Vision-based rotation axis posture detection method and device
Through the vision-based rotation axis pose detection method, binocular cameras are used to identify the color patches of tooling parts to calculate the rotation axis pose information, which solves the problems of complex, inaccurate and high-cost measurement in the existing technology, and achieves low-cost, accurate rotation axis Position measurement.
Patent Information
- Application Number
- CN202110551349.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-20
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-05-20
AI Technical Summary
The existing technology has the problems of complex measurement, inaccurate information, high cost and harsh instrument usage conditions in rotating shaft posture detection. It is especially unfriendly to harsh environments and high-cost equipment automation transformation.
The vision-based rotation axis pose detection method is used to collect images through binocular cameras, identify the color blocks of tooling parts, calculate the position of the dividing line between the color blocks, and calculate the pose information of the rotation axis, including coordinates and rotation angles. It is suitable for various applications. Automate scenarios, reduce costs and increase measurement accuracy.
It achieves low-cost and accurate measurement of the position and orientation information of the rotating shaft without changing the internal structure of the equipment. It is suitable for various automation scenarios and reduces measurement errors and equipment modification costs.
Smart Images

Figure CN113205561B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of posture detection, and in particular to a method, device, computer equipment and storage medium for detecting the posture of a rotating shaft based on vision. Background Art
[0002] Visual measurement technology has a series of advantages such as strong real-time performance, high precision, and high degree of automation, and is widely used in a series of fields such as industrial visual inspection, remote sensing image analysis, and aircraft visual navigation. In the field of industrial visual inspection, the detection of the rotation axis posture of automation equipment is a commonly used detection technology. The rotation axis posture detection refers to the acquisition of target images and feature extraction of the images to solve the target posture information.
[0003] At present, photoelectric encoders or magnetic encoders are mostly used in engineering to detect the position and posture of the rotating shaft. However, when these encoders are used to detect the position and posture of the rotating shaft, they need to be mechanically coordinated with the shaft end to perform measurements. The measurement process is complicated and the measured rotating shaft information is inaccurate. Summary of the invention
[0004] Based on this, it is necessary to provide a vision-based shaft posture detection method, device, computer equipment and storage medium that can improve the accuracy of shaft posture information calculation in order to solve the above-mentioned technical problems.
[0005] In a first aspect, a method for detecting a rotation axis posture based on vision is provided, the method comprising:
[0006] Acquire an image group obtained by capturing a tooling component of a target rotating shaft with a binocular camera, where the images included in the image group are captured at the same time;
[0007] According to a preset image recognition strategy, the tooling component color blocks in each image included in the image group are identified, and the identified tooling component color blocks are marked respectively to obtain a calibration image corresponding to each image;
[0008] For each calibration image, identify the position of the dividing line between each color block in the calibration image;
[0009] According to the position of the dividing line between each color block, the position information of the target rotation axis is calculated.
[0010] In one of the embodiments, the position information of the target rotation axis includes at least the coordinates and rotation angle of the target rotation axis;
[0011] According to the position of the dividing line between each color block, the position information of the target axis is calculated, including:
[0012] In each calibration image, determine the position of the segmentation line between the matching color blocks as the target position pair;
[0013] According to the target position pair, the depth value between the tooling component and the binocular camera is calculated;
[0014] Calculate the center coordinates of the circle according to the depth value;
[0015] Calculate the angle values of target position pairs in pairs to obtain multiple angle values, cluster the multiple angle values, and select the target position pairs corresponding to the angle values in the angle distribution area with the largest density to calculate the radius value of the target rotation axis;
[0016] Calculate the radius residual value according to the radius value and the standard radius value of the target rotation axis, and discard the target position pair corresponding to the radius residual value greater than the preset residual threshold;
[0017] The calculated angle values are averaged according to the remaining target positions to obtain the rotation angle of the target shaft;
[0018] The calculated center coordinates are averaged according to the remaining target positions to obtain the coordinates of the target rotation axis.
[0019] In one embodiment, in each calibration image, determining the position of a segmentation line between each matching color block as a target position pair includes:
[0020] When the color difference of the color blocks on both sides of the different segmentation line positions identified in each calibration image is less than a preset difference threshold, a target position pair is obtained.
[0021] In one embodiment, the identified color blocks of the tooling components are marked respectively to obtain a calibration image corresponding to each image, including:
[0022] According to the tonal ranges corresponding to different color blocks in the tooling parts collected in advance, the tonal values corresponding to the color blocks of the tooling parts in each image included in the image group are identified in the hexagonal pyramid model space;
[0023] The hue values of the identified color blocks of the tooling parts are marked according to the standardized hue values to obtain a calibration image corresponding to each image.
[0024] In one embodiment, for each calibration image, identifying the position of a segmentation line between color blocks in the calibration image includes:
[0025] Extract edge features of the calibration image to obtain an edge image;
[0026] Detecting the upper and lower boundaries of the tooling parts in the edge image;
[0027] Extract the image between the upper boundary and the lower boundary of the tooling component to obtain a cropped image;
[0028] The dividing lines between the color blocks in the cropped image are detected by a preset dividing line detection algorithm to obtain the dividing line positions between the color blocks.
[0029] In one embodiment, after extracting edge features of the calibration image to obtain the edge image, the method further includes:
[0030] Fill the discontinuous areas in the edge image to obtain a complete edge image;
[0031] Calculate the area of each closed contour in the complete edge image, and remove the contours whose area is less than the preset area threshold;
[0032] Perform polygon fitting on the complete edge image after elimination, extract the contour whose area after fitting is larger than the preset area threshold, and obtain the target image;
[0033] Detect the upper and lower boundaries of the tooling parts in the edge image, including:
[0034] Detect the upper and lower boundaries of the tooling part in the target image.
[0035] In one embodiment, the method further comprises:
[0036] Obtaining the position and posture information of the target rotation axis calculated through multiple image groups;
[0037] Among the multiple angle values obtained in the position information of the multiple target rotation axes, the angle value within the preset error range is selected. When the number of angle values within the preset error range reaches the preset number, the average value of the angle values within the preset error range and the corresponding average value of the rotation axis coordinates are calculated to obtain the final angle value and final rotation axis coordinate value of the target rotation axis.
[0038] In a second aspect, a device for detecting the position and posture of a rotating shaft based on vision is provided, the device comprising:
[0039] An acquisition module is used to acquire an image group obtained by capturing a tooling component of a target rotating shaft with a binocular camera, where the images contained in the image group have the same acquisition time;
[0040] A marking module, used to identify the tooling component color blocks in each image included in the image group according to a preset image recognition strategy, and mark the identified tooling component color blocks respectively to obtain a calibration image corresponding to each image;
[0041] A recognition module, for identifying the position of the dividing line between each color block in each calibration image;
[0042] The calculation module is used to calculate the position information of the target rotation axis according to the position of the dividing line between each color block.
[0043] In a third aspect, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0044] Acquire an image group obtained by capturing a tooling component of a target rotating shaft with a binocular camera, where the images included in the image group are captured at the same time;
[0045] According to a preset image recognition strategy, the tooling component color blocks in each image included in the image group are identified, and the identified tooling component color blocks are marked respectively to obtain a calibration image corresponding to each image;
[0046] For each calibration image, identify the position of the dividing line between each color block in the calibration image;
[0047] According to the position of the dividing line between each color block, the position information of the target rotation axis is calculated.
[0048] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0049] Acquire an image group obtained by capturing a tooling component of a target rotating shaft with a binocular camera, where the images included in the image group are captured at the same time;
[0050] According to a preset image recognition strategy, the tooling component color blocks in each image included in the image group are identified, and the identified tooling component color blocks are marked respectively to obtain a calibration image corresponding to each image;
[0051] For each calibration image, identify the position of the dividing line between each color block in the calibration image;
[0052] According to the position of the dividing line between each color block, the position information of the target rotation axis is calculated.
[0053] The above-mentioned vision-based shaft posture detection method, device, computer equipment and storage medium obtain an image group obtained by acquiring the tooling components of the target shaft by a binocular camera, and the images contained in the image group are collected at the same time; according to a preset image recognition strategy, the color blocks of the tooling components in each image contained in the image group are identified, and the identified tooling component color blocks are respectively marked to obtain a calibration image corresponding to each image; for each calibration image, the position of the dividing line between each color block is identified in the calibration image; according to the position of the dividing line between each color block, the posture information of the target shaft is calculated. This method obtains an image group of tooling components on the target shaft acquired by a binocular camera, identifies the position information of different color blocks of the tooling components in the image group, and calculates the posture information of the shaft according to the position information of different color blocks. It is a shaft posture test method with low cost and applicable to various automation scenarios, and can also improve the accuracy of shaft posture information measurement. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 1 is a flow chart of a method for detecting the rotation axis posture based on vision in one embodiment;
[0055] Figure 2 A schematic diagram of the structure of a tooling component in an embodiment;
[0056] Figure 3 A front view showing the positional relationship between a binocular camera and a tooling component in one embodiment;
[0057] Figure 4 is an isometric view of the positional relationship between a binocular camera and a tooling component in one embodiment;
[0058] Figure 5 A schematic diagram of an image in an image group captured by a binocular camera in one embodiment;
[0059] Figure 6 is a schematic diagram of calibrating an image in one embodiment;
[0060] Figure 7 is a schematic diagram of graying a calibration image in one embodiment;
[0061] Figure 8 is a schematic diagram of an edge image in one embodiment;
[0062] Fig. 9 is a schematic diagram of a complete edge image in one embodiment;
[0063] Fig.10 is a schematic diagram of a difference detection window in one embodiment;
[0064] Figures 11(a) and (b) are schematic diagrams of target position pairs in one embodiment;
[0065] Fig.12 is a schematic diagram of angle calculation in one embodiment;
[0066] Fig.13 is a complete flow chart of the rotation axis posture detection based on vision in one embodiment;
[0067] Fig.14 A coordinate distribution point diagram of a target rotation axis in one embodiment;
[0068] Fig.15 is a distribution point diagram of the rotation angle error of the target rotating shaft in one embodiment;
[0069] Fig.16 is a structural block diagram of a rotation axis posture detection device based on vision in one embodiment;
[0070] Fig.17 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0072] Axis position information is very common feedback information in various automation equipment. This feedback information plays a very critical role in the subsequent control of the entire system and collaboration with the outside world.
[0073] For fixed axis problems, the position of the axis is generally fixed, and the position and posture of the axis only involves the degree of freedom of rotation; however, for dynamic axis problems, the position and posture of the axis also involves the degree of freedom of controlling the position. In engineering, the method commonly used to detect the position and posture of the axis is to use a photoelectric encoder. For fixed axis problems, the encoder can be directly installed on the shaft end to output the angle. For complex dynamic axis problems, it is necessary to calculate the output of different encoders based on other position constraint information to obtain complete axis position and posture information.
[0074] Although photoelectric encoders have advantages such as high accuracy and non-contact, they are not suitable for many harsh environments, so the use of magnetic encoders is gradually being promoted. Although these two encoders can output the rotation angle information of the shaft very accurately, they both need to be mechanically matched with the shaft end to measure. Such limitations are very unfriendly to the automation transformation of some high-cost equipment, because the trial-and-error cost of redesigning and assembling the parts of this inherent equipment is very high.
[0075] In addition, the information output by a single encoder can only reflect the angle information of the current axis and cannot obtain information on other degrees of freedom. Therefore, the detection method of a single encoder is also relatively limited in terms of the amount of information obtained.
[0076] Although there are other methods for precision measurement of rotating shafts at home and abroad, such as using laser interferometers, ballbars or microscopes for measurement, these methods have very strict requirements on the use scenarios, and the cost of using the instruments themselves is very high.
[0077] From the above content, it can be seen that the current limitations of shaft posture measurement are: 1. Cost constraints on the modification of existing equipment; 2. The amount of posture information is relatively limited; 3. The use conditions of the instrument used to measure the posture itself are demanding; 4. The instrument used to measure the posture itself is expensive.
[0078] Therefore, the present application proposes a vision-based shaft posture detection which has low cost, can be applied to various automation occasions, requires less modification to the original equipment, and outputs a large amount of information, so as to solve the above-mentioned shortcomings.
[0079] In one embodiment, Figure 1 As shown, a method for detecting the rotation axis posture based on vision is provided. This embodiment takes the method applied to a terminal as an example. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0080] Step 102: Acquire an image group obtained by capturing the tooling components of the target shaft with a binocular camera.
[0081] Among them, Figure 1 As shown, the tooling component is a ring-shaped component with different colors sprayed on the outer ring. The tooling component can be sleeved on the target shaft, and the inner ring of the tooling component is assembled and fitted with the target shaft, and the tooling component can rotate with the target shaft. Figure 2 is a schematic diagram of the tooling components, such as Figure 3 and Figure 4 As shown, the binocular camera can be mounted at a position horizontally aligned with the tooling components according to site restrictions and requirements.
[0082] Specifically, the terminal first uses Zhang's calibration method to perform internal reference calibration on the binocular camera, and then uses the stereo correction algorithm to align the horizontal pixels of the two cameras. The terminal uses the calibrated binocular camera to shoot the tooling parts assembled on the target shaft. The binocular camera can obtain an image group for one shot. An image group contains two images captured by the binocular camera, and the acquisition time of these two images is the same. The terminal can take multiple shots with the binocular camera to obtain multiple image groups, so as to calculate the position information of the target shaft according to each image group.
[0083] Furthermore, the binocular camera is stably fixed at the installation location and the focal length is adjusted. The terminal uses a grid paper with an internal number of 11×9 to shoot the tooling parts at different angles, and the grid paper is stereo-calibrated through the stereoCalibrate function in opencv based on python3.6 to obtain the distortion matrix and the internal parameter matrix, rotation matrix, translation matrix, intrinsic matrix and basic matrix between the two cameras in the binocular camera. The obtained distortion matrix and the internal parameter matrix, rotation matrix, translation matrix, intrinsic matrix and basic matrix are stereo-rectified using the stereoRectify function of opencv to obtain the mapping matrix of the two cameras, and the mapping matrix parameters are input into the sampling program to obtain the field of view of the binocular camera after correction. The tooling parts are shot with the calibrated binocular camera, and the average displacement deviation of the corner points on the calibration plate is calculated by the external parameter matrix of the captured image; the error is used to weigh the calibration effect, and the smaller the error, the more accurate the calibration. When the average displacement deviation is less than 0.13, the calibration process ends and the calibrated binocular camera is obtained.
[0084] Step 104 , according to a preset image recognition strategy, identify the tooling component color blocks in each image included in the image group, and mark the identified tooling component color blocks respectively to obtain a calibration image corresponding to each image.
[0085] Specifically, the terminal converts two images in the image group into the hexagonal cone model space, performs color recognition on each image in the hexagonal cone model space, and marks different color blocks in the tooling parts obtained by color recognition with unique identifiers to obtain a calibration image corresponding to each image.
[0086] Step 106: for each calibration image, identify the position of the segmentation line between the color blocks in the calibration image.
[0087] Specifically, for each calibration image, the terminal detects the dividing line between different color blocks in each calibration image by using a preset dividing line detection algorithm, obtains the horizontal coordinate of the dividing line, and uses the horizontal coordinate of the dividing line as the dividing line position.
[0088] Step 108, calculating the position information of the target rotation axis according to the position of the dividing line between the color blocks.
[0089] Specifically, the terminal calculates the position information of the target rotating axis according to the position of the dividing line between the color blocks, the pre-stored order of the different color blocks in the tooling component, and the angle of each color block to the center of the circle.
[0090] In the above-mentioned vision-based shaft posture detection method, an image group is obtained by acquiring a binocular camera to capture the tooling components of the target shaft, and the images contained in the image group are collected at the same time; according to a preset image recognition strategy, the color blocks of the tooling components in each image contained in the image group are identified, and the identified tooling component color blocks are respectively marked to obtain a calibration image corresponding to each image; for each calibration image, the position of the dividing line between each color block is identified in the calibration image; according to the position of the dividing line between each color block, the posture information of the target shaft is calculated. This method obtains an image group captured by a binocular camera on the tooling components on the target shaft, identifies the position information of different color blocks of the tooling components in the image group, and calculates the posture information of the shaft according to the position information of different color blocks. It is a shaft posture test method with low cost and applicable to various automation scenarios, and can also improve the accuracy of shaft posture information measurement.
[0091] In an optional embodiment, the position information of the target rotation axis is calculated according to the position of the dividing line between each color block, including: in each calibration image, determining the position of the dividing line between each matching color block as a target position pair; calculating the depth value between the tooling component and the binocular camera according to the target position pair; calculating the center coordinates of the circle according to the depth value; calculating the angle values of the target position pairs in pairs to obtain multiple angle values, clustering the multiple angle values, and selecting the target position pairs corresponding to the angle values in the angle distribution area with the largest density to calculate the radius value of the target rotation axis; calculating the radius residual value according to the radius value and the standard radius value of the target rotation axis, and discarding the target position pairs corresponding to the radius residual values greater than a preset residual threshold; averaging the angle values calculated according to the remaining target position pairs to obtain the rotation angle of the target rotation axis; averaging the center coordinates calculated according to the remaining target position pairs to obtain the coordinates of the target rotation axis.
[0092] The position information of the target rotation axis at least includes the coordinates and rotation angle of the target rotation axis.
[0093] Specifically, for each calibration image, Hough transform is used to detect the upper and lower boundaries and vertical lines (i.e., dividing lines) of the tooling parts, and the dividing lines corresponding to the same position of the tooling parts in the two calibration images are used as the dividing lines between the matching color blocks, and the horizontal coordinates of the two matching dividing lines constitute a target position pair. Based on the above process, multiple target position pairs can be obtained. As shown in Figures 11(a) and (b), [2,3], [4,5], [5,5], [6,6], [7,7], [8,8], and [9,9] are the 7 matching target position pairs, among which [5,5] indicates that the dividing line No. 5 in Figure 11(a) and the dividing line No. 5 in Figure 11(b) are both the dividing lines between the purple block and the red block in the tooling parts, so [5,5] is taken as a target position pair.
[0094] Input the horizontal coordinates of the target position pair into the pre-established depth calculation function, and calculate the depth value between the target position pair and the binocular camera according to the binocular imaging law. The depth calculation function is as follows:
[0095]
[0096] disp i =|x i left -x i right |
[0097] Where f is the calibrated camera focal length, T x is the calibrated distance between the optical centers of the two cameras, and disp is the parallax. i left is the horizontal coordinate of the segmentation line in the calibration image collected by the left eye at the target position, x i right is the horizontal coordinate of the segmentation line in the calibration image collected by the right eye at the target position, y i is the depth value between the target position pair and the binocular camera. The root mean square error is used to fit the center of the tooling part and calculate the radius. The regression objective function used is:
[0098]
[0099]
[0100] R is the known radius information, and the center coordinates (x c ,y c ), x i is the horizontal coordinate of the i-th target position pair, y i is the depth value of the i-th target position pair.
[0101] Randomly select two target position pairs from the target position pairs, combine them in pairs, input the horizontal coordinates of the two target position pairs in each combination into the angle calculation function, and calculate the angle value. Assume that there are m groups of target position pairs, and the two combinations are obtained combinations. Since the radius and center direction of the tooling are known, each combination can use the angle calculation formula in step 13 to calculate an angle, and finally get Angle value, angle calculation diagram Fig.12 shown.
[0102] The angle calculation function is as follows:
[0103]
[0104] Among them, Order is the sequence number of the known color block in the tooling. The sequence number of the color block can be determined according to the target position pair. Unit is the angle of each color block to the center of the circle. The angle value calculated by the target position pair of each combination can be obtained by calculation. center is the horizontal coordinate of the center of the circle, x i is the horizontal coordinate of the target position pair, radius is the radius of the known tooling component, array i is the sequence number of the target position pair, array radius The calculated radius value for the target position pair.
[0105] Will The DBSCAN clustering method is used to select the angle distribution area with the highest density, and the target position pair in the angle distribution area with the highest density is used as the correctly matched target position pair. The correctly matched target position pair is input into the regression objective function to calculate the radius value, and the multiple radius values obtained are subtracted from the known standard target value to obtain the radius residual value of the target position pair. The error point discarding algorithm is used to remove the error points. The error point discarding algorithm is as follows:
[0106]
[0107] Among them, the radius values calculated for multiple target positions constitute an estimated radius vector, and correspondingly, the radius residual values constitute a radius residual vector, and k is the number of radius values or residual radius values in the vector.
[0108] As shown in Figure 11(a) and (b), [2,3], [4,5], [5,5], [6,6], [7,7], [8,8], and [9,9] are the seven matched target position pairs. The angle distribution area with the highest density obtained by the DBSCAN clustering method contains the angle values calculated for the five target position pairs [5,5], [6,6], [7,7], [8,8], and [9,9]. The angle values calculated for the two target position pairs [2,3] and [4,5] are outliers. These two target position pairs are incorrectly matched and need to be discarded.
[0109] The angle values calculated are averaged according to the target position after the error is removed to obtain the rotation angle of the target axis. The coordinates of the target axis are averaged according to the target position after the error is removed to obtain the coordinates of the target axis. The Euler angle can also be calculated based on the coordinates of the target axis and the rotation angle.
[0110] In this embodiment, the matching target position pairs are determined by the color difference function, the target position pairs to be mismatched are removed by clustering, and finally the rotation angle and coordinates of the target rotation axis are calculated based on the remaining target position pairs to remove the influence of mismatches and single target position pairs, so that the calculated target rotation axis posture information is more accurate.
[0111] In an optional embodiment, in each calibration image, the dividing line position between the matching color blocks is determined as a target position pair, including: when the color difference of the color blocks on both sides of the different dividing line positions identified by each calibration image is less than a preset difference threshold, the target position pair is obtained.
[0112] Specifically, the coordinates of the center line that horizontally passes through the color block of the tooling component are calculated based on the upper and lower boundaries of the tooling component detected in the calibration image. Fig.10 As shown, a difference detection window with a size of W×L is established around the center line, W is less than the distance h between the upper and lower boundaries, and L is greater than the horizontal width of a color block in the tooling component. The difference detection window is moved simultaneously between different color blocks in the two calibration images, and the color difference between the two color blocks where the difference detection window is located in the two calibration images is detected according to the color difference function. When the color difference is less than the preset difference threshold, the target position pair describing the middle of the two color blocks at the same position in the two calibration images is obtained.
[0113] The color difference function is as follows:
[0114]
[0115] Where i is the normalized hue value of the color block identified in the calibration image, which is used to represent the type of color block; left and right under the second sum sign refer to the two color blocks in the difference detection window, the left color block is left, and the right color block is right. Since the horizontal lines of the visual field after correction have been aligned, the normalized hue values of the color blocks on both sides of the two calibration images collected by the left and right eyes on the same horizontal line are subtracted with the dividing line as the boundary, and then the subtraction result is divided by the total number of pixels to obtain the color difference between the two calibration images on the left and right sides of the dividing line. When the color difference is less than the preset difference threshold, the target position pair between the two color blocks corresponding to the same position of the tooling component in the two calibration images is obtained, and the determined target position pair is recorded.
[0116] In an optional embodiment, the identified color blocks of the tooling components are marked respectively to obtain a calibration image corresponding to each image, including: identifying the hue value corresponding to the color block of the tooling components in each image included in the image group in the hexagonal pyramid model space according to the hue range corresponding to different color blocks in the tooling components collected in advance; marking the hue value of the identified color block of the tooling components according to the standardized hue value to obtain a calibration image corresponding to each image.
[0117] Among them, the pre-collected hue range corresponding to different color blocks in the tooling parts is obtained by the terminal collecting the hue range of all color blocks in the tooling parts in the hexagonal cone model space during the preprocessing stage, and the hue value range corresponding to different color blocks on the tooling parts is obtained and stored in the terminal memory.
[0118] Specifically, when the terminal obtains an image group captured by a binocular camera, firstly, two images in an image group are converted into a hexagonal cone model space, and each pixel in each image is marked with a hue value, and then different color blocks in each image are identified according to the hue value range corresponding to different color blocks on the tooling parts stored in advance, and the hue values of the identified different color blocks are normalized according to the standardized hue values, and the images after normalization are converted into RGB space to obtain the calibration image corresponding to each image. The standardized hue value of each color block can be the average value of the hue value range of the color block, or it can be the identifier corresponding to the color block specified manually.
[0119] For example, the hue value range corresponding to the blue color block on the pre-collected tooling component is [120-130]. Figure 5This is a schematic diagram of an image in the image group captured by the binocular camera. After the terminal marks the hue value of the pixels in each image, the pixels with hue values in the range of [120-130] are used as blue blocks, and all hue values in the blue blocks are marked with 125. Other blocks are processed similarly. After processing, the image is converted to RGB space, as shown in Figure 6 As shown, the calibration image corresponding to each image is obtained.
[0120] In this embodiment, by performing color segmentation on the original image in the image group taken by the binocular camera and marking different color blocks with standardized tone values, a calibration image is obtained, and the contrast between different color blocks in the calibration image is enhanced, which can further improve the accuracy of processing.
[0121] In an optional embodiment, for each calibration image, the position of the dividing line between each color block is identified in the calibration image, including: extracting edge features of the calibration image to obtain an edge image; detecting the upper and lower boundaries of the tooling component in the edge image; extracting the image between the upper and lower boundaries of the tooling component to obtain a cropped image; and detecting the dividing lines between each color block in the cropped image through a preset dividing line detection algorithm to obtain the position of the dividing lines between each color block.
[0122] Specifically, grayscale processing is performed on each calibration image, and the obtained image is as follows: Figure 7 As shown; then use the convolution kernel Convolve the grayscale image to extract the edge features of the calibration image and obtain the edge image. Figure 8 As shown, the edge image obtained after convolution is a binary image.
[0123] The edge image is passed into the Hough transform, and the horizontal lines in the edge image are detected according to the detection threshold obtained from debugging experience. The two farthest horizontal lines in the edge image are used as the upper and lower boundaries of the tooling parts. Since the binocular camera is focused before the tooling parts are installed, the noisy background will be basically removed in the above operation, so the impact of the background on this step is not considered here.
[0124] After obtaining the upper and lower boundaries of the tooling component, an image between the upper and lower boundaries of the tooling component is extracted to obtain a cropped image, and the distance h between the upper and lower boundaries is recorded.
[0125] The cropped image is subjected to Hough transform again to detect vertical lines. The length detection threshold of the vertical line is α·h, where α is the set ratio. The larger the ratio, the more difficult it is to detect the straight line, and the smaller the ratio, the easier it is to detect the straight line, but an inaccurate straight line may be obtained. The α used in the test is 0.5; the angle detection threshold is set to 2°, indicating that the straight lines detected within the deflection range of ±1° are considered to be vertical lines. The horizontal coordinates of each family of detected vertical lines are calculated as the position of the dividing line. The calculation formula is: x=rcosθ, r is the polar diameter detected by the Hough transform, and θ is the polar angle detected by the Hough transform. The straight lines with a horizontal coordinate difference of 30 pixels are considered to be the same straight line. The specific horizontal coordinates of the straight line are obtained by averaging and the two sets of dividing line positions in the two cropped images are recorded respectively.
[0126] In an optional embodiment, after extracting the edge features of the calibration image and obtaining the edge image, the method further includes: filling the discontinuous areas in the edge image to obtain a complete edge image; calculating the area of each closed contour in the complete edge image, and eliminating the contours whose closed contour area is less than a preset area threshold; performing polygon fitting on the eliminated complete edge image, extracting the contours whose fitted area is greater than the preset area threshold, and obtaining the target image. Accordingly, the step of detecting the upper and lower boundaries of the tooling parts in the edge image specifically includes: detecting the upper and lower boundaries of the tooling parts in the target image.
[0127] Specifically, a morphological closing operation is performed on each edge image, that is, the edge image is first expanded and then eroded, which can effectively fill the small space on the boundary of the edge image, making the edge more continuous and full, and the image after filling is used as a complete edge image.
[0128] Use the findContours function of opencv to obtain the contour parameters of the complete edge image under the setting parameters of RETR_TREE and CHAIN_APPROX_NONE. Use contourArea to calculate the area of each closed contour in the complete edge image, and remove the contours whose area is less than the preset area threshold. The threshold used in the test is 100. Use the approxPolyDP function to perform polygon fitting on the remaining contours. After fitting, draw the contours whose area is greater than the preset area threshold to obtain the target image. Then, based on the target image, detect the upper and lower boundaries of the tooling parts and detect the dividing line to obtain the position of the dividing line between each color block.
[0129] like Fig. 9 As shown, for Figure 8 The target image obtained after morphological closing operation and contour processing, Fig. 9The edges of different color blocks in the tooling parts are complete, which can remove the influence of other noise in the image.
[0130] In an optional embodiment, the method also includes: obtaining the position and posture information of the target rotation axis calculated by multiple image groups; selecting the angle value within a preset error range from the multiple angle values in the obtained position and posture information of the multiple target rotation axes, and when the number of angle values within the preset error range reaches a preset number, calculating the average value of the angle values within the preset error range and the corresponding average value of the rotation axis coordinates to obtain the final angle value and final rotation axis coordinate value of the target rotation axis.
[0131] Specifically, the terminal takes multiple shots through a binocular camera to obtain multiple image groups, calculates the position and posture information of the target rotation axis for each image group, and selects multiple rotation angles in the multiple groups of target rotation axis posture information through a random mean error interior point algorithm. The angle values are within a preset error range as interior points. When the number of interior points reaches a preset number, the angle average of the multiple interior points is calculated as the final rotation angle of the target rotation axis, and the axis coordinate average of the multiple interior points is calculated as the final axis coordinate value.
[0132] The random average error interior point algorithm is as follows:
[0133]
[0134]
[0135] In this embodiment, the angle value with high confidence is selected by the random error interior point algorithm, so that the precision and accuracy of the rotation angle calculation of the target shaft can be improved. This method can adapt to various harsh occasions in a low-cost manner without changing the internal structure of the device, and measure the coordinates and rotation angle of the target shaft.
[0136] In order to facilitate understanding of the technical solutions provided in the embodiments of the present application, Fig.13 As shown, the vision-based rotation shaft posture detection method provided in the embodiment of the present application is briefly described with a complete vision-based rotation shaft posture detection process:
[0137] (1) Obtain a group of images captured by a binocular camera on the tooling components of the target shaft.
[0138] (2) according to the tonal ranges corresponding to different color blocks in the tooling components collected in advance, identifying the tonal value corresponding to the color block of the tooling components in each image included in the image group in the hexagonal pyramid model space;
[0139] The hue values of the identified color blocks of the tooling parts are marked according to the standardized hue values to obtain a calibration image corresponding to each image.
[0140] (3) Extract the edge features of the calibration image and obtain the edge image.
[0141] (4) Filling the discontinuous areas in the edge image to obtain a complete edge image;
[0142] Calculate the area of each closed contour in the complete edge image, and remove the contours whose area is less than the preset area threshold;
[0143] Perform polygon fitting on the complete edge image after elimination, extract the contour whose area after fitting is larger than the preset area threshold, and obtain the target image;
[0144] Detect the upper and lower boundaries of the tooling part in the target image.
[0145] (5) extracting the image between the upper boundary and the lower boundary of the tooling component to obtain a cropped image;
[0146] Using a preset segmentation line detection algorithm, the segmentation lines between the color blocks in the cropped image are detected to obtain the segmentation line positions between the color blocks;
[0147] When the color difference of the color blocks on both sides of the different segmentation line positions identified in each cropped image is less than a preset difference threshold, a target position pair is obtained.
[0148] (6) Calculate the depth value between the tooling component and the binocular camera based on the target position pair;
[0149] Calculate the center coordinates of the circle according to the depth value;
[0150] The target position pairs are combined in pairs to calculate angle values to obtain multiple angle values, the multiple angle values are clustered, and the target position pairs corresponding to the angle values in the angle distribution area with the largest density are selected to calculate the radius value of the target rotation axis.
[0151] (7) calculating a radius residual value according to the radius value and a standard radius value of the target rotation axis, and discarding a target position pair corresponding to a radius residual value greater than a preset residual threshold;
[0152] The calculated angle values are averaged according to the remaining target positions to obtain the rotation angle of the target shaft;
[0153] The calculated center coordinates are averaged according to the remaining target positions to obtain the coordinates of the target rotation axis.
[0154] (8) obtaining the position and posture information of the target rotation axis calculated through multiple image groups;
[0155] Among the multiple angle values in the obtained position and posture information of the multiple target rotating shafts, the angle value within the preset error range is selected. When the number of angle values within the preset error range reaches the preset number, the average value of the angle values within the preset error range and the corresponding average value of the rotating shaft coordinates are calculated to obtain the final angle value and the final rotating shaft coordinate value of the target rotating shaft. The final angle value and the final rotating shaft coordinate value of the target rotating shaft are displayed on the control panel of the terminal. The control panel of the terminal is also used to input all thresholds involved in the visual-based rotating shaft position and posture detection process.
[0156] Finally, the effect of the rotation axis posture detection method based on vision proposed in this application is verified. In order to verify the effectiveness of the rotation axis posture detection method based on vision proposed in this application, a simulation experiment was carried out using two Basler ace-acA2440-35uc industrial cameras with a ZT505SW01 precision three-dimensional electric rotation stage as a control. The parameters are as follows:
[0157] The hardware installation parameters are: the distance between the optical centers of the two cameras is about 28.5cm, the angle is about 30°, the center of the tooling circle is about 0.9m from the baseline of the binocular camera, the radius of the tooling edge from the center of the circle is 66mm, and the coloring surface of the tooling is 16 equally divided planes. Green, red, purple, yellow and blue are used to color each surface of the tooling in different combinations.
[0158] The parameters in the feedback algorithm are: the contour parameter threshold is 100 pixels, the horizontal line extraction threshold is 120 pixels, the vertical line extraction threshold is 0.5, the circle center coordinate floating threshold is 0.001, the color matching threshold is 0.3, the number of sampling group images is set to 8 / group, std is set to 0.01 in algorithm 1, d is set to 2 in algorithm 2, iters is set to 100, and batch is set to 2.
[0159] This method was used to measure different angles of the electric rotary table output in fixed-axis rotation mode as a control to obtain comparative verification results. Fig.14 is the calculated floating value of the center coordinate, in millimeters (mm). It can be seen that the coordinate distribution is relatively concentrated; Fig.15 is the residual value of the rotation angle. It can be seen that at a distance of 0.9m, this method can basically make the rotation angle error within 1°, and the error of any point on the axis within 1.15mm.
[0160] Environmental adaptability analysis: The method proposed in the present invention uses a binocular camera to collect images. This acquisition method is inexpensive and will not be limited by the original mechanical design inside the shaft. It uses an external detection method. Reasonable design of the camera protection box can make the camera work in various high-risk scenarios; reasonable material selection of tooling can also make the tooling work for a longer time. Therefore, this method has strong adaptability to the environment and has a relatively broad application prospect in some non-precision instruments and equipment that do not require particularly high precision.
[0161] In summary, the method of detecting the rotation axis posture based on the color ring tooling and vision proposed in the present invention is highly applicable to the problem of detecting the axis center coordinates and rotation angles of the rotation axis where it is inconvenient to perform internal mechanical modification.
[0162] It should be understood that although Figure 1 , Fig.13 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 , Fig.13 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0163] In one embodiment, Fig.16 As shown, a rotation axis posture detection device based on vision is provided, including: an acquisition module 1602, a marking module 1604, a recognition module 1606 and a calculation module 1608, wherein:
[0164] The acquisition module 1602 is used to acquire an image group obtained by capturing the tooling component of the target shaft with a binocular camera, where the images contained in the image group are captured at the same time.
[0165] The marking module 1604 is used to identify the tooling component color blocks in each image included in the image group according to a preset image recognition strategy, and mark the identified tooling component color blocks respectively to obtain a calibration image corresponding to each image.
[0166] The identification module 1606 is used to identify the position of the segmentation line between each color block in each calibration image.
[0167] The calculation module 1608 is used to calculate the position information of the target rotation axis according to the position of the dividing line between each color block.
[0168] In one embodiment, the pose information of the target rotation axis includes at least the coordinates and rotation angle of the target rotation axis; the calculation module 1608 is also used to determine the dividing line position between the matching color blocks in each calibration image as a target position pair; and calculate the depth value between the tooling component and the binocular camera based on the target position pair; and calculate the center coordinates of the circle based on the depth value; and calculate the angle values of the target position pairs in pairs to obtain multiple angle values, cluster the multiple angle values, and select the target position pairs corresponding to the angle values in the angle distribution area with the largest density to calculate the radius value of the target rotation axis; and calculate the radius residual value based on the radius value and the standard radius value of the target rotation axis, and discard the target position pairs corresponding to the radius residual values greater than the preset residual threshold; and average the angle values calculated based on the remaining target position pairs to obtain the rotation angle of the target rotation axis; and average the center coordinates calculated based on the remaining target position pairs to obtain the coordinates of the target rotation axis.
[0169] In one embodiment, the calculation module 1608 is further configured to obtain a target position pair when the color difference between the color blocks on both sides of different segmentation line positions identified in each calibration image is less than a preset difference threshold.
[0170] In one embodiment, the marking module 1604 is also used to identify the hue value corresponding to the tooling component color block in each image included in the image group in the hexagonal pyramid model space according to the hue range corresponding to different color blocks in the tooling component collected in advance; and mark the hue value of the identified tooling component color block according to the standardized hue value to obtain a calibration image corresponding to each image.
[0171] In one embodiment, the recognition module 1606 is also used to extract edge features of the calibration image to obtain an edge image; and detect the upper and lower boundaries of the tooling parts in the edge image; and extract the image between the upper and lower boundaries of the tooling parts to obtain a cropped image; and detect the dividing lines between the color blocks in the cropped image through a preset dividing line detection algorithm to obtain the dividing line positions between the color blocks.
[0172] In one embodiment, the recognition module 1606 is also used to fill in discontinuous areas in the edge image to obtain a complete edge image; and calculate the area of each closed contour in the complete edge image, and eliminate the contours whose area is less than a preset area threshold; and perform polygon fitting on the complete edge image after elimination, and extract the contours whose area after fitting is greater than the preset area threshold to obtain a target image; and detect the upper and lower boundaries of the tooling parts in the target image.
[0173] In one embodiment, the calculation module 1608 is also used to obtain the posture information of the target rotation axis obtained by calculating multiple image groups; and select the angle value within a preset error range from the multiple angle values in the posture information of the multiple target rotation axes obtained. When the number of angle values within the preset error range reaches a preset number, the average value of the angle values within the preset error range and the corresponding average value of the rotation axis coordinates are calculated to obtain the final angle value and final rotation axis coordinate value of the target rotation axis.
[0174] For the specific definition of the vision-based shaft posture detection device, please refer to the definition of the vision-based shaft posture detection method above, which will not be repeated here. Each module in the above-mentioned vision-based shaft posture detection device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0175] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.17 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for detecting the position and posture of the rotating shaft based on vision is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0176] Those skilled in the art will understand that Fig.17 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0177] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0178] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0179] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0180] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0181] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for detecting the rotation axis posture based on vision, characterized in that: The method comprises: Acquire an image group obtained by capturing a tooling component of a target rotating shaft with a binocular camera, wherein the images contained in the image group are captured at the same time, the tooling component is in a ring shape, and has components of different colors sprayed on the outer ring, the tooling component is sleeved on the target rotating shaft, the tooling component rotates with the target rotating shaft, and the binocular camera is mounted at a position horizontally aligned with the tooling component; According to a preset image recognition strategy, a tooling component color block in each image included in the image group is identified, and the identified tooling component color blocks are respectively marked to obtain a calibration image corresponding to each image; For each calibration image, identifying the position of the dividing line between the color blocks in the calibration image; According to the positions of the dividing lines between the color blocks, the position information of the target rotation axis is calculated.
2. The method according to claim 1, characterized in that The position information of the target rotation axis at least includes the coordinates and rotation angle of the target rotation axis; The step of calculating the position information of the target rotation axis according to the position of the dividing line between the color blocks includes: In each of the calibration images, determining the position of the segmentation line between the matched color blocks as a target position pair; Calculating a depth value between the tooling component and the binocular camera according to the target position pair; Calculate the coordinates of the center of the circle according to the depth value; Calculate angle values of the target position pairs in pairs to obtain multiple angle values, cluster the multiple angle values, and select the target position pairs corresponding to the angle values in the angle distribution area with the largest density to calculate the radius value of the target rotation axis; Calculating a radius residual value according to the radius value and a standard radius value of the target rotation axis, and discarding a target position pair corresponding to a radius residual value greater than a preset residual threshold; averaging the calculated angle values according to the remaining target positions to obtain the rotation angle of the target shaft; The calculated circle center coordinates are averaged according to the remaining target positions to obtain the coordinates of the target rotation axis.
3. The method according to claim 2, characterized in that The step of determining the position of the segmentation line between the matched color blocks in each of the calibration images as a target position pair includes: When the color difference of the color blocks on both sides of the different segmentation line positions identified by each of the calibration images is less than a preset difference threshold, a target position pair is obtained.
4. The method according to claim 1, characterized in that: The step of marking the identified color blocks of the tooling components to obtain a calibration image corresponding to each image includes: According to the pre-collected hue ranges corresponding to different color blocks in the tooling components, identifying the hue value corresponding to the color block of the tooling component in each image included in the image group in the hexagonal pyramid model space; The hue values of the identified color blocks of the tooling parts are marked according to the standardized hue values to obtain a calibration image corresponding to each image.
5. The method according to claim 1, characterized in that For each calibration image, identifying the position of the dividing line between the color blocks in the calibration image includes: Extracting edge features of the calibration image to obtain an edge image; Detecting the upper boundary and the lower boundary of the tooling component in the edge image; Extracting an image between the upper boundary and the lower boundary of the tooling component to obtain a cropped image; The dividing lines between the color blocks in the cropped image are detected by a preset dividing line detection algorithm to obtain the dividing line positions between the color blocks.
6. The method according to claim 5, characterized in that After extracting the edge features of the calibration image to obtain the edge image, the method further includes: Filling discontinuous areas in the edge image to obtain a complete edge image; Calculating the area of each closed contour in the complete edge image, and removing the contours whose area is smaller than a preset area threshold; Perform polygon fitting on the complete edge image after elimination, extract the contour whose area after fitting is larger than the preset area threshold, and obtain the target image; The detecting the upper boundary and the lower boundary of the tooling component in the edge image includes: An upper boundary and a lower boundary of the tooling component in the target image are detected.
7. The method according to claim 2, characterized in that: The method further comprises: Acquire the position and posture information of the target rotation axis calculated through multiple image groups; Among the multiple angle values obtained in the posture information of the multiple target rotation axes, select the angle value within the preset error range. When the number of angle values within the preset error range reaches a preset number, calculate the average value of the angle values within the preset error range and the corresponding average value of the rotation axis coordinates to obtain the final angle value and final rotation axis coordinate value of the target rotation axis.
8. A rotation axis posture detection device based on vision, characterized in that: The device comprises: An acquisition module is used to acquire an image group obtained by a binocular camera from a tooling component of a target rotating shaft, wherein the images contained in the image group are acquired at the same time, the tooling component is in a ring shape, and has components of different colors sprayed on the outer ring, the tooling component is sleeved on the target rotating shaft, the tooling component rotates with the target rotating shaft, and the binocular camera is mounted at a position horizontally aligned with the tooling component; A marking module, used for identifying the tooling component color blocks in each image included in the image group according to a preset image recognition strategy, and marking the identified tooling component color blocks respectively to obtain a calibration image corresponding to each image; A recognition module, for identifying, for each calibration image, the positions of the dividing lines between the color blocks in the calibration image; The calculation module is used to calculate the position information of the target rotation axis according to the position of the dividing line between each color block.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Numerical control machine tool rotating shaft error detection method based on binocular vision
CN105043259A
Pose identifying and grabbing device and method based on binocular vision
CN110509281A
Soft magnet posture recognition and automatic grabbing method based on binocular vision
CN112132889A
Position-attitude detecting method and device thereof and flexible production system
JP1995237158A
Method for extracting pallet image using color information, and rack or pallet loading condition recognition module using vision recognition for automatic guided vehicle
KR1020170092734A
