Machine vision-based precise part size automatic detection method and system
By combining subpixel-level topological feature mapping and dual-constraint geometric reconstruction techniques with deep learning and traditional image processing, the problems of low accuracy and poor robustness in precision parts detection in existing technologies have been solved, achieving high-precision and stable automatic detection of parts dimensions.
Patent Information
- Application Number
- CN202511355128.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-22
- Publication Date
- 2025-10-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing machine vision-based precision part size inspection technologies suffer from low inspection accuracy, lack of robustness and adaptability, making it difficult to meet the high-precision measurement requirements at the sub-millimeter or even micrometer level. In particular, the accuracy is unstable under complex shapes and multiple postures, and there is a lack of systematic error compensation mechanisms.
Using sub-pixel topological feature mapping technology, combined with deep learning segmentation models and traditional image processing technology, industrial cameras are used to collect images of precision parts in different positioning postures, perform part positioning and extract regions of interest, and utilize dual-constrained geometric reconstruction and error compensation mechanisms to achieve high-precision measurement.
It significantly improves measurement accuracy to the sub-pixel level, enhances measurement stability and adaptability, and can effectively cope with changes in lighting and posture deviations, meeting the high-precision inspection needs of modern precision manufacturing.
Smart Images

Figure CN120833369A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of machine vision, in particular to a precision part size automatic detection method and system based on machine vision. BACKGROUND
[0002] With the continuous improvement of modern industrial manufacturing level, the machining precision requirement of precision parts is also increasingly strict. The traditional contact measurement method has been difficult to meet the detection demand of high precision and high efficiency, and the non-contact measurement technology based on machine vision has been widely applied in the field of precision part size detection due to its advantages of non-destructive, high efficiency and automation.
[0003] The existing precision part size detection technology based on machine vision mainly adopts pixel-level edge detection method, such as Canny, Sobel and other operators to extract edge features, and then obtains the size through simple geometric calculation. However, this kind of method is limited by the camera resolution, and the measurement precision can only reach the pixel level, which is difficult to meet the high-precision measurement demand of sub-millimeter or even micrometer. Although some technologies introduce sub-pixel edge detection algorithm, due to the lack of effective topological structure preservation and geometric constraint mechanism, there are still problems of unstable precision and poor robustness under the condition of complex shape and multi-pose.
[0004] In addition, the existing method often lacks systematic error compensation mechanism when dealing with complex parts, and it is difficult to cope with the measurement error caused by factors such as light change and pose deviation, which limits its application in high-precision field.
[0005] Therefore, it is urgent to develop a precision part size automatic detection method and system which can realize sub-pixel level precision and has robustness and self-adaptive ability to meet the high-precision detection demand of modern precision manufacturing industry. SUMMARY
[0006] Therefore, the technical problem to be solved by the present application is to overcome the problems of low detection precision, lack of robustness and self-adaptive ability of the existing precision part size detection technology.
[0007] To solve the above technical problems, the present application provides a precision part size automatic detection method based on machine vision, comprising: acquiring precision part images of different positioning poses by an industrial camera; performing part positioning on the precision part images to obtain region of interest images; performing sub-pixel level topological feature mapping on the region of interest images to obtain part edge lines; performing double-constraint geometric reconstruction based on the part edge lines to obtain feature distance and feature angle of the part; The feature distance and the feature angle are calculated according to the feature distance and the feature angle, and error compensation is performed to obtain a measured geometric size of the part.
[0008] Preferably, the images of the precision parts in different positioning postures are collected by an industrial camera, and specifically include: The precision parts are placed in different positioning postures. The images of the precision parts in the different positioning postures are collected by the industrial camera. The images of the precision parts are normalized and preprocessed.
[0009] Preferably, the precision part images are positioned to obtain the region of interest images, and specifically include: A training set of the precision part images is input into a precision part image segmentation model for calculation to obtain a predicted value. An IOU value of the true value and the predicted value is calculated by using an IOU loss function. The parameters of the precision part image segmentation model are updated in reverse by using a gradient descent algorithm. The training set is re-input into the precision part image segmentation model for calculation to determine whether the accuracy requirement is met, if yes, the trained precision part image segmentation model is obtained, and if no, the step of calculating the IOU value of the true value and the predicted value by using the IOU loss function is re-executed. The precision part image is input into the trained precision part image segmentation model to obtain the region of interest image.
[0010] Preferably, the region of interest image is mapped at a sub-pixel level to obtain a part edge line, and specifically includes: The region of interest image is subjected to gray level histogram equalization to highlight the feature region. The edge contour of the feature region is obtained by using a Canny edge detection method. The edge contour is processed by using a morphological operator, and edges smaller than an edge threshold are deleted to obtain accurate edge information. The accurate edge information is tracked by edge chain code to construct a connected edge point sequence. Based on the edge point sequence, a local coordinate system is constructed in the neighborhood of each edge point, sub-pixel subdivision is performed, and a sub-pixel edge point is obtained. The sub-pixel edge point is analyzed by using a profile analysis method of the feature distance and the feature angle to obtain the part edge line.
[0011] Preferably, double-constraint geometric reconstruction is performed based on the part edge line to obtain the feature distance and the feature angle of the part, and specifically includes: The edge points are divided into straight feature edge points and curved feature edge points according to the curvature of the edge points. establishing a linear feature edge line fitting model, fitting the linear feature edge points to obtain a linear feature edge line; establishing a curve feature edge line fitting model, fitting the curve feature edge points to obtain a curve feature edge line; performing image sub-pixel matching on the feature distance and the feature angle obtained by calculating the linear feature edge line and the curve feature edge line to construct a double constraint condition; designing a comprehensive objective function, solving the minimum value of the objective function under the premise of meeting the double constraint condition, and obtaining the optimal feature distance and feature angle.
[0012] Preferably, the linear feature edge line fitting model is Y=KX+b; and the curve feature edge line fitting model is a parametric spline curve.
[0013] Preferably, the feature distance and the feature angle are used to calculate the geometric size of the part and to perform error compensation to obtain the measured geometric size of the part, specifically including: acquiring images of standard precision parts of the same type through an industrial camera, and extracting the feature distance and the feature angle of the standard precision parts; constructing a part geometric relationship model according to the feature distance, the feature angle and the geometric size of the standard precision parts; calculating the pixel ratio of the standard precision parts and the to-be-measured precision parts, and mapping the feature distance and the feature angle of the to-be-measured precision parts to a standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle; inputting the mapped feature distance and the mapped feature angle into the part geometric relationship model to calculate the initial measured geometric size of the to-be-measured precision parts; establishing a part size error model to perform error compensation on the initial measured geometric size to obtain the measured geometric size of the to-be-measured precision parts.
[0014] Preferably, the feature distance and the feature angle of the to-be-measured precision parts are mapped to a standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle, specifically including: constructing a rotation transformation matrix according to the feature angle to realize coordinate system normalization; performing coordinate mapping according to the rotation transformation matrix to convert the feature distance and the feature angle to the standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle.
[0015] Preferably, a part size error model is established to perform error compensation on the initial measured geometric size to obtain the measured geometric size of the to-be-measured precision parts, specifically including: decomposing the total error of the part size error model into three parts of systematic error, random error and model error; The error space distribution function is constructed to describe error characteristics and variation rules of different regions; The parameters of the part size error model are updated by using historical measurement data to realize dynamic adjustment of the model; The initial measurement geometric size is compensated in multiple levels according to the part size error model to obtain the measurement geometric size of the precision part to be measured.
[0016] The application further provides a precision part size automatic detection system based on machine vision, which is used for executing the precision part size automatic detection method based on machine vision. The acquisition module is used for acquiring precision part images in different positioning postures by an industrial camera. The part positioning module is used for performing part positioning on the precision part images to obtain region of interest images. The edge detection module is used for performing sub-pixel level topological feature mapping on the region of interest images to obtain part edge lines. The feature extraction module is used for performing double-constraint geometric reconstruction based on the part edge lines to obtain feature distances and feature angles of the part. The error compensation module is used for calculating part geometric sizes and performing error compensation according to the feature distances and feature angles to obtain measurement geometric sizes of the part.
[0017] Compared with the prior art, the above technical scheme of the application has the following beneficial effects: The precision part size automatic detection method based on machine vision has the following advantages: the sub-pixel level topological feature mapping technology is adopted to improve the edge positioning accuracy from the pixel level to the sub-pixel level (usually up to 1 / 10-1 / 20 pixel), and the measurement accuracy is significantly improved; the double-constraint geometric reconstruction mechanism of feature distances and feature angles is introduced to construct a geometric redundant measurement system, effectively reduce the risk caused by a single unreliable feature, and improve the measurement stability; the deep learning segmentation model and the traditional image processing technology are combined to realize accurate positioning and feature extraction of complex shape parts, and the system application range is expanded; the multi-level error compensation mechanism is established, including rotation matrix conversion, standard-actual size mapping and dynamic error model, and the measurement error caused by factors such as posture change and illumination condition is effectively reduced.
[0018] The precision part size automatic detection system based on machine vision has the following advantages: the overall modular design is adopted, each functional unit is highly specialized and the interface is standardized, and the system is convenient for industrial application integration and function expansion. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to make the content of the present application more easily understood, the present application will be further described in detail below according to specific embodiments of the present application and in conjunction with the accompanying drawings, in which: Figure 1 is a flowchart of a precision part size automatic detection method based on machine vision of the present application; Figure 2 is a flowchart of sub-pixel level topological feature mapping of the present application; Figure 3 is a flowchart of double-constraint geometric reconstruction of the present application; Figure 4 is a structural diagram of a precision part size automatic detection system based on machine vision of the present application. DETAILED DESCRIPTION
[0020] The present application will be further described below in conjunction with the accompanying drawings and specific embodiments, so that those skilled in the art can better understand the present application and implement it, but the embodiments are not limiting to the present application.
[0021] Referring to Figure 1 , the present application provides a precision part size automatic detection method based on machine vision, comprising: S1: acquiring precision part images in different positioning attitudes by an industrial camera; S2: positioning the precision part images to obtain region of interest images; S3: performing sub-pixel level topological feature mapping on the region of interest images to obtain part edge lines; S4: performing double-constraint geometric reconstruction based on the part edge lines to obtain feature distances and feature angles of the part; S5: calculating part geometric dimensions and performing error compensation according to the feature distances and feature angles to obtain measured geometric dimensions of the part.
[0022] Specifically, in S1, the precision part images in different positioning attitudes are acquired by an industrial camera, comprising: S11: placing the precision part in different positioning attitudes. Preferably, at least 8 different attitudes are included to ensure comprehensive acquisition of feature information. These attitudes usually cover 0°, 45°, 90°, 135°, 180°, 225°, 270°, 315° eight directions, and different inclination angles.
[0023] S12: Collect images of the precision parts in different positioning attitudes by using a high-precision industrial camera. In an embodiment of the present application, an industrial camera with a resolution of no less than 5MP (2592x1944 pixels) is adopted, and a high-quality lens and a uniform illumination system are used to obtain clear images of the parts. The optical axis of the camera is perpendicular to the surface of the part, and the working distance is determined according to the focal length of the lens and the field of view range, and is usually 200-500 mm.
[0024] S13: Perform normalization preprocessing on the precision part image. Preferably, the normalization preprocessing includes operations such as illumination equalization, noise filtering, and contrast enhancement to improve the image quality.
[0025] Specifically, in S2, the precision part image is positioned to obtain a region of interest image, including: S21: Obtain a training set of the precision part image, input the precision part image segmentation model for calculation, and obtain a prediction value. The prediction value refers to the segmentation result of the model for the input image, which is usually a binary image, wherein the region with a pixel value of 1 represents a part, and the region with a pixel value of 0 represents a background.
[0026] Preferably, after obtaining the precision part image database, the training set accounts for 70% of the total image data, and the remaining 30% is used as a test set.
[0027] In a preferred embodiment of the present application, a semantic segmentation network such as U-Net or MaskR-CNN is used to train the precision part image segmentation model, and appropriate data enhancement strategies (such as rotation, scaling, and flipping) are used.
[0028] During the model training process, the learning rate is initially set to 0.001, and an exponential decay strategy is used to gradually reduce it during the training process. The batch size is set according to the size of the GPU memory, and is usually 16 or 32.
[0029] S22: Calculate the IOU value of the true value and the prediction value by using the IOU loss function.
[0030] The IOU value calculation formula is as follows: ; Wherein, is the true segmentation region (i.e. the labeled part region), is the predicted segmentation region (i.e. the part region predicted by the model), represents the area of the intersection (i.e. the area of the region that is labeled and predicted as a part at the same time), represents the area of the union (i.e. the total area of the region that is labeled as a part or predicted as a part). The IOU value ranges from 0 to 1, and the larger the value, the more accurate the segmentation result.
[0031] S23: updating the parameters of the precision part image segmentation model in reverse by using a gradient descent algorithm.
[0032] Preferably, an Adam optimizer is used, with the following parameter settings: , , The weight update formula is as follows: ; wherein, represents the model parameters (including all weights and biases in the network) of the i-th step, represents the updated parameters, is a learning rate (initial value is set to 0.001), is a first moment estimate (exponential moving average of the gradient), is a second moment estimate (exponential moving average of the square of the gradient), is a small constant to prevent division by zero (set to ). The formula accelerates the convergence process of the deep network by adaptively adjusting the learning rate of each parameter.
[0033] S24: re-inputting the training set into the precision part image segmentation model for calculation to determine whether the accuracy requirement is met; preferably, when the average IOU value reaches 0.95 or more, and the IOU value of 5 consecutive training periods (epochs) is improved by less than 0.001, it is considered that the model training is completed, and a trained precision part image segmentation model is obtained; otherwise, return to S22 and continue training.
[0034] S25: inputting a precision part image into the trained precision part image segmentation model to obtain an accurate segmentation result of the part and obtain a region of interest (ROI) image.
[0035] Preferably, the region of interest is expanded outward by 5-10 pixels based on the original part segmentation result to ensure that complete edge information is included.
[0036] Specifically, as shown in FIG. 3, in S3, sub-pixel level topological feature mapping is performed on the region of interest image to obtain a part edge line, including: Figure 2 S31: performing gray level histogram equalization on the region of interest image to enhance the contrast of the image and highlight the feature region.
[0037] The gray level histogram equalization uses the following formula: ; wherein, is the kth gray level value of the input image (usually k ranges from 0 to 255), is the transformed gray level value, is the gray level transformation function, is the number of gray levels (usually 256), is the gray level value is the probability density of the gray level value , i.e., the number of pixels with gray level value divided by the total number of pixels, is the cumulative variable from 0 to This step converts the original gray level distribution into an approximately uniform distribution, enhancing the image contrast and making the edges more obvious.
[0038] S32: Obtain the edge contour of the feature region using the Canny edge detection method.
[0039] Canny edge detection includes the following steps: a) Gaussian filter to smooth the image: where I is the original image, is the smoothed image, is the Gaussian kernel, is the standard deviation of the Gaussian kernel (usually takes a value of 1.0-1.5), * represents the convolution operation; b) Calculate the gradient magnitude and direction: , where is the gradient magnitude at position is the gradient direction angle, and are the first-order derivatives in and directions (usually calculated using the Sobel operator); c) Non-maximum suppression: compare adjacent pixels along the gradient direction and retain the local maximum; d) Double threshold processing and hysteresis tracking: use high and low thresholds (such as , ), strong edge points (gradient value greater than ) are directly retained, weak edge points (gradient value between and ) are only retained when connected to strong edge points.
[0040] S33: Process the edge contour using morphological operators and delete edges smaller than the edge threshold to obtain accurate edge information.
[0041] Preferably, a combination of morphological opening and closing operations is used, using a structure element with a size of 3x3: ; ; where I is the binary edge image, is the opening operation result, is the closing operation result, B is the structuring element (usually a 3x3 rectangle or ellipse shape), represents the erosion operation (remove small protrusions around the edge), represents the dilation operation (fill small gaps around the edge). The opening operation is used to remove small connected regions, and the closing operation is used to fill small holes and connect disconnected edges. Edges smaller than the threshold (e.g. less than 10 pixels in length) will be removed to reduce interference.
[0042] The purpose of expanding the ROI region by 5-10 pixels is to ensure that complete edge features that may be near the part boundary are captured, especially when the part is located at the image edge or has a large pose change. The edges with a length less than 10 pixels that are removed in the morphological processing are mainly pseudo-edges generated by noise or fragment edges of non-main structures, rather than effective edge features of real parts. These two steps target different goals, the former ensures that effective information is not lost, and the latter removes interference information. They complement each other and together improve the accuracy of edge extraction. The edge length threshold of 10 pixels is an empirical value based on a large amount of experimental data and can be dynamically adjusted according to the actual application scenario, part characteristics, and image resolution.
[0043] S34: Perform edge chain code tracking on the accurate edge information to construct a connected edge point sequence.
[0044] Edge chain code tracking is based on the 8- connectivity principle, starting from the initial edge point, searching for adjacent edge points in priority order, and generating an ordered edge chain. The chain code direction encoding uses the following rules: ; where represents the direction encoding from the current edge point to the next edge point, corresponding to 8 possible directions (east, northeast, north, northwest, west, southwest, south, southeast). By recording these direction encodings, the shape and direction of the edge can be completely described.
[0045] S35: Based on the edge point sequence, construct a local coordinate system in the neighborhood of each edge point, perform sub-pixel subdivision, and obtain sub-pixel edge points.
[0046] For each edge point , a local coordinate system is constructed in its 5x5 neighborhood, and the sub-pixel position is determined by two-dimensional Gaussian fitting: ; where is the fitted two-dimensional Gaussian function, indicating that at point The gray value at , A is the amplitude (related to the edge strength), is the center of the Gaussian function, representing the edge position with sub-pixel accuracy, and is the standard deviation in the x and y directions, indicating the width of the edge transition zone. The parameters are obtained by fitting the neighborhood grayscale distribution using the least squares method. and , achieving edge positioning with sub-pixel accuracy.
[0047] S36: Analyze sub-pixel edge points using a contour analysis method based on feature distance and feature angle to obtain part edge lines.
[0048] Compute the curvature of each edge point: ; in, is the curvature of the i-th edge point, and are the first-order derivatives of the point in the x and y directions, respectively. and The second-order derivatives of the point in the x and y directions, respectively, are calculated using the finite difference method. Curvature represents the degree of curvature of the edge; a greater curvature indicates a more curved edge, while zero curvature indicates a straight edge. Based on this curvature information and the distance relationship between edge points, a complete representation of the edge line is constructed.
[0049] Specifically, refer to Figure 3 As shown, in S4, dual-constraint geometric reconstruction is performed based on the edge line of the part to obtain the feature distance and feature angle of the part, including: S41: dividing edge points into straight line feature edge points and curve feature edge points according to the curvature of the edge points.
[0050] The classification is based on the statistical characteristics of the curvature of the points on the edge line: if more than 90% of the points on the edge line have curvature , it is classified as a straight feature edge line; otherwise, it is classified as a curved feature edge line. The curvature threshold of 0.01 is an empirical value determined based on experiments and can be adjusted appropriately according to specific application scenarios.
[0051] S42: Establish a straight line feature edge line fitting model, fit the straight line feature edge points, and obtain the straight line feature edge line.
[0052] Preferably, the straight feature edge line fitting model is Y=KX+b.
[0053] The weighted least squares method is used to fit the straight line parameters K and b: ; Among them, K is the slope of the straight line, b is the intercept of the straight line, ( , ) is the first Point coordinates, For the The weight of each point is proportional to the confidence level of the point, which is usually related to the gradient amplitude. n is the number of points on the edge line. The optimal line parameters are obtained by minimizing the sum of squared weighted errors. For n points, the least squares solution is: ; ; Among them, the summation symbol Indicates that all The edge points are accumulated.
[0054] S43: Establishing a curve feature edge line fitting model, fitting the curve feature edge points, and obtaining the curve feature edge line.
[0055] Preferably, the curve feature edge line fitting model is a parameterized spline curve.
[0056] In a preferred embodiment of the present invention, non-uniform rational B-splines (NURBS) curves are used to represent: ; in, For parameters The coordinates of the curve point at For the The coordinates of the control points, For the The weight of the control point, for Order B-spline basis function, The number of control points minus 1, and are the lower and upper limits of the parameter range (usually set to 0 and 1). In the preferred embodiment, (Cubic spline). NURBS parameters are determined by least squares fitting based on the edge point sequence. The number of control points is adaptively set based on the complexity of the curve, typically 1 / 5 to 1 / 10 the number of edge points.
[0057] S44: performing image sub-pixel matching on the characteristic distance and characteristic angle calculated for the straight characteristic edge line and the curved characteristic edge line to construct a dual constraint condition.
[0058] The characteristic distance D is defined as the shortest distance between two edges: ; where, is the characteristic distance, and are two corresponding edge lines, and are points on them, denotes the Euclidean distance between points and .
[0059] The characteristic angle is defined as the angle between two edge lines: ; where, is the characteristic angle, and are the direction vectors of the two edge lines (for straight lines, it is the slope vector; for curves, it is the tangent direction at the characteristic point), denotes the dot product of two vectors, and denote the modulus of two vectors.
[0060] S45: Design a comprehensive objective function, solve the minimum value of the objective function under the premise of meeting the double constraint conditions, and obtain the optimal characteristic distance and characteristic angle.
[0061] The objective function is of the form: ; where, is the comprehensive objective function, and are the sub-objective functions (usually error square functions) related to the characteristic distance and the characteristic angle, and are weight coefficients, representing the relative importance of distance and angle features in measurement, usually set to , , indicating that the importance of distance feature in measurement is usually higher than that of angle feature.
[0062] The double constraint condition is of the form: ; ; where, and are constraint functions, representing the geometric relationships that the characteristic distance and the characteristic angle need to satisfy. By solving this constraint optimization problem, the optimal characteristic distance and the characteristic angle are obtained.
[0063] Specifically, in S5, the part geometric size is calculated according to the feature distance and feature angle, and error compensation is performed to obtain the measured geometric size of the part, including: S51: Collect the image of a standard precision part of the same model through an industrial camera, and extract the feature distance and feature angle of the standard precision part.
[0064] The standard precision part refers to a reference part that has been precisely calibrated, and its actual size is known and accurate. Preferably, a calibrated high-precision standard part is used, and its actual size has been accurately measured by a traditional precision measuring instrument (such as a three-coordinate measuring machine). Collect the image of the standard part in at least 8 different poses, and extract the feature parameters.
[0065] After obtaining the image of the standard precision part, the method of S2-S4 is applied to extract the feature distance and feature angle of the standard precision part.
[0066] S52: According to the feature distance, feature angle and geometric size of the standard precision part, a part geometric relationship model is constructed.
[0067] The part geometric relationship model adopts a polynomial mapping form: ; Wherein, is the part geometric size (in millimeters), is the feature distance (in pixels), is the feature angle (in radians), to are model parameters determined by least squares fitting. This polynomial model not only considers the linear effect of distance and angle on size, but also includes their interaction terms and quadratic terms, which can effectively capture the nonlinear mapping relationship.
[0068] The part geometric size model is based on the mapping relationship between the feature parameters and the actual geometric size , considering the influence of image resolution, lens distortion, etc.
[0069] S53: Calculate the pixel ratio of the standard precision part and the precision part to be measured, and map the feature distance and feature angle of the precision part to be measured to the standard reference coordinate system to obtain the mapped feature distance and feature angle.
[0070] The pixel ratio r is calculated as follows: ; Wherein, is the pixel ratio factor (dimensionless), is the feature pixel size of the standard part (pixel number), The feature pixel size (pixel number) of the precision part to be measured. The scale factor reflects the influence of image resolution or camera position change on size measurement.
[0071] Preferably, the feature distance and the feature angle of the precision part to be measured are mapped to the standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle, comprising: S53-1: Construct a rotation transformation matrix according to the feature angle to realize coordinate system normalization; The rotation matrix is constructed based on the rotation angle wherein, is a 2×2-dimensional rotation matrix, is the rotation angle (radian). The matrix performs a counterclockwise rotation of the angle on the coordinate system; The rotation transformation applies the rotation matrix to ensure that the standard part and the production part are compared in the same coordinate system; S53-2: Perform coordinate mapping according to the rotation transformation matrix to convert the feature distance and the feature angle to the standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle.
[0072] Perform coordinate mapping to convert the feature space to the standard reference coordinate system: wherein, is the original coordinate vector (2×1 dimension, representing the [x, y] coordinates of the point), is the transformed coordinate vector (2×1 dimension), is a 2×2-dimensional rotation matrix, is a 2×1-dimensional translation vector (used for adjustment of the coordinate origin); through this transformation, the influence of the pose difference is eliminated;
[0073] The mapped feature distance and the mapped feature angle are calculated as follows: wherein, is the mapped feature distance (pixel number), is the original feature distance (pixel number), is the pixel scale factor, is the mapped feature angle (radian), is the original feature angle (radian). The feature distance needs to be adjusted according to the pixel scale, while the feature angle remains unchanged under the rotation transformation.
[0074] S54: input the mapped feature distance and feature angle into the part geometric relationship model, and calculate the initial measurement geometric size of the precision part to be measured.
[0075] Apply the part geometric relationship model: ; wherein, is the initial measurement geometric size of the precision part to be measured (mm), is the mapping function of the feature parameter to the geometric size, is the mapped feature distance (pixels), is the mapped feature angle (radians). The mapping function usually adopts the polynomial form mentioned above. By substituting the feature parameters of the precision part to be measured into the mapping function of the standard part, accurate conversion from image measurement to actual size is realized.
[0076] S55: establish a part size error model, and compensate for the error of the initial measurement geometric size to obtain the measurement geometric size of the precision part to be measured. Specifically, it includes: S55-1: decompose the total error of the part size error model into three parts of systematic error, random error and model error.
[0077] The total error of the error model is: ; wherein, is the total error (the difference between the measured value and the true value, in mm), is the systematic error (deterministic error caused by fixed factors such as camera calibration and lighting conditions, in mm), is the random error (uncertain error caused by random factors such as image noise and vibration, in mm), is the model error (error caused by approximation of the mapping model, in mm). By decomposing the error into different sources, targeted compensation can be performed.
[0078] S55-2: construct an error space distribution function to describe the error characteristics and variation law of different regions.
[0079] The form of the error space distribution function is: ; wherein, is the error value (mm) at position is the th basis function (such as polynomial basis function, radial basis function, etc.), is the th coefficient, is the measurement geometric size of the precision part to be measured (mm).coefficient of the basis function, number of basis functions, residual term (error part that cannot be explained by the model). This function is fitted by analyzing historical measurement data, describing the spatial distribution characteristics of the error.
[0080] The processing of random error adopts the way of statistical filtering and multiple measurement averaging: ; where, average random error after multiple measurements (mm), random error of the measurement (mm), number of measurements. By increasing the number of measurements, the influence of random error can be significantly reduced, in line with the statistical laws of random processes.
[0081] S55-3: Update the parameters of the part size error model using historical measurement data, and realize dynamic adjustment of the model.
[0082] Based on the Bayesian framework, update the model parameters: ; where, posterior probability distribution of parameters given data , likelihood function (representing the probability of observing data under parameters ), prior probability distribution of parameters , is proportional to. Update the model parameters by maximum a posteriori estimation.
[0083] S55-4: According to the part size error model, compensate the initial measured geometric size in a hierarchical manner to obtain the measured geometric size of the precision part to be measured.
[0084] The final correction formula is:
[0085] where, measured geometric size of the precision part to be measured (mm), initial measured geometric size of the precision part to be measured (mm), and deterministic compensation amount of systematic error (mm), model error estimation compensation amount obtained by statistical modeling of historical data (mm), The average estimation of random error (mm) obtained by multiple measurements. This hierarchical compensation strategy uses different processing methods for errors with different characteristics, systematic errors are compensated by deterministic models, model errors are compensated by statistical modeling estimation, and random errors are reduced by multiple measurement filtering, which improves the measurement accuracy and reliability.
[0086] The sub-pixel level topological feature mapping technology is adopted in the precision part size automatic detection method based on machine vision, the edge positioning accuracy is improved from pixel level to sub-pixel level (usually up to 1 / 10-1 / 20 pixel), and the measurement accuracy is significantly improved; the double-constraint geometric reconstruction mechanism of feature distance and feature angle is introduced, a geometric redundant measurement system is constructed, the risk caused by unreliable single feature is effectively reduced, and the measurement stability is improved; the deep learning segmentation model and the traditional image processing technology are combined, the precise positioning and feature extraction of the complex shape part are realized, and the system application range is expanded; a multi-level error compensation mechanism is established, including rotation matrix conversion, standard-actual size mapping and dynamic error model, and the measurement error caused by factors such as posture change and illumination condition is effectively reduced.
[0087] Based on the above-mentioned machine vision precision part size automatic detection method, the application further provides a machine vision precision part size automatic detection system, as shown in Figure 4 , comprising: The acquisition module is used for acquiring the images of the precision parts in different positioning attitudes through the industrial camera; The part positioning module is used for part positioning on the precision part image to obtain the region of interest image; The edge detection module is used for sub-pixel level topological feature mapping on the region of interest image to obtain the part edge line; The feature extraction module is used for performing double-constraint geometric reconstruction based on the part edge line to obtain the feature distance and feature angle of the part; The error compensation module is used for calculating the part geometric size and performing error compensation according to the feature distance and feature angle to obtain the measured geometric size of the part.
[0088] The machine vision precision part size automatic detection system has a modular design, each functional unit is highly specialized and the interface is standardized, and is convenient for industrial application integration and function expansion.
[0089] In conclusion, the application provides a precision part size automatic detection method and system based on machine vision, which realizes high-precision automatic detection of precision part size through sub-pixel level topological feature mapping and double-constraint geometric reconstruction technology, significantly improves the measurement precision, enhances the robustness and adaptability of the system, and meets the demand of modern precision manufacturing industry for high-precision detection.
[0090] Those skilled in the art will understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.
[0091] The present application is described with reference to flowcharts and / or block diagrams according to the methods, devices (systems), and computer program products of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the flow Figure 1 one or more flows and / or blocks Figure 1 an apparatus that implements the function specified in the flow or flows and / or block or blocks.
[0092] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including instruction apparatus, which implements the flow Figure 1 one or more flows and / or blocks Figure 1 an apparatus that implements the function specified in the flow or flows and / or block or blocks.
[0093] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide a process for implementing the flow Figure 1 one or more flows and / or blocks Figure 1 an apparatus that implements the function specified in the flow or flows and / or block or blocks.
[0094] Obviously, the above embodiments are merely example for clearly illustrating, and are not limitation to the embodiments. Based on the above description, other different forms of changes or variations can be made by those skilled in the art. Here, all the embodiments are not required to be enumerated, and the obvious changes or variations derived from the above are still within the protection scope of the present application.
Claims
1. A method for automatic detection of dimensions of precision parts based on machine vision, characterized in that, The method comprises the following steps: Collecting images of precision parts in different positioning attitudes by an industrial camera; Part positioning is performed on the precision part images to obtain region of interest images; Sub-pixel level topological feature mapping is performed on the region of interest images to obtain part edge lines; Double-constraint geometric reconstruction is performed based on the part edge lines to obtain feature distances and feature angles of the part; The feature distances and feature angles are used to calculate the geometric size of the part and perform error compensation to obtain the measured geometric size of the part.
2. The method according to claim 1, wherein, The method for collecting images of precision parts in different positioning attitudes by an industrial camera comprises the following steps: Placing the precision part in different positioning attitudes; Collecting images of the precision part in different positioning attitudes by an industrial camera; Performing normalization preprocessing on the precision part images.
3. The method according to claim 2, wherein, Part positioning is performed on the precision part images to obtain region of interest images, which comprises the following steps: Obtaining a training set of precision part images, inputting the precision part image segmentation model for calculation to obtain a prediction value; Using an IOU loss function to calculate the IOU value of the true value and the prediction value; Using a gradient descent algorithm to update the parameters of the precision part image segmentation model in reverse; Re-inputting the training set into the precision part image segmentation model for calculation to determine whether the accuracy requirement is met, if yes, obtaining the trained precision part image segmentation model, if not, re-executing the step of using the IOU loss function to calculate the IOU value of the true value and the prediction value; Inputting the precision part image into the trained precision part image segmentation model to obtain a region of interest image.
4. The method according to claim 1, wherein, Sub-pixel level topological feature mapping is performed on the region of interest image to obtain part edge lines, which comprises the following steps: Performing gray histogram equalization on the region of interest image to highlight the feature region; Using a Canny edge detection method to obtain the edge contour of the feature region; Using a morphological operator to process the edge contour and deleting the edges smaller than the edge threshold to obtain accurate edge information; Performing edge chain code tracking on the accurate edge information to construct a connected edge point sequence; Based on the edge point sequence, constructing a local coordinate system in the neighborhood of each edge point, performing sub-pixel subdivision to obtain a sub-pixel edge point; Using a profile analysis method of feature distance and feature angle to analyze the sub-pixel edge point to obtain part edge lines.
5. The method according to claim 1, wherein Double-constraint geometric reconstruction is performed based on the part edge lines to obtain feature distances and feature angles of the part, which comprises the following steps: Dividing the edge points into straight feature edge points and curved feature edge points according to the curvature of the edge points; Establishing a straight feature edge line fitting model to fit the straight feature edge points to obtain a straight feature edge line; Establishing a curved feature edge line fitting model to fit the curved feature edge points to obtain a curved feature edge line; Performing image sub-pixel matching on the feature distances and feature angles obtained by the straight feature edge line and the curved feature edge line to construct double-constraint conditions; Designing a comprehensive objective function, solving the minimum value of the objective function under the premise of meeting the double-constraint conditions to obtain optimal feature distances and feature angles.
6. The method according to claim 5, wherein The straight feature edge line fitting model is Y=KX+b; and the curved feature edge line fitting model is a parameterized spline curve.
7. The method according to claim 1, wherein The feature distance and the feature angle are used to calculate the geometric size of the part and to perform error compensation to obtain the measured geometric size of the part. Images of standard precision parts of the same model are collected by an industrial camera, and the feature distance and the feature angle of the standard precision parts are extracted. A part geometric relationship model is constructed according to the feature distance, the feature angle and the geometric size of the standard precision part. The pixel ratio of the standard precision part and the to-be-measured precision part is calculated, and the feature distance and the feature angle of the to-be-measured precision part are mapped to a standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle. The mapped feature distance and the mapped feature angle are input into the part geometric relationship model to calculate the initial measured geometric size of the to-be-measured precision part. A part size error model is established to perform error compensation on the initial measured geometric size to obtain the measured geometric size of the to-be-measured precision part.
8. The method according to claim 7, wherein, The feature distance and the feature angle of the to-be-measured precision part are mapped to a standard reference coordinate system to obtain the mapped feature distance and the mapped feature angle, which specifically includes: A rotation transformation matrix is constructed according to the feature angle to realize coordinate system normalization; The feature distance and the feature angle are converted to the standard reference coordinate system according to the rotation transformation matrix to obtain the mapped feature distance and the mapped feature angle.
9. The method according to claim 7, wherein, A part size error model is established to perform error compensation on the initial measured geometric size to obtain the measured geometric size of the to-be-measured precision part, which specifically includes: The total error of the part size error model is decomposed into three parts of systematic error, random error and model error; An error space distribution function is constructed to describe the error characteristics and variation law of different regions; The parameters of the part size error model are updated using historical measurement data to realize dynamic adjustment of the model; The initial measured geometric size is compensated in multiple levels according to the part size error model to obtain the measured geometric size of the to-be-measured precision part.
10. A machine vision based precision part dimension automatic detection system for performing the machine vision based precision part dimension automatic detection method of any one of claims 1-9, wherein, It includes: A collection module is configured to collect images of precision parts in different positioning attitudes by an industrial camera; A part positioning module is configured to perform part positioning on the precision part images to obtain region of interest images; An edge detection module is configured to perform sub-pixel level topological feature mapping on the region of interest images to obtain part edge lines; A feature extraction module is configured to perform double-constraint geometric reconstruction based on the part edge lines to obtain feature distances and feature angles of the part; An error compensation module is configured to calculate the geometric size of the part according to the feature distances and the feature angles and to perform error compensation to obtain the measured geometric size of the part.
Citation Information
Patent Citations
Industrial part contour line multi-feature extracting method with additional constraint conditions
CN104655041A
Visual identification-based precise shaft size measurement method, apparatus and system
CN108288288A
High-precision measurement method, device and equipment for size of workpiece with angular points and medium
CN119152011A
Highly dynamic wide-range any-contour-error monocular six-dimensional measurement method for numerical control machine tool
WO2019090487A1
Cited By
Furniture edge curve accurate image recognition and processing system
CN121213798A
Sealing ring appearance detection method and detection equipment based on image processing
CN121558751A
Image processing-based seal ring appearance detection method and detection device
CN121558751B
Component size detection system based on machine vision
CN121724969A
