Workpiece precision measurement method based on binocular structured light
Through binocular structured light technology, the Harris algorithm and Gray code phase shift method are used to solve the problem of measurement errors of binocular cameras in industrial measurement, achieve high-precision three-dimensional measurement of workpieces, improve detection efficiency and accuracy, and are suitable for automation detection.
Patent Information
- Application Number
- CN202410717155.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-10-01
AI Technical Summary
Existing consumer-grade binocular cameras do not consider factors such as lighting conditions, imaging resolution, and target characteristics during industrial measurement, resulting in measurement errors and inability to achieve accurate three-dimensional measurements.
Using binocular structured light technology, by installing a binocular visible light camera, the Harris algorithm is used to optimize corner point extraction, and the Gray code and phase shift methods are combined to obtain absolute phase information, generate a disparity map, construct a three-dimensional point cloud, and perform denoising and smoothing processing. Achieve precise measurement of workpieces.
It improves detection efficiency and accuracy, reduces manual operations, achieves 24-hour uninterrupted work, significantly improves production efficiency and product quality, avoids mismatching problems, enhances the robustness and accuracy of the detection system, and is suitable for high-precision full-scale inspection. Automatic detection.
Smart Images

Figure CN118729988A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of workpiece size measurement, and in particular to a workpiece precision measurement method based on binocular structured light. Background Art
[0002] In modern industrial production, industrial measurement is an extremely important task. Whether it is manufacturing, processing, assembly, inspection or maintenance, it is necessary to rely on various measurement tools to obtain accurate data to ensure the quality of products and the normal operation of production equipment. Whether the industrial measurement is accurate directly affects the quality and performance of the product. Any small deviation may cause product failure or weakened performance. Therefore, the importance of industrial measurement is self-evident. It is an indispensable part of ensuring high quality and high performance of products.
[0003] There are three main methods commonly used in industrial measurement: monocular detection, binocular detection, and laser detection. However, although consumer-grade binocular cameras on the market can perform binocular imaging or obtain scene depth, they do not consider the errors caused by many factors such as lighting conditions, imaging resolution, and target features, and cannot be directly used for three-dimensional precise measurement of specified targets. In order to improve the accuracy of measurement, the present invention chooses to use binocular structured light to solve the above problems.
[0004] With the development of artificial intelligence related technologies, binocular vision image acquisition and processing technology in the field of computer vision has broad application prospects in the fields of industrial precision parameter detection, three-dimensional measurement and virtual reality. By analyzing the binocular imaging characteristics of various targets, studying structured light projection, binocular image alignment, significant area detection, stereo matching and measurement, etc., we can solve the core technical problems related to precision measurement of targets in industrial measurement. Summary of the invention
[0005] The purpose of the present invention is to provide a workpiece precision measurement method based on binocular structured light in order to solve the above-mentioned problem.
[0006] The technical solution adopted by the present invention is as follows: a workpiece precision measurement method based on binocular structured light, characterized in that it includes the following steps:
[0007] Step 1: Install the binocular visible light camera and calibrate it using a high-precision small calibration plate. During this process, the Harris algorithm is used to optimize the extraction of corner points to improve the calibration accuracy, thereby determining the position relationship of the right camera relative to the left camera.
[0008] Step 2: Project the encoded structured light pattern on the workpiece surface and capture the left and right camera views; align the image lines of the left and right views through the Bouguet epipolar correction method, and use saliency detection and edge detection techniques to exclude background elements in the view;
[0009] Step 3: Combine Gray code and phase shift measurement to obtain the absolute phase information of the workpiece, then accurately match the absolute phase to achieve stereo matching of the image, optimize the efficiency of phase matching through epipolar correction, and generate a disparity map based on this;
[0010] Step 4: Build a 3D point cloud based on the disparity map, perform denoising and smoothing on the initial point cloud data of the workpiece, and remove redundant point clouds to reconstruct the 3D model and optimize the dimensional accuracy of the workpiece, and finally obtain the shape and precise size of the workpiece.
[0011] In a preferred embodiment, the binocular camera used in the method is configured with two cameras, the two cameras of the binocular camera are installed to remain within a fixed distance, and their positions and angles are pre-calibrated during installation; the binocular image is calibrated and corrected to generate a disparity map for measurement.
[0012] In a preferred embodiment, the combination of structured light 3D measurement technology and binocular imaging technology achieves improved measurement accuracy during feature point search.
[0013] In a preferred embodiment, the Harris corner detection algorithm is used to accurately extract corner points during the calibration process, thereby improving the accuracy of binocular camera calibration;
[0014] Harris corner detection calculates the eigenvalues μ1 and μ2 of the Harris response matrix M matrix for each pixel in the image, defines a corner response function R(x, y) about the eigenvalues, and sets a reasonable threshold F. If the corner response function R(x, y)>F, the detection result is that there is a corner at the pixel.
[0015] The M matrix is represented as:
[0016]
[0017] In formula (1), X and Y are the first-order grayscale gradients of pixels in the image, and w is the processed Gaussian smoothing window; R(x, y) is expressed as:
[0018] R(x,y)=Det(M)-kTr 2 (M) = μ1μ2-k(μ1+μ2) 2 =AB-C 2 -k(A+B) 2 (2)
[0019] In formula (2), Tr(M) represents the trace of matrix M, and Det(M) represents the determinant value of matrix M;
[0020] Combining the transformation relationship of the four coordinate systems, the transformation relationship from three-dimensional spatial coordinates to two-dimensional coordinates is:
[0021]
[0022] In formula (3), M1 is the camera internal parameter and f x 、f y , u0, v0 are related to the internal parameters of the camera; M2 is the camera external parameter, which represents the conversion relationship from the world coordinate system to the camera coordinate system, and is the position and posture matrix of the camera in the world coordinate system;
[0023] During the calibration process, the position of the calibration plate is constantly changed, and multiple sets of images of the left and right camera calibration plates are collected. Based on the Harris algorithm, the gradient components I of each pixel in the image in the horizontal and vertical directions are first calculated. x ,I y ,I x I y , get the M matrix, in order to suppress the noise in the image and enhance the robustness of corner detection, the image is Gaussian smoothed, then, according to the core idea of Harris algorithm, the corner response function R value corresponding to each pixel on the original image is calculated; by setting a reasonable threshold F, the corner information in the image is detected and the corner coordinates in the image are extracted;
[0024] By using the MATLAB calibration toolbox, the captured images and the detected corner point coordinates are added to the calibration object, and the left and right cameras are calibrated respectively. After the calibration is completed, the intrinsic parameter matrices of the left and right cameras and the rotation matrices R1, R2 and translation matrices T1, T2 of the left and right cameras are obtained;
[0025] The camera's intrinsic parameter matrix K is:
[0026]
[0027] In formula (4), c is a constant, f x and f y Indicates the position of the focal length in the u-axis and v-axis directions, and u0 and v0 represent the coordinates of the center of the camera's photosensitive plate in the pixel coordinate system;
[0028] Then, the binocular camera is jointly calibrated to establish the relationship between the camera image pixel position and the object space position, and the rotation matrix and translation vector of the binocular camera are obtained;
[0029]
[0030] In formula (5), R1 and R2 are the rotation matrices of the left and right cameras, respectively. T1 and T2 are the translation matrices of the left and right cameras, respectively. R and T represent the rotation matrix and translation vector between the two camera coordinate systems, respectively. R is the rotation angle required for the left camera to rotate from one to the right camera coordinate system, and T is the translation vector required to move from the origin of one camera coordinate system to the origin of another camera coordinate system.
[0031] In a preferred embodiment,
[0032] In a preferred embodiment,
[0033] In a preferred embodiment,
[0034] In a preferred embodiment,
[0035] In a preferred embodiment,
[0036] In a preferred embodiment,
[0037] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0038] 1. In the present invention, by mounting the photographing device on the assembly line stage, the workpiece can be photographed without interference and stably, greatly improving the detection efficiency and accuracy. This automated detection method can not only reduce manual operation, but also achieve 24-hour uninterrupted work, greatly improving production efficiency and product quality.
[0039] 2. In the present invention, structured light technology is used, and a unique method of distinguishing each pixel in both row and column directions using unique code values is created. This method effectively solves the problem of mismatching that is prone to occur in repetitive textures or weak texture areas. By assigning a unique code value to each pixel, each pixel can be accurately distinguished even when the texture is not obvious or the texture is repeated, thereby avoiding common matching errors in image processing and significantly improving the robustness and accuracy of the detection system.
[0040] 3. In the present invention, the traditional matching and measurement algorithms are improved to make them more suitable for high-precision fully automatic detection and measurement. The improved algorithm can process image data quickly and accurately to achieve accurate measurement of workpiece dimensions. This high-precision measurement capability is crucial for factory production. It can not only ensure the accuracy of workpiece dimensions, but also detect unqualified workpieces in a timely manner and trigger an early warning mechanism, thereby preventing unqualified products from entering the market, reducing economic losses and enhancing the company's reputation. In this way, the present invention provides an efficient, accurate and automated detection solution for modern manufacturing, which helps promote the development of industrial automation and intelligent manufacturing. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is the operation flow chart of the binocular structured light measurement system.
[0042] Figure 2 Schematic diagram of the workpiece image acquisition device for binocular structured light
[0043] Figure 3 The conversion relationship diagram of three-dimensional space coordinates to two-dimensional coordinates
[0044] Figure 4 Schematic diagram of the principle of triangulation size. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention 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 invention and are not used to limit the present invention.
[0046] Reference Figure 1-4 ,
[0047] Example:
[0048] A method for precise workpiece measurement based on binocular structured light comprises the following steps:
[0049] 1. Image acquisition and transmission: Install a visible light camera in a parallel binocular form, project linear structured light on the workpiece, and capture left and right views.
[0050] The left and right views of the workpiece to be measured are obtained by a parallel binocular visible light camera mounted on the stage, and transmitted to a computer using the remote transmission module of the camera. The left and right views are processed and analyzed on the computer, where the left and right views refer to the left view and the right view.
[0051] 2. Use the Harris corner detection algorithm to extract the corner points of the calibration plate, calibrate the left and right cameras separately, obtain the parameter matrix, and then jointly calibrate the binocular camera to obtain the rotation matrix and translation vector of the binocular camera.
[0052] The binocular camera calibration uses Zhang Zhengyou's calibration method, which takes multiple sets of calibration plate images at different angles and postures. Usually 10-20 sets of calibration images are optimal.
[0053] Harris corner detection algorithm is used to accurately extract the corner points in the chessboard. First, the chessboard image is converted into a grayscale image. For each pixel in the grayscale image, the horizontal and vertical difference operators are used for filtering. Through the filtering operation, the gradient components of each pixel in the x direction and y direction can be obtained, which are recorded as I and x and I y.
[0054] Then, the image is smoothed using Gaussian filtering. After Gaussian filtering, the autocorrelation matrix M of each pixel is calculated. The M matrix is expressed as:
[0055]
[0056] Where X and Y are the first-order grayscale gradients of pixels in the image, and w is the processed Gaussian smoothing window.
[0057] Next, the autocorrelation matrix M is used to calculate the corner response function R of the corresponding pixel. The corner response function R is a scalar value used to measure the possibility of the pixel being a corner point. The commonly used calculation formula for the corner response function R is:
[0058] R(x,y)=Det(M)-kTr 2 (M) = μ1μ2-k(μ1+μ2) 2 =AB-C 2 -k(A+B) 2
[0059] Where Tr(M) represents the trace of the matrix M, and Det(M) represents the determinant of the matrix M. According to Harris's experience, k is usually taken as 0.04.
[0060] After calculating the corner response function R of each pixel, set a threshold F and compare the R value with the threshold F. If R is greater than F and the pixel is a local maximum point in its neighborhood, the pixel is considered to be a corner point. Finally, by traversing the entire image and applying the above steps, the inner corner points of the chessboard are accurately extracted and their coordinate positions in the image are obtained.
[0061] By using the MATLAB calibration toolbox, the captured images and the detected corner coordinates are added to the calibration object, and the left and right cameras are calibrated respectively. After the calibration is completed, the intrinsic parameter matrices of the left and right cameras and the rotation matrices R1, R2 and translation matrices T1, R2 of the left and right cameras are obtained. On the basis of obtaining the calibration parameters of the left and right cameras, the spatial position of the binocular camera is solved by joint calibration to obtain the internal and external parameters R, T and distortion parameters of the binocular camera.
[0062] The accuracy of the camera calibration is verified by comparing the mean error of the corner reprojection and the left and right image epipolar line results to see if they are within the threshold. If the calibration result is inaccurate, it is necessary to re-shoot the calibration plate image or adjust the camera parameters. Finally, the obtained camera intrinsic and extrinsic calibration results are exported to a readable and writable file for use in subsequent applications.
[0063] 3. After camera calibration, the acquired binocular images are then subjected to epipolar correction to improve the efficiency and accuracy of phase matching.
[0064] In order to make the camera optical axes parallel to each other and the corresponding points in the left and right views on the same epipolar line, after the stereo camera is calibrated, the stereo epipolar line correction is performed using the Bouguet correction method. First, the rotation matrix R of the stereo camera is decomposed into two sub-rotation matrices R1 and R2. Each sub-rotation matrix corresponds to the rotation of a camera.
[0065]
[0066] By using the rotation matrices of the left and right cameras and the original image, the pole of the left camera is transformed to infinity, so that the translation vector between the projection centers of the left and right cameras is the direction of the left pole.
[0067] Then construct a transformation matrix. Based on the translation vector T obtained by the binocular camera calibration in step 2, construct a transformation matrix R rect This transformation matrix is composed of three direction vectors e1, e2 and e3. Among them, e1 is the direction of the optical center of the left and right cameras, e2 is orthogonal to the main optical axis and e1, and parallel to the image, and e3 is orthogonal to e1 and e2.
[0068] The above transformation matrix R rect Multiply the composite rotation matrices R1 and R2 of the left and right cameras to obtain new rotation matrices. Multiply the left and right camera coordinate systems by their respective new rotation matrices so that the principal optical axes of the left and right cameras are parallel and the image plane is parallel to the baseline.
[0069]
[0070] Through the above steps, binocular epipolar correction is completed, so that the two images meet the characteristics of the ideal stereo vision model and the left and right views are aligned.
[0071] 4. After epipolar correction, a method combining fast salient object detection and edge detection is used to effectively remove the background part of the workpiece.
[0072] The GR algorithm is an efficient saliency detection algorithm. It needs to first perform superpixel segmentation on the target image and calculate the saliency value of each superpixel block. The calculation process will simultaneously consider multiple factors such as color, position, and distance from the center area. In the Lab color space, calculate the saliency value of each superpixel area:
[0073]
[0074] In the above formula, ci is the mean color feature vector of the Lab space of region i, p is the mean spatial coordinate normalized to between 0 and 1, σp It is used to control the weight of spatial features.
[0075] Then, the target center position prior information is used to estimate the salient area. Different from the CA algorithm, the GR algorithm uses the center of the convex hull containing the target area as the centroid of the target area and constructs the salient value:
[0076]
[0077] Finally, after matrix operation, the final saliency value of each pixel area is obtained:
[0078] S in (i) = S co (i)×S ce (i)
[0079] Then we optimize the saliency image, and finally use automatic threshold operation to segment the image into binary images and extract the artifact part.
[0080] Then, saliency detection is used as a constraint to extract the edge or contour of the workpiece to improve accuracy.
[0081] In order to improve the accuracy of edge extraction, the improved Canny operator is used as the main edge detection algorithm. First, the grayscale values of the pixel points to be filtered and their neighborhood points are weighted averaged according to the parameter rules generated by the Gaussian formula to form the Gaussian blur of the image, which can effectively filter out the high-frequency noise superimposed in the ideal image.
[0082] The convolution mask is applied to the x and y directions respectively, and then the gradient magnitude and direction are calculated. For each pixel, it performs the following operations: non-maximum suppression technology is applied to filter out non-edge pixels, making the blurred boundaries clear. This process retains the maximum value of the gradient intensity at each pixel and filters out other values.
[0083] 1) The gradient direction is approximated to one of the following values, including 0, 45, 90, 135, 180, 225, 270 and 315, which means up, down, left, right and 45 degrees.
[0084] 2) Compare the gradient strength of the pixel point with the pixel points in the positive and negative directions of its gradient. If the gradient strength of the pixel point is the largest, it is retained; otherwise, it is suppressed (deleted, i.e., set to 0).
[0085] After the traditional Canny operator is used for non-maximum suppression, there are still many noise points in the image. The accuracy of edge detection can be further improved by using a double threshold, that is, setting an upper threshold and a lower threshold. If the pixel in the image is greater than the upper threshold, it is considered to be a boundary (called a strong edge), and if it is less than the lower threshold, it is considered not to be a boundary. If the pixel gradient intensity is between the thresholds, if the pixel is connected to the strong boundary, it is considered to be a boundary, otherwise it is deleted.
[0086] By combining saliency with edge detection, the background and noise can be effectively removed, providing a basis for further improving the accuracy of three-dimensional detection.
[0087] 5. The structured light measurement method combining Gray code and phase shift method is used to obtain the absolute phase information, and then phase matching is performed.
[0088] First, the projector projects 6 Gray code patterns onto the object in sequence, dividing the surface of the object into 26 regions from 000000 to 11111l. Then, a phase shift pattern is projected onto the object, and it is shifted 1 / 4 of a cycle each time, and projected 4 times. The minimum cycle of the Gray code pattern is set to 4 times the cycle of the phase shift pattern, so that the phase value of each point of the phase shift pattern within the Gray code cycle is absolutely unique.
[0089] The decoding process needs to convert the Gray code into a decimal code to obtain the number of cycles k. In order to reduce the interference of the surface color of the object on the measurement results, this paper uses a simplified Daniel Scharsterin method. After projecting a set of Gray code patterns onto the surface of the object, the Gray code is inverted and projected onto the object again. If the grayscale value of the first set of Gray code sampling points is greater than that of the second set, the value is 1, otherwise it is 0. This method reduces the error caused by threshold segmentation and improves the accuracy of the cycle value k. Then, 4 phase-shifted patterns are projected, and the grayscale value of the sampling point can be expressed as:
[0090] I n (x, y)=I′(x, y)+I″(x, y)[cosθ(x, y)+nπ / 2]
[0091] Where I n (x, y) is the gray value of point I(x, y) in the nth phase shift image, I'(x, y) is the background intensity of the stripe light, I"(x, y) / I'(x, y) is the stripe contrast, and θ(x, y) is the main phase value to be determined:
[0092]
[0093] Finally, the absolute phase value Ψ(x, y) of point I(x, y) can be obtained by superimposing the period value obtained by decoding the Gray code with the main phase value:
[0094] ψ(x,y)=2kπ+θ θ(x,y)
[0095] After obtaining the absolute phase value, it needs to be checked again, that is, period correction. Ideally, the Gray code stripes and the phase shift pattern have exactly the same period, the period number k and the phase main value θ change simultaneously, and the absolute phase value Ψ increases monotonically. However, due to interference from environmental factors, there is generally a period misalignment between the two, that is, Ψ(x, y+1)-Ψ(x, y)≈2π. Considering the impact of the environment, when Ψ(x, y+1)-Ψ(x, y)≥3 / 2π, let k(x, y)=k(x, y)+1 to ensure that the Gray code stripes are consistent with the phase shift period.
[0096] After binocular epipolar correction, the pixels in the left and right images are located in the same row, so that the corresponding pixels can be quickly found in the row direction, thereby improving the efficiency of matching search.
[0097] First, take the image captured by the left camera as the reference, select a central pixel point on the image of the left camera, and select an m×m window with the center position (x0, y0). The size of this window is usually an odd number multiplied by an odd number square area, such as 5×5, 7×7, etc. Since the epipolar correction has been performed, the images of the left and right cameras are aligned in the row direction, so the corresponding matching points will be on the same horizontal line.
[0098] In the image captured by the right camera, on the horizontal line corresponding to the center pixel of the left window, (x0+d x , y0) as the center, according to a certain step size or continuous pixel position, move and establish a window of the same size as the left image. Calculate the difference between the absolute phase value of each pixel in the left image window and the absolute phase value of the corresponding pixel in the right image window, and accumulate these differences, and take their absolute value as the cost of phase matching (M SAD ):
[0099]
[0100] Where dx represents the horizontal x-direction offset of a pixel in the matching image relative to the corresponding point in the reference image, and I L (x0+i, y0+j) represents the absolute phase value of the window range after the center point of the left image is moved horizontally by i pixels and vertically by j pixels. R (x0+dx+i, y0+dy+j) represents the absolute phase value within the window after the center point moves i pixels in the horizontal direction and j pixels in the vertical direction.
[0101] Phase matching will repeatedly calculate the phase matching cost within a preset parallax range, each time moving the center position of the right image window. By comparing the sum of phase differences under different parallaxes, the parallax with the minimum difference value is found, which is the best matching point. Finally, the pixel points corresponding to the center position of the window in the left and right images are determined as a pair of matching points under the parallax with the minimum sum of phase differences.
[0102] For each pixel in the left image, after finding its best matching point in the right image, the horizontal distance between the two points is calculated, indicating the distance of the object from the camera in the scene.
[0103] According to the calculated disparity value, a new two-dimensional image, namely the disparity map, is generated.
[0104] 6. Obtain 3D point cloud based on parallax diagram to achieve workpiece measurement
[0105] In a binocular vision system, a point p(u, v) on the image plane can be converted to a point P(X) in the world coordinate system by the following formula: c , Yc, Z c ):
[0106]
[0107] Among them, f x and f y is the focal length of the camera, C x and C y are the coordinates of the optical center of the image.
[0108] In the binocular vision system, the relationship between parallax (the horizontal coordinate difference of points on the image plane of the left and right cameras) and depth is
[0109]
[0110] Where f is the focal length of the camera; baseline is the distance between the two cameras, also called the baseline; U L is the horizontal coordinate on the left camera image plane; U R is the horizontal coordinate of the point on the right camera image plane; the parallax is U L -(-U R ), which is the difference between the two coordinates.
[0111] The generation of point cloud is to convert the depth information of each pixel into a point in three-dimensional space. Through the depth and image coordinates (u, v), the three-dimensional coordinates (x, y, z) are solved, which can be calculated by the following formula:
[0112] x = depth * (u-cx) / fx
[0113] y = depth * (v-cy) / fy
[0114] z=depth
[0115] Where depth is the depth value calculated based on parallax; fx and fy are the focal lengths of the camera; cx and cy are the coordinates of the optical center of the image. x, y, and z are the point cloud coordinate system. After denoising and smoothing the 3D point cloud data, the precise size of the workpiece can be obtained through our measurement method.
[0116] From the above, we can know that:
[0117] In the present invention, by mounting the photographing device on the assembly line stage, the workpiece can be photographed without interference and stably, greatly improving the detection efficiency and accuracy. This automated detection method can not only reduce manual operations, but also achieve 24-hour uninterrupted work, greatly improving production efficiency and product quality.
[0118] In the present invention, structured light technology is used, and a unique method of distinguishing each pixel in both row and column directions using unique code values is created. This method effectively solves the problem of mismatching that is prone to occur in repetitive textures or weak texture areas. By assigning a unique code value to each pixel, each pixel can be accurately distinguished even when the texture is not obvious or the texture is repeated, thereby avoiding common matching errors in image processing and significantly improving the robustness and accuracy of the detection system.
[0119] In the present invention, the traditional matching and measurement algorithms are improved to make them more suitable for high-precision fully automatic detection and measurement. The improved algorithm can process image data quickly and accurately to achieve accurate measurement of workpiece dimensions. This high-precision measurement capability is crucial for factory production. It can not only ensure the accuracy of workpiece dimensions, but also detect unqualified workpieces in a timely manner and trigger an early warning mechanism, thereby preventing unqualified products from entering the market, reducing economic losses and enhancing the reputation of the company. In this way, the present invention provides an efficient, accurate and automated detection solution for modern manufacturing, which helps to promote the development of industrial automation and intelligent manufacturing.
[0120] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0121] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A workpiece precision measurement method based on binocular structured light, characterized in that: The following steps are covered: Step 1: Install the binocular visible light camera and calibrate it using a high-precision small calibration plate. During this process, the Harris algorithm is used to optimize the extraction of corner points to improve the calibration accuracy, thereby determining the position relationship of the right camera relative to the left camera. Step 2: Project the encoded structured light pattern on the workpiece surface and capture the left and right camera views; align the image lines of the left and right views through the Bouguet epipolar correction method, and use saliency detection and edge detection techniques to exclude background elements in the view; Step 3: Combine Gray code and phase shift measurement to obtain the absolute phase information of the workpiece, then accurately match the absolute phase to achieve stereo matching of the image, optimize the efficiency of phase matching through epipolar correction, and generate a disparity map based on this; Step 4: Build a 3D point cloud based on the disparity map, perform denoising and smoothing on the initial point cloud data of the workpiece, and remove redundant point clouds to reconstruct the 3D model and optimize the dimensional accuracy of the workpiece, and finally obtain the shape and precise size of the workpiece.
2. A method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: In the step 1, the binocular camera used is configured with two cameras, the two cameras of the binocular camera are installed to be kept within a fixed distance, and their positions and angles are pre-calibrated during installation; the binocular image is calibrated and corrected to generate a disparity map for measurement.
3. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: In the step 1, the structured light 3D measurement technology and the binocular imaging technology are combined to improve the measurement accuracy during the feature point search process.
4. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: In the step 1, the Harris corner detection algorithm is used to accurately extract corner points during the calibration process, thereby improving the accuracy of the binocular camera calibration; Harris corner detection calculates the eigenvalues μ1 and μ2 of the Harris response matrix M matrix for each pixel in the image, defines a corner response function R(x, y) about the eigenvalues, and sets a reasonable threshold F. If the corner response function R(x, y)>F, the detection result is that there is a corner at the pixel. The M matrix is represented as: In formula (1), X and Y are the first-order grayscale gradients of pixels in the image, and w is the processed Gaussian smoothing window; R(x, y) is expressed as: R(x,y)=Det(M)-kTr 2 (M)=μ1μ2-k(μ1+μ2) 2 =AB-C 2 -k(A+B) 2 (2) In formula (2), Tr(M) represents the trace of matrix M, and Det(M) represents the determinant value of matrix M; Combining the transformation relationship of the four coordinate systems, the transformation relationship from three-dimensional spatial coordinates to two-dimensional coordinates is: In formula (3), M1 is the camera internal parameter and f x 、f y , u0, v0 are related to the internal parameters of the camera; M2 is the camera external parameter, which represents the conversion relationship from the world coordinate system to the camera coordinate system, and is the position and posture matrix of the camera in the world coordinate system; During the calibration process, the position of the calibration plate is constantly changed, and multiple sets of images of the left and right camera calibration plates are collected. Based on the Harris algorithm, the gradient components I of each pixel in the image in the horizontal and vertical directions are first calculated. x ,I y ,I x I y , get the M matrix, in order to suppress the noise in the image and enhance the robustness of corner detection, the image is Gaussian smoothed, then, according to the core idea of Harris algorithm, the corner response function R value corresponding to each pixel on the original image is calculated; by setting a reasonable threshold F, the corner information in the image is detected and the corner coordinates in the image are extracted; By using the MATLAB calibration toolbox, the captured images and the detected corner point coordinates are added to the calibration object, and the left and right cameras are calibrated respectively. After the calibration is completed, the intrinsic parameter matrices of the left and right cameras and the rotation matrices R1, R2 and translation matrices T1, T2 of the left and right cameras are obtained; The camera's intrinsic parameter matrix K is: In formula (4), c is a constant, f x and f y Indicates the position of the focal length in the u-axis and v-axis directions, and u0 and v0 represent the coordinates of the center of the camera's photosensitive plate in the pixel coordinate system; Then, the binocular camera is jointly calibrated to establish the relationship between the camera image pixel position and the object space position, and the rotation matrix and translation vector of the binocular camera are obtained; In formula (5), R1 and R2 are the rotation matrices of the left and right cameras, respectively. T1 and T2 are the translation matrices of the left and right cameras, respectively. R and T represent the rotation matrix and translation vector between the two camera coordinate systems, respectively. R is the rotation angle required for the left camera to rotate from one to the right camera coordinate system, and T is the translation vector required to move from the origin of one camera coordinate system to the origin of another camera coordinate system.
5. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: In the step 2, epipolar correction technology is used to optimize the stereo matching step in the binocular vision measurement process, and the efficiency and accuracy of the measurement are significantly improved by accurately aligning the epipolar lines; Decompose the rotation matrix R of the left and right cameras into the rotation matrices R1 and R2 of the left and right cameras respectively; Apply the decomposed rotation matrix to rotate the left and right cameras by half each, so that their optical axes are parallel; By constructing the transformation matrix R rect , R1 and R2 are placed at R rect Multiplying them together, we get the overall rotation matrix. Multiplying the left and right camera coordinate systems by their respective overall rotation matrices can align the baseline with the imaging plane to achieve row alignment. After the correction is completed, the image is appropriately cropped and a new image center is selected as appropriate to ensure that the left and right images have the largest overlapping part; after the epipolar line correction, the corresponding points of the left and right images will be located on the same epipolar line, thereby improving the efficiency and accuracy of the phase matching step described in step three of claim 1.
6. A method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: In the step 2, the fast significant target detection and edge detection technology are combined to effectively separate the workpiece image and remove the background elements other than the workpiece; The GR algorithm is an efficient saliency detection algorithm. It first segments the target image into superpixels, and then calculates the saliency value of each superpixel block. This calculation process combines factors such as color, position, and distance from the center area of the image. In the Lab color space, the saliency value of each superpixel area is calculated: In the above formula, ci is the mean color feature vector of the Lab space of region i, p is the mean spatial coordinate normalized to between 0 and 1, and δ p It is used to control the weight of spatial features; The GR algorithm then uses the prior information of the center position of the target to estimate the salient area; compared with the CA algorithm, the GR algorithm uses the convex hull center of the target area as the centroid to calculate the saliency value: Based on the saliency value, the final saliency value of each pixel area is obtained through matrix operation: S in (i)=S co (i)×S ce (i)M SAD d x σ p (9) Next, the saliency image is optimized and the automatic thresholding technique is applied to segment the image into a binary image, thereby separating the artifact part. Using the results of saliency detection as a guide, edge or contour extraction of the workpiece is performed to improve the accuracy of the results; In order to improve the accuracy of edge detection, the optimized Canny operator is selected as the main edge detection algorithm. This method first uses Gaussian weights to perform weighted average on the grayscale values of the processed pixel and its neighboring pixels, thereby producing a Gaussian blurred image effect and effectively removing the high-frequency noise superimposed in the ideal image. The convolution mask is applied to the x and y directions respectively, and then the gradient magnitude and direction are calculated; for each pixel, it performs the following operations: non-maximum suppression technology is applied to filter out non-edge pixels to make the blurred boundaries clear; this process retains the maximum value of the gradient intensity at each pixel and filters out other values; (1) The gradient direction is approximated to one of the following values, including 0, 45, 90, 135, 180, 225, 270, and 315, which represent up, down, left, right, and 45-degree directions; (2) Compare the gradient strength of the pixel with that of the pixels in the positive and negative directions of its gradient. If the gradient strength of the pixel is the largest, it is retained; otherwise, it is suppressed (deleted, i.e., set to 0); The accuracy of workpiece edge detection can be further improved by adopting a double threshold, that is, setting an upper threshold and a lower threshold. If the pixel in the image is greater than the upper threshold, it is considered to be a boundary (called a strong edge), and if it is less than the lower threshold, it is considered not to be a boundary. If the pixel gradient intensity is between the thresholds, if the pixel is connected to the strong boundary, it is considered to be a boundary, otherwise it is deleted. By combining saliency with edge detection, the background and noise can be effectively removed, providing a basis for further improving the accuracy of three-dimensional detection.
7. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: In the step three, a structured light measurement method using Gray code and phase shift method is used to analyze the absolute phase information, and then absolute phase matching is performed; First, the projector projects 6 Gray code patterns onto the object in sequence, dividing the surface of the object into 26 areas ranging from 000000 to 11111l. Then, the phase shift pattern is projected onto the object, and it is shifted 1 / 4 of a period each time, and projected 4 times. In addition, the minimum period of the Gray code pattern must be 4 times the period of the phase shift pattern, so that the phase value of each point of the phase shift pattern within the Gray code period is absolutely unique. In the decoding method corresponding to the above encoding method, the Gray code is first converted into a decimal code to obtain the number of cycles k; in order to reduce the interference of the surface color of the object on the measurement result, this paper uses a simplified Daniel Scharsterin method. After projecting a set of Gray code patterns onto the surface of the object, the Gray code is inverted and projected onto the object again; if the gray value of the first set of Gray code sampling points is greater than that of the second set, the value is 1, otherwise it is 0; this method reduces the error caused by threshold segmentation and improves the accuracy of the cycle value k; then, 4 phase-shift patterns are projected, and the gray value of the sampling point can be expressed as: I n (x,y)=I'(x,y)+I”(x,y)[cosθ(x,y)+nπ / 2] (10) In formula (10), I n (x,y) is the gray value of point I(x,y) in the nth phase shift image, I'(x,y) is the background intensity of the stripe light, I"(x,y) / I'(x,y) is the stripe contrast, and θ(x,y) is the main phase value to be determined: Finally, the absolute phase value Ψ(x,y) of point I(x,y) can be obtained by superimposing the period value obtained by decoding the Gray code with the main phase value: ψ(x,y)=2kπ+θ(x,y) (12) After obtaining the absolute phase value, it needs to be checked again, that is, period correction. Ideally, the Gray code stripes and the phase shift pattern have exactly the same period, the period number k and the phase main value θ change simultaneously, and the absolute phase value Ψ increases monotonically. However, due to interference from environmental factors, there is generally a period misalignment between the two, that is, Ψ(x,y+1)-Ψ(x,y)≈2π. Considering the environmental impact, when Ψ(x,y+1)-Ψ(x,y)≈3 / 2π, let k(x,y)=k(x,y)+1 to ensure that the Gray code stripes are consistent with the phase shift period. The absolute phase information of each pixel is obtained by decoding with Gray code and phase shift method. Then, based on the image captured by the left camera, an m×m window with a center position (x0, y0) is selected. Since the images of the left and right cameras have been aligned in the row direction due to epipolar correction, the corresponding matching points will be located on the same horizontal line. In the image from the right camera, construct a window of the same size as the left image, centered at (x0+d x ,y0); then, the difference between the absolute phase value of each pixel in the left image window and the absolute phase value of the corresponding pixel in the right image window is calculated, and these differences are accumulated and their absolute values are taken as the cost of phase matching (M SAD ): In formula (13), d x Indicates the horizontal x-direction offset of a pixel in the matching image relative to the corresponding point in the reference image. L (x0-i, y0+j) represents the absolute phase value of the window range after the center point of the left image is moved horizontally by i pixels and vertically by j pixels. R (x0+d x +i,y0+j) represents the absolute phase value within the window after the center point moves i pixels in the horizontal direction and j pixels in the vertical direction; In a certain range (0,d max ), gradually move the window position in the image captured by the right camera; at each window position, recalculate the matching cost of the absolute phase; by continuously comparing and updating the matching costs, finally find the window position with the minimum cost aggregation; the window centers in the left and right camera images corresponding to this position are determined as a pair of matching points.
8. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: The process of generating the disparity map in step 4 is specifically as follows: Through phase matching of binocular images, the best matching point in the right view can be found for each pixel in the left view, and the horizontal distance between the two points can be calculated to indicate the distance of the object from the camera in the scene. Based on the calculated disparity values, a new two-dimensional image, namely the disparity map, can be generated; the disparity map is usually displayed in the form of a grayscale image, where darker pixels represent smaller disparities and brighter pixels represent larger disparities; finally, a disparity map is obtained from the binocular image.
9. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: The step 4 is specifically as follows: In a binocular vision system, a point p(u,v) on the image plane can be converted to a point P(X c ,Y c ,Z c ): Among them, f x and f y is the focal length of the camera, C x and C y is the coordinate of the optical center of the image; In the binocular vision system, the relationship between parallax (the horizontal coordinate difference of points on the image plane of the left and right cameras) and depth is: Where f is the focal length of the camera; baseline is the distance between the two cameras, also called the baseline; U L is the horizontal coordinate on the left camera image plane; U R is the horizontal coordinate of the point on the right camera image plane; the parallax is U L -(-U R ), which is the difference between the two coordinates; The generation of point cloud is to convert the depth information of each pixel into a point in three-dimensional space. Through the depth and image coordinates (u, v), its three-dimensional coordinates (x, y, z) are solved, which can be calculated by formula 16: x = depth * (u-cx) / fx y=depth*(v-cy) / fy z=depth (16) Where depth is the depth value calculated based on parallax; f x and f y is the focal length of the camera; cx and cy are the center coordinates of the image; In order to avoid too many holes in the workpiece after the three-dimensional point cloud reconstruction and improve the smoothness of the reconstructed surface, the voxel grid centroid point filtering method is used to remove noise points such as outliers and redundant points in the initial point cloud data; By dividing the point cloud space into extremely small grids, each grid contains multiple data points; setting the side length of the voxel grid to d, the maximum value x on the X, Y, and Z coordinate axes is obtained. max ,y max and z max and the minimum value x min ,y min and z min ; Then X, Y, Z can be divided into E, F, G parts, and the number of voxel grids N = E·F·G; E=(x max -x min ) / d F=(y max -y min ) / d G=(z max -z min ) / d (17) Calculate the centroid of each voxel grid interval, denoted as g, and only retain the corresponding centroid in each interval, so that a large amount of redundant point cloud data can be removed and the smoothness of the reconstructed surface can be improved; Where n is the number of data points in the voxel grid, p i Point cloud data; In order to further improve the reconstruction accuracy and effect of the 3D model, this method uses the moving least squares method to smooth the point cloud data and establish the fitting function f(x): Where a(x) = A -1 (x)B(x)y is the coefficient matrix to be determined, where w(xx i ) is the node x i The weight function, y = [y(x1), y(x2), y(x3), .... y(x m )] T ,p(x)=[p1(x),p2(x),p3(x),..p m (x)] T is the basis function, m is the number of basis function terms; The weight function is shown in the following formula. Different basis functions and weight functions are used to change the smoothness and accuracy of the fitting surface, thereby completing the smooth optimization of point cloud data. Where s = r i / βh i , r i =||xx i ||,h i For node x i The size of the weight function influence domain, β is the influence coefficient; The initial point cloud data obtained after denoising and smoothing is converted into a CAD model through a voxel grid algorithm; that is, the point cloud data is grouped into voxels, and each voxel is fitted with a surface to obtain a continuous surface model; since the coordinates of the CAD model are determined by the design coordinate system, and the point cloud data uses the system's measurement coordinate system, it is necessary to align the point cloud data with the CAD model to obtain a 1:1 reconstructed three-dimensional model of the workpiece; the specific steps are as follows: (1) First, unify the coordinate system. Unify the system's measurement coordinate system with the design coordinate system converted by the software. After unification, there is a large difference in position, so calibration is required; (2) Determine the main direction of the point cloud by calculating the eigenvectors and eigenvalues of the point cloud covariance matrix, and then calculate the corresponding rotation and translation matrices to achieve rough alignment of the point cloud and provide a better initial position for fine alignment; (3) Use the iterative closest point algorithm for accurate registration, that is, through continuous iteration, rotation and translation are performed through point-to-point registration. Its measurement standard is based on the least squares method, and the distance between points must be within a certain threshold range. For two point clouds P and Q to be registered, select any point in the point cloud P, denoted by p i , find a point with the shortest Euclidean distance from the point cloud Q, denoted as q i , pi and qi are corresponding points, and the transformation matrix is obtained. After multiple iterations, the most ideal transformation matrix is finally obtained, so that the two clouds overlap. At this time, a condition needs to be set to stop the iteration. The formula is as follows: Among them, R represents the rotation transformation matrix, T represents the translation transformation matrix, and through iterative conditions, point cloud coincidence is achieved, and the point cloud data is aligned with the CAD model; This method uses normal vector estimation based on local surface fitting. By extracting the area points around the measurement point (point P), the local plane is estimated using the least squares method, and then the normal vector of the measurement point in the plane is calculated. The formula is as follows: Among them, a is the normal vector at point P, d is the distance from the coordinate origin to the local plane, and k is the domain point calculated by the minimum multiplication method. Now, the normal vector parameters corresponding to the measured point in the CAD model can be obtained; The normal equation passing through point P can be obtained from point P and the normal vector: Where (x0, y0, z0) is the coordinate of point P, (m, n, p) is the normal vector; The length from the intersection point Q of the plane and the normal to the measuring point is the required flushness and gap parameters; let: Then we can substitute it into the plane equation: Substituting the parametric equation into the coordinates of the intersection point (x, y, z) can be obtained, and the distance d between point P and point Q can be calculated: The above algorithm can be used to determine the actual distances between all edges and corners of the workpiece and complete the surveying and mapping.
10. The method for precise workpiece measurement based on binocular structured light according to claim 1, characterized in that: This method can automatically achieve precise measurement of workpieces The workpiece to be measured is placed in the middle of the stage, and the binocular camera on the stage is responsible for the left and right view images, and the photos are remotely transmitted to the computer processing end; after the four steps of claim 1 are automatically processed, the measurement results can be directly displayed on the display interface; Harris algorithm is used to extract corner points to optimize calibration accuracy, which can achieve accurate camera calibration parameters; Bouguet epipolar correction is used to achieve accurate and efficient alignment of the left and right views; the structured light measurement method combining Gray code and phase shift method is used to solve the absolute phase information, realize stereo matching of images, and improve the accuracy and efficiency of matching; when using the disparity map to establish a three-dimensional point cloud, the initial point cloud data of the workpiece is denoised and smoothed, redundant point clouds are removed, the three-dimensional model is reconstructed, the dimensional accuracy of the workpiece is improved, and finally the precise measurement of the workpiece is achieved.
Citation Information
Cited By
Automatic calibration method and device based on fine inspection camera edge finding and storage medium
CN119559265A
Rapid measurement system for cuboid workpiece under three-coordinate structured light
CN120445091A
Object pose estimation method and device based on three-dimensional point cloud and storage medium
CN121616661A
An object pose estimation method and device based on a three-dimensional point cloud and a storage medium
CN121616661B
