Instrument reading method, device and robot
Through the ORB feature recognition and reinforcement learning algorithm, the instrument template image is matched and recognized, and the target instrument subgraph is generated, which solves the problem of slow instrument reading speed and low accuracy of robots in harsh environments, and achieves more efficient instrument data acquisition.
Patent Information
- Application Number
- CN202310104537.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-07
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2043-02-07
AI Technical Summary
In the existing technology, when a robot reads instrument data in a harsh environment, it is affected by environmental complexity and background interference, resulting in slow reading speed and low accuracy.
The ORB feature recognition algorithm is used to match the image to be processed and the instrument template image, determine the affine matrix, generate the target instrument subgraph, and determine the reading display area through the agent trained by the reinforcement learning algorithm, and perform digital recognition to obtain the instrument reading.
By removing background interference, the amount of data processing is reduced, and the speed and accuracy of instrument readings are improved.
Smart Images

Figure CN116189166B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an instrument reading method, device and robot. Background Art
[0002] Instruments are key devices for measuring and monitoring the operating data of various equipment and are widely used in people's daily lives and industrial production. In the existing technology, the reading of instruments is mainly done manually, but for some instruments used in harsh environments, such as high temperature environments and radioactive environments, long-term stay will endanger human health.
[0003] With the continuous development of artificial intelligence technology, there is now a method of using robots to replace workers in high-risk environments to read instruments. Among them, the robot uses a visual system to capture instrument images and uses artificial intelligence technology to identify instrument readings. However, the environment in which the instrument is located is complex, and the shapes of different instruments are different. The instrument image captured by the robot usually also includes the background of the instrument. The background increases the complexity of the image, resulting in a slower instrument reading speed and lower accuracy. Summary of the invention
[0004] The problem solved by the invention is how to improve the speed and accuracy of meter readings.
[0005] In order to solve the above problems, the present invention provides an instrument reading method, device and robot.
[0006] In a first aspect, the present invention provides a meter reading method, comprising:
[0007] Get the image to be processed;
[0008] Using an ORB feature recognition algorithm to match the image to be processed with the instrument template image, and determining an affine matrix from the image to be processed to the instrument template image;
[0009] Performing an inverse transformation on the instrument template image according to the affine matrix, determining the area of the target instrument in the image to be processed, and generating a target instrument sub-image;
[0010] Determine a reading display area from the target instrument sub-image by using a first intelligent agent trained by a reinforcement learning algorithm;
[0011] Digital recognition is performed on the reading display area to determine the reading of the target instrument in the image to be processed.
[0012] Optionally, the using of an ORB feature recognition algorithm to match the image to be processed with an instrument template image including only a target instrument, and determining an affine matrix from the image to be processed to the instrument template image comprises:
[0013] Determine at least one first feature point in the image to be processed and at least one second feature point in the instrument template image, and calculate a first descriptor corresponding to each of the first feature points and a second descriptor corresponding to each of the second feature points;
[0014] Using a Hamming distance matching algorithm to match the first descriptor and the second descriptor to determine a matching point pair;
[0015] The affine matrix from the image to be processed to the instrument template image is determined according to the matching point pairs.
[0016] Optionally, before the first intelligent agent trained by the reinforcement learning algorithm determines the reading display area from the target instrument sub-image, the instrument reading method further includes:
[0017] The first acquisition step is to obtain the current area selected by the ROI selection box;
[0018] Input the current area into the first agent and output a position adjustment strategy;
[0019] adjusting the position of the ROI selection box according to the position adjustment strategy, updating the current area selected by the ROI selection box, and determining a first reward value of the position adjustment strategy according to a first reward function, wherein the first reward function includes a positive correlation between the first reward value and the completeness of the current area including the meter reading;
[0020] The first agent is updated according to the first reward value, and the first acquisition step is executed again, and the loop is iterated until a first preset termination condition is met to obtain a trained first agent.
[0021] Optionally, before acquiring the image to be processed, the instrument reading method further includes:
[0022] A second acquisition step is to acquire a real-time image captured by a visual device;
[0023] Input the real-time image into a second intelligent agent, and output a posture adjustment strategy;
[0024] adjusting the posture of the visual system according to the posture adjustment strategy, controlling the visual system to re-shoot the real-time image, and determining a second reward value of the posture adjustment strategy according to a second reward function, wherein the second reward function includes a positive correlation between the second reward value and the clarity of the real-time image;
[0025] The second agent is updated according to the second reward value, and the second acquisition step is executed again, and the loop is iterated until a second preset termination condition is met to obtain a trained second agent.
[0026] Optionally, acquiring the image to be processed includes:
[0027] The posture of the visual device is adjusted by the trained second intelligent agent, and the visual device is controlled to capture the image to be processed.
[0028] Optionally, the digitally identifying the reading display area to determine the reading of the target instrument in the image to be processed includes:
[0029] When the target instrument is a digital display instrument, preprocessing the target instrument sub-image to obtain a preprocessed sub-image;
[0030] The preprocessed sub-images are trimmed according to the positions of the digits on the target instrument to obtain n digital images, where n is the number of digits on the target instrument;
[0031] Matching the n digital images with a plurality of preset digital template images respectively to determine the reading in each of the digital images;
[0032] The readings in each of the digital images are combined according to the positions of the corresponding digits to obtain the reading of the target instrument in the image to be processed.
[0033] Optionally, matching the n digital images with a plurality of preset digital template images respectively to determine the reading in each of the digital images comprises:
[0034] For any of the digital images, respectively calculating NCC values between the digital image and a plurality of different digital template images;
[0035] Comparing the NCC values, and determining the digital template image with the largest NCC value according to the comparison result;
[0036] The number corresponding to the digital template image with the largest NCC value is determined as the reading in the digital image.
[0037] Optionally, the digitally identifying the reading display area to determine the reading of the target instrument in the image to be processed includes:
[0038] When the target instrument is a pointer-type instrument, determining the position of the pointer in the reading display area;
[0039] Determining the scale adjacent to the pointer and the angle between the pointer and the adjacent pointer according to the position of the pointer;
[0040] The reading of the target instrument in the image to be processed is determined according to the adjacent scales and the angle.
[0041] In a second aspect, the present invention provides a meter reading device, comprising:
[0042] An acquisition module, used for acquiring an image to be processed;
[0043] A matching module, used to match the image to be processed with the instrument template image by using an ORB feature recognition algorithm, and determine an affine matrix from the image to be processed to the instrument template image;
[0044] A positioning module, used to perform an inverse transformation on the instrument template image according to the affine matrix, determine the area of the target instrument in the image to be processed, and generate a target instrument sub-image; determine the reading display area from the target instrument sub-image by using a first intelligent agent trained by a reinforcement learning algorithm;
[0045] The recognition module is used to digitally recognize the reading display area and determine the reading of the target instrument in the image to be processed.
[0046] In a third aspect, the present invention provides a robot, comprising an action device, a visual device and a control device, wherein the control device is used to implement the instrument reading method as described above;
[0047] The action device comprises a mechanical arm module and an end effector module, wherein the end effector module is detachably connected to the end of the mechanical arm module, and the mechanical arm module and the end effector module are electrically connected to the control device respectively;
[0048] The visual device is electrically connected to the control device and is installed on the robot arm module and / or the end effector module.
[0049] The instrument reading method, device and robot of the present invention have the following beneficial effects: obtaining an image to be processed including a target instrument, matching the image to be processed with an instrument template image by an ORB feature recognition algorithm, wherein the instrument template image refers to an image including only the target instrument without the background, and establishing an affine matrix from the image to be processed to the instrument template image according to the matching result. The instrument template image is inversely transformed according to the affine matrix to determine the area where the target instrument is located in the image to be processed, and a target instrument sub-image corresponding to the area where the target instrument is located can be obtained by cropping, and the background area is removed from the target instrument sub-image, which can avoid interference of the background area with the instrument reading recognition, and can reduce the data processing amount of subsequent image recognition. The first intelligent agent can be trained in advance by a reinforcement learning algorithm, and the reading display area is determined from the target instrument sub-image by the trained first intelligent agent, and the area on the target instrument that is not related to the reading is removed to reduce interference and data volume. When the reading display area is digitally recognized, there is no interference from the background area and the irrelevant area on the target instrument, and the data volume is less, which improves the speed and accuracy of determining the target instrument reading in the image to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A schematic diagram of the structure of a robot according to an embodiment of the present invention;
[0051] Figure 2 is a schematic structural diagram of an action device according to an embodiment of the present invention;
[0052] Figure 3 A schematic diagram of a flow chart of an instrument reading method according to an embodiment of the present invention;
[0053] Figure 4 A schematic diagram of a process of matching an image to be processed with an instrument template image to generate a target instrument sub-image according to an embodiment of the present invention;
[0054] Figure 5 The present invention is a schematic diagram of the structure of an instrument reading device according to an embodiment of the present invention.
[0055] Description of reference numerals:
[0056] 10-Robotic arm; 20-Gripper. DETAILED DESCRIPTION
[0057] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be interpreted as being limited to the embodiments described herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.
[0058] It should be noted that, in the coordinate system XYZ provided in this article, the positive direction of the X axis represents the right, the negative direction of the X axis represents the left, the positive direction of the Y axis represents the back, the negative direction of the Y axis represents the front, the positive direction of the Z axis represents the top, and the negative direction of the Z axis represents the bottom.
[0059] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0060] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments"; the term "optionally" means "optional embodiments". Relevant definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc. mentioned in the present invention are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0061] It should be noted that the modifications of "one" and "plurality" mentioned in the present invention are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0062] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes, and are not used to limit the scope of these messages or information.
[0063] like Figure 1 and Figure 2 As shown, a robot provided by an embodiment of the present invention includes a motion device, a visual device and a control device, wherein the control device is used to implement the instrument reading method as described above;
[0064] The action device comprises a mechanical arm module and an end effector module, wherein the end effector module is detachably connected to the end of the mechanical arm module, and the mechanical arm module and the end effector module are electrically connected to the control device respectively;
[0065] The visual device is electrically connected to the control device and is installed on the robot arm module and / or the end effector module.
[0066] Specifically, the robot of this embodiment can be used in laboratories to rotate bottle caps (unscrew / tighten), pipette (absorb / release), shake (solid-liquid / liquid-liquid), read instrument panels, clamp target objects, perform button operations (physical buttons / resistive touch screens), etc., which can be performed under visual servoing or according to a preset action path under non-visual servoing.
[0067] like Figure 2 As shown, the robot arm module may include at least one robot arm 10, and the two robot arms may be symmetrically arranged on the platform. The robot arm 10 may adopt a six-axis robot arm and a seven-axis robot arm, etc. For example, a dual robot arm of model UR3 may be adopted. Compared with other collaborative robot arms, the end joint of UR3 robot arm can rotate infinitely, can be installed on a desktop, and the programming and debugging process is simple. The end effector module may include a variety of different types of grippers 20, such as a two-finger gripper of model PGE-50-26 and a two-finger rotating gripper of RGI-35-14, which has an opening width control but does not have force feedback, is an electric rigid gripper, and has less noise than a pneumatic gripper. The fingertips may be selected from sticky rubber fingertips or elastic fingertips according to the usage scenario. The rotating gripper is more capable of some rotation actions such as opening the bottle cap than the ordinary gripper. In this embodiment, the two-finger gripper is mainly responsible for grasping, and the rotating gripper is mainly used for rotation actions represented by screwing the cap. Figure 2 The middle right robotic arm can be installed with a two-finger gripper, and the left side can be installed with a two-finger gripper with unlimited angular rotation freedom. The end effector module is detachably connected to the end of the robotic arm module, and the appropriate gripper can be selected according to different application scenarios, which is simple and convenient.
[0068] For example, in the laboratory scenario, the size of the object required for the grasping operation is relatively uniform, with little variation and overall small size (no more than 50mm). At this time, if a gripper with a larger stroke is used (such as an AG-95 gripper with a stroke of 100mm), half of the stroke will be redundant. It is worth noting that the redundant stroke here can increase the fault tolerance of grasping, but it will also put forward higher requirements on the spatial characteristics of the grasping area. In this robot, through experimental adjustment, we finally selected a gripper whose stroke range is close to the size range of the grasped object. In addition, for the gripper fingertips, we selected a combination of an outer elastic material and an internal rigid skeleton. On the one hand, the outer elastic surface can provide greater friction, and on the other hand, it can use its own elasticity to fit the surface of the object to be grasped. The combination of the two improves the grasping effect (for example, for a round test tube, the original fingertips are metal planes, and the contact surface between the two can be approximately regarded as a line, with a small area, a low friction coefficient, and easy slipping during grasping).
[0069] The visual module may include a global camera and a three-eye depth camera. The three-eye depth camera can be installed on the wrist of the robot arm. Specifically, the four circles of different sizes from left to right are infrared camera a, active infrared speckle projector, infrared camera b and color camera. There is an obvious distance between infrared cameras a and b. This distance corresponds to the baseline length, and this distance also causes the parallax of cameras a and b. The data collected by the visual module corresponds to the depth image data and color image data in the data layer. These data will be transmitted to the specific functions in the application layer running on the system layer through the hardware in the network layer. For example, during the calibration process, some color image data will be transmitted to the visual positioning function module, and the calibration results in the data layer can be obtained after the calculation and processing of this module. The posture data of the robot arm and the gripper in the data layer can be directly read from the corresponding hardware.
[0070] Specifically, for the wrist camera, first of all, it is considered that the three-eye depth camera has a distance blind spot, which is usually about 15cm. When the distance between the target object and the camera is less than this value, reliable depth information cannot be obtained. Secondly, considering that the gripper 20 will cause a certain degree of occlusion to the field of view of the wrist camera, it is necessary to adjust the distance between the camera and the gripper fingertips and the angle between the camera optical axis and the gripper axis. Reducing the distance between the camera and the gripper fingertips and increasing the angle between the two axes can reduce the field of view occlusion, but if the camera-fingertip distance is too small, it will enter the blind spot of the depth camera, and if the angle between the two axes is too large, the distortion of the captured target object will be aggravated. For the global camera, the placement distance is mainly determined by considering the visual protection function and the performance characteristics of the global camera used. The global camera can be installed vertically above the robot body to overlook the overall status of the system. On the one hand, it provides primary feature information for the operation task, and then mobilizes the robot arm and wrist camera; on the other hand, it is to ensure the safety of the operation process. For example: when the robot is used in a laboratory environment, the robot's operating object may involve high-risk biological, chemical and nuclear materials, which are seriously harmful to human health, and a safe distance needs to be strictly maintained. At this time, the global camera estimates the distance between the person in the field of view and the robot, and responds to different degrees when entering different intervals. More specifically, for example, when the robot performs pathogen-related operations, a reminder is issued when the human is 5m away, a warning is issued when the human is 3m away, and a protective disinfection program is started at 2m. For example, when the robot is performing some high-speed operations, the running speed is positively correlated with the human distance. When it is less than a certain threshold, the operation is directly suspended, and when it is greater than another threshold, it runs at full speed.
[0071] In an optional embodiment, the control device may include a human-computer interaction module and a relay module, the human-computer interaction module may include a teaching pendant and a computer, the computer may include a memory and a processor; the memory is used to store a computer program; the processor is used to implement the meter reading method described below when executing the computer program. The relay module may include a router and a switch.
[0072] Specifically, the human-computer interaction module is used to receive control instructions input by the user and can display the real-time status of the system in a visual way. The relay module is responsible for the communication between different hardware parts. The teach pendant is used for early basic development and temporary debugging. The computer is used for algorithm development and testing.
[0073] In this embodiment, the conversion relationship between the spatial coordinate system where the end of the robot arm is located and the camera visual coordinate system can be determined by hand-eye calibration. The origin, a point on the positive half axis of the x-axis, and any point on the first quadrant can be taught in sequence through manual control, and the plane corresponding to this teaching can be obtained by calculation. The plane teaching process can be used to determine the horizontal position of the operating object. On this basis, the vertical distance value collected by the trinocular depth camera, that is, the information of the z-axis in space, can be added to complete the positioning.
[0074] like Figure 3 As shown, an instrument reading method provided by an embodiment of the present invention includes:
[0075] Step S100, obtaining an image to be processed.
[0076] Specifically, the instrument to be read is photographed by a visual device to obtain an image to be processed.
[0077] Step S200, using an ORB (Oriented FAST and Rotated BRIEF, fast feature extraction and description algorithm) feature recognition algorithm to match the image to be processed and the instrument template image, and determining an affine matrix from the image to be processed to the instrument template image.
[0078] Specifically, the instrument template image is an image that only includes the target instrument after removing the background, and the target instrument can be photographed in advance to obtain the image.
[0079] Step S300, performing an inverse transformation on the instrument template image according to the affine matrix, determining the area of the target instrument in the image to be processed, and generating a target instrument sub-image.
[0080] Specifically, an inverse affine transformation is performed on the instrument template image according to the affine matrix, and the region of the target instrument in the image to be processed can be determined according to the instrument template image, and the target instrument sub-image can be obtained by selecting the region.
[0081] Step S400, determining a reading display area from the target instrument sub-image by using a first intelligent agent trained by a reinforcement learning algorithm.
[0082] Specifically, the first intelligent agent may be trained in advance through a reinforcement learning algorithm to obtain a trained first intelligent agent for determining a reading display area.
[0083] Step S500, digitally identifying the reading display area to determine the reading of the target instrument in the image to be processed.
[0084] Specifically, a recognition algorithm may be used to recognize numbers in the reading display area to determine the reading of the target instrument in the image to be processed.
[0085] In this embodiment, an image to be processed including a target instrument is obtained, and the image to be processed and the instrument template image are matched by the ORB feature recognition algorithm. The instrument template image refers to an image that does not include the background but only includes the target instrument. An affine matrix from the image to be processed to the instrument template image is established according to the matching result. The instrument template image is inversely transformed according to the affine matrix to determine the area where the target instrument is located in the image to be processed. The target instrument sub-image corresponding to the area where the target instrument is located can be obtained by cropping. The background area is removed from the target instrument sub-image, which can avoid interference of the background area on the instrument reading recognition and can reduce the data processing amount of subsequent image recognition. The first intelligent agent can be trained in advance by the reinforcement learning algorithm, and the reading display area is determined from the target instrument sub-image by the trained first intelligent agent, and the area on the target instrument that is not related to the reading is removed to reduce interference and data volume. When the reading display area is digitally recognized, there is no interference from the background area and the irrelevant area on the target instrument, and the amount of data is less, which improves the speed and accuracy of determining the target instrument reading in the image to be processed.
[0086] Optionally, the using an ORB feature recognition algorithm to match the image to be processed and the instrument template image, and determining an affine matrix from the image to be processed to the instrument template image includes:
[0087] At least one first feature point in the image to be processed and at least one second feature point in the instrument template image are determined, and a first descriptor corresponding to each of the first feature points and a second descriptor corresponding to each of the second feature points are calculated.
[0088] Specifically, the detector and descriptor provided in OpenCV can be used to detect the Oriented FAST corner point position (i.e., the first feature point) in the image to be processed, and calculate the corresponding BRIEF descriptor (i.e., the first descriptor), as well as the Oriented FAST corner point position (i.e., the second feature point) in the instrument template image, and calculate the corresponding BRIEF descriptor (i.e., the second descriptor).
[0089] The first descriptor and the second descriptor are matched using a Hamming distance matching algorithm to determine a matching point pair.
[0090] Specifically, the Hamming distance matching algorithm (BruteForce-Hamming) provided in OpenCV can be used to match the two groups of descriptors. The Hamming distance of each matching point pair can be compared with a preset threshold, and the matching point pairs with a Hamming distance greater than the preset threshold can be screened out. The preset threshold can be twice the minimum Hamming distance of the matching point pairs in each detection. In order to avoid the Hamming distance being too small, a minimum value can be set according to the experience value to screen out the matching point pairs with a Hamming distance less than the minimum value.
[0091] The affine matrix from the image to be processed to the instrument template image is determined according to the matching point pairs.
[0092] Specifically, the homography matrix (i.e., affine matrix) from the image to be tested to the template image can be estimated through the cv::findHomography function.
[0093] In this optional embodiment, the ORB feature recognition algorithm can be used to quickly establish an affine matrix from the image to be processed to the instrument template image, and the reading display area in the image to be processed is determined by the affine matrix, and the background area is screened out, thereby improving the speed and accuracy of the instrument reading.
[0094] Optionally, performing an inverse transformation on the instrument template image according to the affine matrix, determining a region of a target instrument in the image to be processed, and generating a target instrument sub-image comprises:
[0095] The four corners of the instrument template image are inversely transformed into the image to be processed according to the affine matrix, and the minimum bounding rectangle is determined based on the four corners in the inversely transformed image to be processed. The minimum bounding rectangle is the ROI to be detected, that is, the area of the target instrument in the image to be processed.
[0096] For example, Figure 4 The target instrument is shown as a pipette as an example. Figure 4The leftmost pipette is the target instrument template image, which includes all feature points matched by the ORB feature recognition algorithm. However, some of the feature points are not on the pipette. After filtering out some feature points, Figure 4 The vertical pipette in the middle is transformed through affine inverse transformation to obtain the target instrument sub-image, that is, Figure 4 The vertical pipette on the far right.
[0097] In this optional embodiment, when the shooting environment of the instrument template image is basically the same as that of the image to be processed, the position of the target instrument in the image to be processed is no longer limited, the ROI area may not be directly limited, and the error tolerance of the target instrument in the image to be processed is expanded. The ROI area can also be used to set the white balance reference area of the trinocular depth camera to improve the clarity of the target instrument in the image to be processed.
[0098] In an optional embodiment, for a digital display instrument, the image to be processed may be transformed using an affine matrix through the cv::warpPerspect function, and the transformed image to be processed may be clipped to make its size match the instrument template image;
[0099] Then, according to the position of each digit in the instrument template image, the sub-image corresponding to each digit position in the transformed image to be processed is cut out; the cv::Canny function is used to process each sub-image to obtain an edge binary image;
[0100] Use cv::findContours function (mode = CV_RETR_TREE) to find the contour and obtain the hierarchical relationship;
[0101] If there is only one contour level, use the cv::fillContours function to fill the contour with white, and determine the meter reading by matching. If there are two contour levels, first use the cv::fillContours function to fill the second-bottom contour with white, then fill the bottom contour with black, and determine the meter reading by matching.
[0102] Optionally, before the first intelligent agent trained by the reinforcement learning algorithm determines the reading display area from the target instrument sub-image, the instrument reading method further includes:
[0103] The first acquisition step is to obtain the current area selected by the ROI (region of interest) selection box;
[0104] Input the current area into the first agent and output a position adjustment strategy;
[0105] adjusting the position of the ROI selection box according to the position adjustment strategy, updating the current area selected by the ROI selection box, and determining a first reward value of the position adjustment strategy according to a first reward function, wherein the first reward function includes a positive correlation between the first reward value and the completeness of the current area including the meter reading;
[0106] The first agent is updated according to the first reward value, and the first acquisition step is executed again, and the loop is iterated until a first preset termination condition is met to obtain a trained first agent.
[0107] Specifically, the first agent is used to control the ROI selection box to accurately determine the reading display area of the instrument to avoid selecting irrelevant areas. The first agent can use a model-free learning-based Q-learning DQN (Deep Q-learning Network) algorithm, which is easy to implement.
[0108] First, the entire instrument area is coarsely selected to obtain the target instrument sub-image, which completely includes the reading display area. The trained first agent can control the ROI selection box to select the reading display area. The integrity of the selected data can be judged by identifying whether the reading in the reading display area is meaningful. For example, when the selection is incomplete, low confidence results or uncommon characters will appear in the character recognition results, and the reward function will give a negative score.
[0109] For example, suppose the actual data is "200", but because the box selection is incomplete, the recognition result output is "20u", and the letter u here is an abnormal symbol. Whether a symbol is abnormal can be judged by counting a certain number of recognition results, and those low-frequency symbols are marked as abnormal symbols.
[0110] In addition, for the optimization of the ROI selection box, because the ROI selection box will affect the imaging effect (the white balance of the image can be determined based on the ROI) and will also affect the character recognition results (such as the incomplete selection box mentioned above), the following second reward function can also be used for optimization.
[0111] In this optional embodiment, the first intelligent agent is trained by a reinforcement learning algorithm. The trained first intelligent agent can accurately determine the reading display area from the target instrument sub-image and filter out the background area to avoid interference from the background area, reduce the amount of data processing, and thereby improve the speed and accuracy of the instrument reading.
[0112] Optionally, before acquiring the image to be processed, the instrument reading method further includes:
[0113] A second acquisition step is to acquire a real-time image captured by a visual device;
[0114] Input the real-time image into a second intelligent agent, and output a posture adjustment strategy;
[0115] adjusting the posture of the visual system according to the posture adjustment strategy, controlling the visual system to re-shoot the real-time image, and determining a second reward value of the posture adjustment strategy according to a second reward function, wherein the second reward function includes a positive correlation between the second reward value and the clarity of the real-time image;
[0116] The second agent is updated according to the second reward value, and the second acquisition step is executed again, and the loop is iterated until a second preset termination condition is met to obtain a trained second agent.
[0117] Specifically, the second agent is used to control the visual device to capture the image to be processed including the target instrument as clearly as possible, and a model-free learning based Q-learning DQN (Deep Q-learning Network) algorithm can be used. The second agent can control the visual device to avoid shooting distances that are too far or too close and shooting angles that are too inclined. Specifically, it can control the robotic arm to move in different postures to avoid bad shooting postures. The setting of the second reward function is related to the imaging quality. The clearer the imaging, the higher the success rate and confidence of the recognition reading, thereby obtaining a higher score.
[0118] Optionally, acquiring the image to be processed includes:
[0119] The posture of the visual device is adjusted by the trained second intelligent agent, and the visual device is controlled to capture the image to be processed.
[0120] In this optional embodiment, the second intelligent agent is trained by a reinforcement learning algorithm, and the trained second intelligent agent is used to control the visual device to avoid bad shooting postures and capture clear images to be processed. The clear images to be processed help improve the accuracy of instrument readings.
[0121] Optionally, the digitally identifying the reading display area to determine the reading of the target instrument in the image to be processed includes:
[0122] When the target instrument is a digital instrument, the target instrument sub-image is preprocessed to obtain a preprocessed sub-image.
[0123] Specifically, the target instrument sub-image may be pre-processed by scaling, cropping, graying, and Gaussian filtering.
[0124] The preprocessed sub-images are clipped according to the positions of the digits on the target instrument to obtain n digital images, where n is the number of digits on the target instrument.
[0125] Specifically, the position of each digit on the target instrument can be determined based on the instrument template image. For example, if the reading on the preprocessed sub-image is 3.578, four digital images can be obtained by cropping, that is, n=4, among which the decimal point can be directly identified, or a decimal point template image can be added to the digital template image to determine the decimal point by matching.
[0126] The n digital images are matched with a plurality of preset digital template images respectively to determine the reading in each of the digital images.
[0127] Specifically, the digital template image includes 10 digital template images, specifically 0, 1, 2, ..., 9, and each digital image is matched with the 10 digital template images respectively to determine the reading corresponding to each digital image.
[0128] The readings in each of the digital images are combined according to the positions of the corresponding digits to obtain the reading of the target instrument in the image to be processed.
[0129] Specifically, by combining the readings according to the digit positions corresponding to the digital images, the readings of the target instrument in the image to be processed can be obtained. When there is a decimal point, the identified decimal point needs to be placed in the combination according to the corresponding position.
[0130] In this optional embodiment, by matching with the digital template image, the reading corresponding to the digital image can be quickly determined, and then the reading of the target instrument in the image to be processed can be determined.
[0131] Optionally, matching the n digital images with a plurality of preset digital template images respectively to determine the reading in each of the digital images comprises:
[0132] For any of the digital images, NCC (Normalized cross-correlation) values between the digital image and a plurality of different digital template images are calculated respectively.
[0133] For example, assuming that the reading on the preprocessed sub-image is 3.578, the four digital images are 3, 5, 7, and 8, respectively. For digital image 3, the NCC values between it and the digital template images of 0, 1, 2, ..., 9 are calculated respectively. Each NCC value is compared with a preset threshold, and the digital template images with NCC values less than the preset threshold are screened out, and the digital template images with NCC values greater than or equal to the preset threshold are retained. The NCC value greater than or equal to the preset threshold indicates a successful match.
[0134] The NCC values are compared, and the digital template image with the largest NCC value is determined according to the comparison result.
[0135] Specifically, the NCC values of each successful match are compared, and the digital template image with the largest NCC value is determined as the correct matching result.
[0136] The number corresponding to the digital template image with the largest NCC value is determined as the reading in the digital image.
[0137] Specifically, the number corresponding to the digital template image is the reading of the digital image. In this example, the NCC value between digital image 3 and digital template image 3 is the largest.
[0138] Optionally, the digitally identifying the reading display area to determine the reading of the target instrument in the image to be processed includes:
[0139] When the target instrument is a pointer-type instrument, determining the position of the pointer in the reading display area;
[0140] Determining the scale adjacent to the pointer and the angle between the pointer and the adjacent pointer according to the position of the pointer;
[0141] The reading of the target instrument in the image to be processed is determined according to the adjacent scales and the angle.
[0142] In an optional embodiment, the angle between the current position and the initial position of the pointer may be directly determined, and the reading of the target instrument may be determined by the correspondence between the preset angle and the reading.
[0143] Specifically, the position of the pointer in the reading display area can be determined by the recognition algorithm, and the meter reading can be determined by judging the positional relationship between the pointer and the adjacent large scale with numbers, the middle scale without numbers, and the small scale. When a digit needs to be estimated, the reading of the estimated digit can be determined based on the angle value between the current position of the pointer and its left adjacent readable digit, the ratio of the angle value to the angle between the two smallest scales, and then multiplied by the spacing between the two smallest scales. Among them, the angle value and the spacing between the two smallest scales are constants that can be determined in advance.
[0144] like Figure 5 As shown, an instrument reading device provided by an embodiment of the present invention includes:
[0145] An acquisition module, used for acquiring an image to be processed;
[0146] A matching module, used to match the image to be processed with the instrument template image by using an ORB feature recognition algorithm, and determine an affine matrix from the image to be processed to the instrument template image;
[0147] A positioning module, used to perform an inverse transformation on the instrument template image according to the affine matrix, determine the area of the target instrument in the image to be processed, and generate a target instrument sub-image; determine the reading display area from the target instrument sub-image by using a first intelligent agent trained by a reinforcement learning algorithm;
[0148] The recognition module is used to digitally recognize the reading display area and determine the reading of the target instrument in the image to be processed.
[0149] The meter reading device of this embodiment is used to implement the meter reading method as described above. Its advantages over the prior art are the same as the advantages of the above-mentioned meter reading method over the prior art, and will not be described in detail here.
[0150] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. In the present application, the unit described as a separate component may or may not be physically separated, and the component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or it may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment of the present invention. In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0151] Although the present invention is disclosed as above, the protection scope of the present invention is not limited thereto. Those skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention, and these changes and modifications will fall within the protection scope of the present invention.
Claims
1. A method for reading an instrument, characterized in that: include: Get the image to be processed; Using an ORB feature recognition algorithm to match the image to be processed with the instrument template image, and determining an affine matrix from the image to be processed to the instrument template image; Performing an inverse transformation on the instrument template image according to the affine matrix, determining the area of the target instrument in the image to be processed, and generating a target instrument sub-image; Determine a reading display area from the target instrument sub-image by using a first intelligent agent trained by a reinforcement learning algorithm; Digitally identifying the reading display area to determine the reading of the target instrument in the image to be processed; Before the first agent trained by the reinforcement learning algorithm determines the reading display area from the target instrument sub-image, the instrument reading method further includes: a first acquisition step, acquiring the current area selected by the ROI selection box; inputting the current area into the first agent, and outputting a position adjustment strategy; adjusting the position of the ROI selection box according to the position adjustment strategy, updating the current area selected by the ROI selection box, and determining a first reward value of the position adjustment strategy according to a first reward function, wherein the first reward function includes a positive correlation between the first reward value and the completeness of the current area including the instrument reading; updating the first agent according to the first reward value, returning to execute the first acquisition step, and iterating in a loop until a first preset termination condition is met, thereby obtaining a trained first agent; The digital identification of the reading display area to determine the reading of the target instrument in the image to be processed includes: when the target instrument is a digital display instrument, preprocessing the target instrument sub-image to obtain a preprocessed sub-image; cutting the preprocessed sub-image according to the position of the digits on the target instrument to obtain n digital images, wherein n is the number of digits on the target instrument; matching the n digital images with a plurality of preset digital template images respectively to determine the reading in each of the digital images; combining the readings in each of the digital images according to the corresponding position of the digits to obtain the reading of the target instrument in the image to be processed; The step of matching the n digital images with a plurality of preset digital template images respectively to determine the readings in each of the digital images comprises: for any of the digital images, respectively calculating the NCC values between the digital image and a plurality of different digital template images; comparing the NCC values, and determining the digital template image with the largest NCC value according to the comparison result; and determining the number corresponding to the digital template image with the largest NCC value as the reading in the digital image; The digital identification of the reading display area to determine the reading of the target instrument in the image to be processed includes: when the target instrument is a pointer-type instrument, determining the position of the pointer in the reading display area; determining the scale adjacent to the pointer and the angle between the pointer and the adjacent scale according to the position of the pointer; and determining the reading of the target instrument in the image to be processed according to the adjacent scale and the angle; When a digit needs to be estimated, the ratio of the angle value to the angle between the two smallest scales is determined based on the angle between the current position of the pointer and its adjacent scale to the left, and then multiplied by the distance between the two smallest scales to determine the reading of the estimated digit.
2. The meter reading method according to claim 1, characterized in that: The step of using the ORB feature recognition algorithm to match the image to be processed with an instrument template image that only includes the target instrument, and determining an affine matrix from the image to be processed to the instrument template image includes: Determine at least one first feature point in the image to be processed and at least one second feature point in the instrument template image, and calculate a first descriptor corresponding to each of the first feature points and a second descriptor corresponding to each of the second feature points; Using a Hamming distance matching algorithm to match the first descriptor and the second descriptor to determine a matching point pair; The affine matrix from the image to be processed to the instrument template image is determined according to the matching point pairs.
3. The meter reading method according to claim 1, characterized in that: Before acquiring the image to be processed, the instrument reading method further includes: A second acquisition step is to acquire a real-time image captured by a visual device; Input the real-time image into a second intelligent agent, and output a posture adjustment strategy; adjusting the posture of the visual system according to the posture adjustment strategy, controlling the visual system to re-shoot the real-time image, and determining a second reward value of the posture adjustment strategy according to a second reward function, wherein the second reward function includes a positive correlation between the second reward value and the clarity of the real-time image; The second agent is updated according to the second reward value, and the second acquisition step is executed again, and the loop is iterated until a second preset termination condition is met to obtain a trained second agent.
4. The meter reading method according to claim 3, characterized in that: The obtaining of the image to be processed comprises: The posture of the visual device is adjusted by the trained second intelligent agent, and the visual device is controlled to capture the image to be processed.
5. A meter reading device, characterized in that: include: An acquisition module, used for acquiring an image to be processed; A matching module, used to match the image to be processed with the instrument template image by using an ORB feature recognition algorithm, and determine an affine matrix from the image to be processed to the instrument template image; A positioning module, used for performing an inverse transformation on the instrument template image according to the affine matrix, determining the area of the target instrument in the image to be processed, and generating a target instrument sub-image; Determine a reading display area from the target instrument sub-image by using a first intelligent agent trained by a reinforcement learning algorithm; An identification module, used for digitally identifying the reading display area and determining the reading of the target instrument in the image to be processed; Before the first agent trained by the reinforcement learning algorithm determines the reading display area from the target instrument sub-image, the instrument reading method further includes: a first acquisition step, acquiring the current area selected by the ROI selection box; inputting the current area into the first agent, and outputting a position adjustment strategy; adjusting the position of the ROI selection box according to the position adjustment strategy, updating the current area selected by the ROI selection box, and determining a first reward value of the position adjustment strategy according to a first reward function, wherein the first reward function includes a positive correlation between the first reward value and the completeness of the current area including the instrument reading; updating the first agent according to the first reward value, returning to execute the first acquisition step, and iterating in a loop until a first preset termination condition is met, thereby obtaining a trained first agent; The digital identification of the reading display area to determine the reading of the target instrument in the image to be processed includes: when the target instrument is a digital display instrument, preprocessing the target instrument sub-image to obtain a preprocessed sub-image; cutting the preprocessed sub-image according to the position of the digits on the target instrument to obtain n digital images, wherein n is the number of digits on the target instrument; matching the n digital images with a plurality of preset digital template images respectively to determine the reading in each of the digital images; combining the readings in each of the digital images according to the corresponding position of the digits to obtain the reading of the target instrument in the image to be processed; The step of matching the n digital images with a plurality of preset digital template images respectively to determine the readings in each of the digital images comprises: for any of the digital images, respectively calculating the NCC values between the digital image and a plurality of different digital template images; comparing the NCC values, and determining the digital template image with the largest NCC value according to the comparison result; and determining the number corresponding to the digital template image with the largest NCC value as the reading in the digital image; The digital identification of the reading display area to determine the reading of the target instrument in the image to be processed includes: when the target instrument is a pointer-type instrument, determining the position of the pointer in the reading display area; determining the scale adjacent to the pointer and the angle between the pointer and the adjacent scale according to the position of the pointer; and determining the reading of the target instrument in the image to be processed according to the adjacent scale and the angle; When a digit needs to be estimated, the ratio of the angle value to the angle between the two smallest scales is determined based on the angle between the current position of the pointer and its adjacent scale to the left, and then multiplied by the distance between the two smallest scales to determine the reading of the estimated digit.
6. A robot, characterized in that: It comprises an action device, a visual device and a control device, wherein the control device is used to implement the meter reading method according to any one of claims 1 to 4; The action device comprises a mechanical arm module and an end effector module, wherein the end effector module is detachably connected to the end of the mechanical arm module, and the mechanical arm module and the end effector module are electrically connected to the control device respectively; The visual device is electrically connected to the control device and is installed on the robot arm module and / or the end effector module.
