High-precision measurement method, device, equipment and medium for workpiece dimensions with corner points
By preprocessing the original image of the target workpiece and optimizing the key points in the corner area, the problems of low efficiency and low accuracy of workpiece size measurement with corner points in the prior art are solved, and high-precision workpiece size measurement is achieved .
Patent Information
- Application Number
- CN202411635978.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-15
AI Technical Summary
The prior art is inefficient and low accuracy when measuring workpiece sizes with corner points.
By preprocessing the original image of the target workpiece, based on the preset edge detection model and the target detection model, the key points of the corner point area are detected and optimized, and their world coordinate information is obtained to calculate the workpiece size.
High-precision measurement of workpieces with corner points is achieved, improving the accuracy and efficiency of measurement, especially when dealing with special corner points, it is more accurate, stable and efficient.
Smart Images

Figure CN119152011B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of workpiece dimension measurement, and in particular to a method, device, equipment and medium for high-precision measurement of workpiece dimensions with corner points. Background Art
[0002] In the process of precision parts manufacturing, it is often necessary to measure the dimensions of the parts after they are processed to determine whether they meet the specifications. With the development of technology, the measurement of dimensions has gradually become automated, but the measurement of special parts still relies on traditional measurement methods, and often requires manual visual measurement through measuring instruments and other equipment. Taking plate-like thin steel sheets as an example, in order to avoid stress concentration and sharp edges that may hurt people, and to improve the strength and safety of the steel sheets after shearing and punching, it is often necessary to round the corners of the steel sheets, that is, to eliminate burrs and create arcs. However, manual measurement of rounded corners is complicated and prone to errors.
[0003] In order to solve the problem of automated measurement, related technologies have been developed in recent years to achieve this goal using computer vision methods. In the prior art, the multi-view images of multiple 2D cameras are aligned with the known 3D workpiece model by extracting and matching specific point features, thereby achieving workpiece size measurement. Alternatively, the camera calibration method is used to establish the relationship between the image and the real size, and the basic parameters of the workpiece are calculated by enhancing the collected target workpiece image, extracting edge contours, template matching, edge segmentation and fitting, and performing real size conversion.
[0004] In summary, the traditional workpiece measurement method is more flexible and intuitive, but it has low efficiency and human errors. The computer vision method has the advantages of automation and efficiency, and can achieve a certain degree of automatic measurement, but there is still room for improvement. For example, the use of multiple cameras is costly, and relies on prior knowledge of 3D models, lacks flexibility, and is not accurate; while camera calibration improves measurement accuracy, it relies on template images and does not take into account the situation where special corners are widely present in current processes. Summary of the invention
[0005] The embodiments of the present invention provide a method, device, equipment and medium for high-precision measurement of workpiece dimensions with corner points, aiming to solve the problems of low efficiency and low accuracy in the prior art for measuring the dimensions of workpieces with corner points.
[0006] In a first aspect, an embodiment of the present invention provides a method for high-precision measurement of workpiece dimensions with corner points, comprising:
[0007] Preprocessing the original workpiece image of the target workpiece to obtain a preprocessed workpiece image, acquiring a workpiece region in the preprocessed workpiece image based on a preset edge detection model, and obtaining an image of a region of interest;
[0008] Detecting corner point areas in the region of interest image based on a preset first target detection model;
[0009] Detecting key points of the corner point area based on a preset second target detection model;
[0010] Based on geometric constraint information between key points in the corner point area, optimizing the key points in the corner point area to obtain optimized key points in the corner point area;
[0011] The image coordinate information of the optimized key points of the corner point area in the original workpiece image is obtained, the world coordinate information of the optimized key points of the corner point area is obtained according to the image coordinate information and preset camera calibration parameters, and the size information of the target workpiece is obtained based on the world coordinate information.
[0012] A further technical solution is that the workpiece region in the preprocessed workpiece image is acquired based on a preset edge detection model to obtain an image of a region of interest, including:
[0013] Acquiring edge information of the preprocessed workpiece image based on a preset edge detection model;
[0014] Acquire the maximum circumscribed rectangle of the edge information to obtain the workpiece area in the preprocessed workpiece image;
[0015] A workpiece region in the preprocessed workpiece image is intercepted to obtain the region of interest image.
[0016] A further technical solution is that the detecting the key points of the corner point area based on the preset second target detection model includes:
[0017] After scaling the corner point region to a preset target size, the region is input into the second target detection model, and the key points of the corner point region are detected by the second target detection model.
[0018] A further technical solution is that the key points of the corner point area include left boundary points, right boundary points, corner points and heart points, and the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area, including:
[0019] Determine a first straight line based on the left boundary point, the corner point of the corner point area, and the corner points of the corner point area adjacent to the corner point area;
[0020] Determine a second straight line based on the right boundary point, the corner point of the corner point area, and the corner points of the corner point area adjacent to the corner point area;
[0021] An intersection point between the first straight line and the second straight line is obtained as an optimized corner point corresponding to the corner point.
[0022] A further technical solution is that the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area, and further includes:
[0023] Obtaining a first distance between the left boundary point and the optimized corner point;
[0024] Acquire a second distance between the right boundary point and the optimized corner point;
[0025] Obtaining a distance difference between the first distance and the second distance;
[0026] Determining whether the distance difference is greater than a preset distance threshold;
[0027] If the distance difference is greater than a preset distance threshold, and the first distance is greater than the second distance, the left boundary point is moved along the first straight line by half of the distance difference in a direction close to the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; the right boundary point is moved along the second straight line by half of the distance difference in a direction away from the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point;
[0028] If the distance difference is greater than a preset distance threshold and the first distance is less than the second distance, the left boundary point is moved along the first straight line by half of the distance difference in a direction away from the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; the right boundary point is moved along the second straight line by half of the distance difference in a direction close to the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point.
[0029] A further technical solution is that the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area, and further includes:
[0030] Obtaining the midpoint between the optimized left boundary point and the optimized right boundary point;
[0031] Determine a third straight line based on the optimized left boundary point and the optimized right boundary point; obtain a fourth straight line that is perpendicular to the third straight line and passes through the midpoint;
[0032] The orthocenter from the incenter to the fourth straight line is obtained as the optimized incenter corresponding to the incenter.
[0033] A further technical solution is that the preprocessing of the original workpiece image of the target workpiece to obtain the preprocessed workpiece image includes:
[0034] The original workpiece image of the target workpiece is subjected to equalization processing to obtain the preprocessed workpiece image.
[0035] In a second aspect, an embodiment of the present invention further provides a high-precision measuring device for workpiece dimensions with corner points, which includes a unit for executing the above method.
[0036] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.
[0037] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0038] The embodiment of the present invention provides a method, device, equipment and medium for high-precision measurement of workpiece dimensions with corner points. The method includes: preprocessing the original workpiece image of the target workpiece to obtain a preprocessed workpiece image, acquiring the workpiece area in the preprocessed workpiece image based on a preset edge detection model to obtain an image of the region of interest; detecting the corner point area in the image of the region of interest based on a preset first target detection model; detecting the key points of the corner point area based on a preset second target detection model; optimizing the key points of the corner point area based on geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area; obtaining the image coordinate information of the optimized key points of the corner point area in the original workpiece image, obtaining the world coordinate information of the optimized key points of the corner point area based on the image coordinate information and preset camera calibration parameters, and obtaining the size information of the target workpiece based on the world coordinate information. The present invention can extract the accurate outer contour from the original workpiece image, mark the key points in each corner point area, accurately locate and fit various special corner point areas of the steel sheet, and finally obtain its accurate position, radius and geometric characteristics, so that the measurement and positioning of steel sheets with special corner points are more accurate, stable and efficient, thereby improving the production efficiency and the workpiece quality inspection process level. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0040] Figure 1 A schematic diagram of a process flow of a method for high-precision measurement of workpiece dimensions with corner points provided by an embodiment of the present invention;
[0041] Figure 2 Another schematic diagram of a process flow of a method for high-precision measurement of workpiece dimensions with corner points provided by an embodiment of the present invention;
[0042] Figure 3 A flow chart of workpiece edge contour extraction provided by an embodiment of the present invention;
[0043] Figure 4 A schematic diagram of a key point detection process provided by an embodiment of the present invention;
[0044] Figure 5 A schematic block diagram of a high-precision measuring device for workpiece dimensions with corner points provided by an embodiment of the present invention;
[0045] Figure 6 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0048] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0049] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0050] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0051] See also Figure 1 Combined with Figure 2 , Figure 1 1 is a flow chart of a method for high-precision measurement of workpiece dimensions with corner points provided by an embodiment of the present invention. As shown in the figure, the method comprises the following steps:
[0052] S1, preprocessing an original workpiece image of a target workpiece to obtain a preprocessed workpiece image, acquiring a workpiece region in the preprocessed workpiece image based on a preset edge detection model, and obtaining an image of a region of interest.
[0053] In the specific implementation, a high-resolution camera is installed on the production line or quality inspection table, the target workpiece is placed and the original workpiece image is obtained; in order to avoid the influence of light changes and improve image contrast, the original workpiece image of the target workpiece is preprocessed to obtain a preprocessed workpiece image.
[0054] Furthermore, the edge of the workpiece in the preprocessed workpiece image is acquired based on a preset edge detection model to obtain a workpiece region, and the workpiece region is cropped to obtain an image of a region of interest.
[0055] For example, in one embodiment, the above step of “preprocessing the original workpiece image of the target workpiece to obtain the preprocessed workpiece image” includes: performing equalization processing on the original workpiece image of the target workpiece to obtain the preprocessed workpiece image.
[0056] In the specific implementation, the equalization processing is specifically histogram equalization processing. The original workpiece image is processed by histogram equalization to obtain a pre-processed workpiece image. Histogram equalization processing can improve the uneven brightness of the image and effectively improve the image contrast.
[0057] For example, in one embodiment, the above step of "obtaining the workpiece region in the pre-processed workpiece image based on a preset edge detection model to obtain an image of the region of interest" includes:
[0058] S11, acquiring edge information of the preprocessed workpiece image based on a preset edge detection model.
[0059] In a specific implementation, the edge detection model adopts the Mobile-Seed algorithm. The edge detection model can be used to extract edge contour maps and semantic segmentation maps with high consistency from the pre-processed workpiece image.
[0060] The Mobile-Seed algorithm is a lightweight semantic segmentation model that integrates edge detection tasks. The algorithm consists of three parts: a dual-branch encoder structure, an active fusion decoder, and multi-task consistency constraints. Among them, the backbone of the encoder is a feature extractor composed of two MobileNetV2 modules, which embeds the original image into a high-dimensional feature space to obtain a high-dimensional feature map, which is input into the subsequent two branches; the two branches, one is the semantic branch, which uses the lightweight semantic segmentation backbone network AFFormer-T, and the other branch is the edge branch. In addition to the high-dimensional feature map from the backbone, the multi-scale intermediate feature map of the semantic branch is also used as input, and a 3x3 convolution module is used to convert the semantic information into edge information, and finally the multi-scale edge information is spliced together. The active fusion decoder obtains the feature vector through operations such as global average pooling and channel attention, and fuses the two features by splicing. The multi-task consistency constraint of the Mobile-Seed algorithm is reflected in the alignment of the pseudo-edge features generated by the differential template and the edge features predicted by the edge branch, and additional supervision is performed on the semantic prediction of the area near the edge, so as to achieve the consistency constraint of the edge and semantics. The network structure of the Mobile-Seed algorithm is as follows: Figure 3 The workpiece edge contour extraction flow chart is shown in FIG.
[0061] According to the above edge contour map and semantic segmentation map, the edge information of the segmented target workpiece area can be obtained. The specific operation is to perform a morphological closing operation on the workpiece area mask segmented in the semantic segmentation map, while eliminating the isolated area and expanding the edge of the workpiece area. By aligning the positions of the workpiece area mask after the morphological closing operation and the edge contour map, the edge within the mask can be obtained, which is the edge information of the workpiece area.
[0062] It should be noted that, in this embodiment, the artifact mask is the target in the semantic segmentation map, and the semantic segmentation map includes an artifact area mask and a non-artifact area mask, a total of two types of pixels. In this embodiment, the edge information of the edge contour map is aligned with the artifact area mask in the semantic segmentation map. Specifically, the area enclosed by the edge of the artifact in the edge contour map is image-and-operated with the artifact area mask in the semantic segmentation map to obtain the edge within the mask.
[0063] S12, obtaining the maximum circumscribed rectangle of the edge information to obtain the workpiece region in the preprocessed workpiece image.
[0064] In a specific implementation, the edge information may be an irregular figure, and its maximum circumscribed rectangle is obtained. The area framed by the maximum circumscribed rectangle is the workpiece area in the pre-processed workpiece image.
[0065] S13, intercepting the workpiece region in the preprocessed workpiece image to obtain the region of interest image.
[0066] In a specific implementation, the image of the region of interest can be obtained by cropping the workpiece region in the pre-processed workpiece image using a cropping tool.
[0067] S2: Detect corner point areas in the region of interest image based on a preset first target detection model.
[0068] In a specific implementation, the above-mentioned region of interest image is input into the first target detection model to obtain the corner point region R of the target workpiece. i ( i= 0,1...). The first target detection model uses the YOLOv10 algorithm. To reduce the number of parameters that need to be trained, the first target detection model shares a feature extraction module with the Mobile-Seed in step S1. The specific network structure is as follows: Figure 3 The edge information features that have been fused with semantic feature information are input into the subsequent PAN structure to further fully fuse semantic information and spatial information, and then input into the subsequent regression and classification modules to obtain the position information and classification information of the corner area, such as rounded corners, right angles, etc.
[0069] It can be understood that the first target detection model is trained in advance with training data so that it has the ability to identify corner point areas.
[0070] S3: Detect key points of the corner point area based on a preset second target detection model.
[0071] In the specific implementation, in order to facilitate measurement, it is necessary to further locate the key points in the corner point area. In order to improve the prediction accuracy, the second target detection model of the present invention can also use the YOLOv10 algorithm, and the second target detection model can be used to perform regression prediction on the key point coordinates to achieve key point prediction.
[0072] Specifically, the second object detection model is trained in advance with training data so that it has the ability to identify key points in the corner point area. Then, the key points in the corner point area are detected with the preset second object detection model.
[0073] For example, in one embodiment, the above step of "detecting the key points of the corner point area based on a preset second target detection model" includes: scaling the corner point area to a preset target size, inputting it into the second target detection model, and detecting the key points of the corner point area through the second target detection model.
[0074] In the specific implementation, the corner point area R smaller than the fixed size S in the above step S2 is i Normalization is performed and enlarged to a uniform size S. Similarly, the corner point area larger than the size S is reduced to a uniform size S. Through the normalization and scaling operation, the normalized corner point area R is obtained. i '.
[0075] R i 'Input into the second target detection model to obtain the coordinates of the four key points in the corner area, such as Figure 4 As shown in the figure, they are named as corner points (or virtual corner points), incenter points, left boundary points, and right boundary points according to their positions. Among them, the corner point or virtual corner point is the intersection point of two edges in the region, the incenter point is located on one side of the region formed by the two edges of the region and less than 180 degrees (when the corner is rounded, the incenter point represents the center of the rounded corner), and the left and right boundary points are named based on the main direction from the incenter point to the virtual corner point. The left boundary point is on the left side of this direction, and the right boundary point is on the right side of this direction.
[0076] S4, optimizing the key points of the corner point region based on geometric constraint information between the key points of the corner point region to obtain optimized key points of the corner point region.
[0077] The key points predicted by deep learning above have certain errors. To further improve the measurement accuracy, the present invention uses the geometric characteristics of the edge of the target workpiece to further optimize the predicted key point coordinates to obtain optimized key points. Sort all the corner point areas mentioned above in clockwise order according to the coordinates, R1R 2… R N ; Start from the first corner point area and optimize it one by one.
[0078] For example, in one embodiment, the key points of the corner point region include a left boundary point, a right boundary point, a corner point, and an inner heart. The above step of "optimizing the key points of the corner point region based on geometric constraint information between the key points of the corner point region to obtain optimized key points of the corner point region" includes the following steps:
[0079] S41, determining a first straight line based on the left boundary point, the corner point of the corner point region, and the corner points of the corner point region adjacent to the corner point region.
[0080] S42, determining a second straight line based on the right boundary point, the corner point of the corner point area, and the corner points of the corner point area adjacent to the corner point area;
[0081] S43: Obtain an intersection point between the first straight line and the second straight line as an optimized corner point corresponding to the corner point.
[0082] In a specific implementation, according to the geometric constraints, the left boundary point of the corner point region, the corner point and the corner point of the adjacent corner point region of the corner point region. It can be understood that the adjacent corner point region of the corner point region is determined according to the arrangement order between the corner point regions.
[0083] The first straight line is L1: ;
[0084] The second straight line is L2: .
[0085] Among them, A 1、 A 2、 B 1、 B 2、 C 1、 C2 is the coefficient of the above straight line equation.
[0086] Substituting the left boundary point, corner point of the corner point area and the corner points of the adjacent corner point area of the corner point area into the first straight line L1, and solving the linear equations by the least square method, the expression of the first straight line can be determined.
[0087] Substituting the right boundary point, corner point of the corner point area and the corner points of the adjacent corner point area of the corner point area into the second straight line L2, and solving the linear equations by the least squares method, the expression of the second straight line can be determined.
[0088] Then, the intersection point of the first straight line and the second straight line is calculated as the optimized corner point corresponding to the corner point. .
[0089] S44, obtaining a first distance between the left boundary point and the optimized corner point.
[0090] S45: Obtain a second distance between the right boundary point and the optimized corner point.
[0091] S46: Obtain a distance difference between the first distance and the second distance.
[0092] In a specific implementation, the distance difference is equal to the absolute value of the difference between the first distance and the second distance.
[0093] S47, determining whether the distance difference is greater than a preset distance threshold.
[0094] In a specific implementation, if the distance difference is greater than a preset distance threshold, it indicates that there is a deviation between the positions of the left boundary point and the right boundary point, and therefore adjustment is required; otherwise, it is considered that there is no deviation between the positions of the left boundary point and the right boundary point, and therefore no adjustment is required. The specific adjustment method is as follows S48-S49.
[0095] S48, if the distance difference is greater than a preset distance threshold, and the first distance is greater than the second distance, move the left boundary point along the first straight line by half of the distance difference toward the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; move the right boundary point along the second straight line by half of the distance difference away from the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point.
[0096] S49, if the distance difference is greater than a preset distance threshold and the first distance is less than the second distance, move the left boundary point along the first straight line by half of the distance difference in a direction away from the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; move the right boundary point along the second straight line by half of the distance difference in a direction close to the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point.
[0097] S410: Obtain a midpoint between the optimized left boundary point and the optimized right boundary point.
[0098] S411, determining a third straight line based on the optimized left boundary point and the optimized right boundary point; and obtaining a fourth straight line that is perpendicular to the third straight line and passes through the midpoint.
[0099] S412, obtaining the orthocenter from the incenter to the fourth straight line as the optimized incenter corresponding to the incenter.
[0100] In a specific implementation, the midpoint between the optimized left boundary point and the optimized right boundary point is obtained. , and the straight line connecting the optimized left boundary point and the optimized right boundary point L 3.
[0101] L 3: .
[0102] According to the geometric characteristics, the incenter should be on the straight line formed by the midpoint of the optimized left boundary point and the optimized right boundary point and the corner point or virtual corner point. L 4 up, L 4 and L 3. Vertically. Move the center point to the line L The orthocenter of 4 is the optimized inward position, and its position is on the straight line L 4 up.
[0103] L 4: ; Among them, C4 is a straight line L 4 coefficients, substitute the midpoint coordinates of the optimized left boundary point and the optimized right boundary point to get C4. Combined with the above formula, the optimized inner center coordinates can be obtained .
[0104] In the embodiment of the present invention, the key point positions in all corner point regions are optimized in a clockwise order. It should be noted that the last corner point region R N The adjacent corner area R1R N-1 For reference.
[0105] S5, obtaining image coordinate information of the optimized key points of the corner point area in the original workpiece image, obtaining world coordinate information of the optimized key points of the corner point area according to the image coordinate information and preset camera calibration parameters, and obtaining size information of the target workpiece based on the world coordinate information.
[0106] In a specific implementation, according to the coordinates of each optimized key point after optimization in the above step S4 and the corresponding cropping and scaling parameters relative to the original image during the processing, the image coordinates of each optimized key point after optimization in the original image can be restored.
[0107] The camera’s intrinsic and extrinsic parameters M1 and M2 are obtained through camera calibration. The specific calibration process is not described in detail. The coordinates of the optimized key points in each corner area of the workpiece after restoration are mapped to obtain the real-world coordinates, which are specifically calculated by the following formula (5).
[0108] ; Among them, Z C is the distance from the preset camera to the inspection platform (or thin steel sheet), u and v represent the coordinates of each key point in the image coordinate system, and X W , Y W , Z W Represents the coordinates of each key point in the real world.
[0109] According to the real-world coordinates, the real size of the workpiece can be calculated according to the distance formula. For example, the real distance between adjacent corner points or virtual corner points is the side length or virtual side length of the side, and the distance from the center of the R angle to the boundary point is the radius of the R angle, etc. This invention will not go into details.
[0110] By applying the technical solution of the embodiment of the present invention, the original workpiece image of the target workpiece is preprocessed to obtain a preprocessed workpiece image, and the workpiece area in the preprocessed workpiece image is obtained based on a preset edge detection model to obtain an image of the region of interest; the corner point area in the image of the region of interest is detected based on a preset first target detection model; the key points of the corner point area are detected based on a preset second target detection model; the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area; the image coordinate information of the optimized key points of the corner point area in the original workpiece image is obtained, and the world coordinate information of the optimized key points of the corner point area is obtained according to the image coordinate information and the preset camera calibration parameters, and the size information of the target workpiece is obtained based on the world coordinate information. The present invention can extract an accurate outer contour from the original workpiece image, mark the key points in each corner point area, accurately locate and fit various special corner point areas of the steel sheet, and finally obtain its accurate position, radius and geometric features, so that the measurement and positioning of the steel sheet with special corner points are more accurate, stable and efficient, and the production efficiency and the workpiece quality inspection process level are improved.
[0111] See also Figure 5 , Figure 5 : is a schematic block diagram of a high-precision workpiece size measurement device 50 with corner points provided by an embodiment of the present invention. Corresponding to the above high-precision workpiece size measurement method with corner points, the present invention also provides a high-precision workpiece size measurement device 50 with corner points. The high-precision workpiece size measurement device 50 with corner points includes a unit for executing the above high-precision workpiece size measurement method with corner points, and the high-precision workpiece size measurement device 50 with corner points can be configured in a desktop computer, a tablet computer, a laptop computer, and other terminals. Specifically, the high-precision workpiece size measurement device 50 with corner points includes:
[0112] A first acquisition unit 51 preprocesses the original workpiece image of the target workpiece to obtain a preprocessed workpiece image, and acquires a workpiece region in the preprocessed workpiece image based on a preset edge detection model to obtain an image of a region of interest;
[0113] A first detection unit 52, configured to detect a corner point region in the region of interest image based on a preset first target detection model;
[0114] A second detection unit 53, configured to detect key points of the corner point area based on a preset second object detection model;
[0115] An optimization unit 54, configured to optimize the key points of the corner point region based on geometric constraint information between the key points of the corner point region to obtain optimized key points of the corner point region;
[0116] The second acquisition unit 55 is used to obtain the image coordinate information of the optimized key points of the corner point area in the original workpiece image, obtain the world coordinate information of the optimized key points of the corner point area according to the image coordinate information and preset camera calibration parameters, and obtain the size information of the target workpiece based on the world coordinate information.
[0117] A further technical solution is that the workpiece region in the preprocessed workpiece image is acquired based on a preset edge detection model to obtain an image of a region of interest, including:
[0118] Acquiring edge information of the preprocessed workpiece image based on a preset edge detection model;
[0119] Acquire the maximum circumscribed rectangle of the edge information to obtain the workpiece area in the preprocessed workpiece image;
[0120] A workpiece region in the preprocessed workpiece image is intercepted to obtain the region of interest image.
[0121] A further technical solution is that the detecting the key points of the corner point area based on the preset second target detection model includes:
[0122] After scaling the corner point region to a preset target size, the region is input into the second target detection model, and the key points of the corner point region are detected by the second target detection model.
[0123] A further technical solution is that the key points of the corner point area include left boundary points, right boundary points, corner points and heart points, and the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area, including:
[0124] Determine a first straight line based on the left boundary point, the corner point of the corner point area, and the corner points of the adjacent corner point area of the corner point area;
[0125] Determine a second straight line based on the right boundary point, the corner point of the corner point area, and the corner points of the corner point area adjacent to the corner point area;
[0126] An intersection point between the first straight line and the second straight line is obtained as an optimized corner point corresponding to the corner point.
[0127] A further technical solution is that the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area, and further includes:
[0128] Obtaining a first distance between the left boundary point and the optimized corner point;
[0129] Acquire a second distance between the right boundary point and the optimized corner point;
[0130] Obtaining a distance difference between the first distance and the second distance;
[0131] Determining whether the distance difference is greater than a preset distance threshold;
[0132] If the distance difference is greater than a preset distance threshold, and the first distance is greater than the second distance, the left boundary point is moved along the first straight line by half of the distance difference in a direction close to the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; the right boundary point is moved along the second straight line by half of the distance difference in a direction away from the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point;
[0133] If the distance difference is greater than a preset distance threshold and the first distance is less than the second distance, the left boundary point is moved along the first straight line by half of the distance difference in a direction away from the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; the right boundary point is moved along the second straight line by half of the distance difference in a direction close to the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point.
[0134] A further technical solution is that the key points of the corner point area are optimized based on the geometric constraint information between the key points of the corner point area to obtain the optimized key points of the corner point area, and further includes:
[0135] Obtaining the midpoint between the optimized left boundary point and the optimized right boundary point;
[0136] Determine a third straight line based on the optimized left boundary point and the optimized right boundary point; obtain a fourth straight line that is perpendicular to the third straight line and passes through the midpoint;
[0137] The orthocenter from the incenter to the fourth straight line is obtained as the optimized incenter corresponding to the incenter.
[0138] A further technical solution is that the preprocessing of the original workpiece image of the target workpiece to obtain the preprocessed workpiece image includes:
[0139] The original workpiece image of the target workpiece is subjected to equalization processing to obtain the preprocessed workpiece image.
[0140] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the above-mentioned high-precision workpiece size measuring device 50 with corner points and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0141] The high-precision measuring device 50 for workpiece dimensions with corner points can be implemented in the form of a computer program. The computer program can be used in Figure 6 Runs on the computer device shown.
[0142] See also Figure 6 , Figure 6 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.
[0143] The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0144] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 can execute a method for high-precision measurement of workpiece dimensions with corner points.
[0145] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0146] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a high-precision measurement method for the size of a workpiece with corner points.
[0147] The network interface 505 is used to communicate with other devices over the network. Those skilled in the art will appreciate that the above structure is only a block diagram of a portion of the structure related to the present application solution, and does not constitute a limitation on the computer device 500 to which the present application solution is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0148] The processor 502 is used to run a computer program 5032 stored in the memory to implement the following steps: steps of a method for high-precision measurement of workpiece dimensions with corner points provided in any of the above method embodiments.
[0149] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0150] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0151] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program. When the computer program is executed by a processor, the processor executes the steps of a high-precision measurement method for workpiece dimensions with corner points provided in any of the above method embodiments.
[0152] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which can store program codes. The computer-readable storage medium can be non-volatile or volatile.
[0153] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0154] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0155] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0156] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0157] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0158] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0159] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A high-precision measurement method for workpiece dimensions with corner points, characterized in that: include: Preprocessing the original workpiece image of the target workpiece to obtain a preprocessed workpiece image, acquiring a workpiece region in the preprocessed workpiece image based on a preset edge detection model, and obtaining an image of a region of interest; Detecting corner point areas in the region of interest image based on a preset first target detection model; Detecting key points of the corner point area based on a preset second target detection model; Based on geometric constraint information between key points in the corner point area, optimizing the key points in the corner point area to obtain optimized key points in the corner point area; Obtaining image coordinate information of the optimized key points of the corner point area in the original workpiece image, obtaining world coordinate information of the optimized key points of the corner point area according to the image coordinate information and preset camera calibration parameters, and obtaining size information of the target workpiece based on the world coordinate information; The key points of the corner point region include a left boundary point, a right boundary point, a corner point, and an inner heart. The key points of the corner point region are optimized based on geometric constraint information between the key points of the corner point region to obtain the optimized key points of the corner point region, including: Determine a first straight line based on the left boundary point, the corner point of the corner point area, and the corner points of the corner point area adjacent to the corner point area; Determine a second straight line based on the right boundary point, the corner point of the corner point area, and the corner points of the corner point area adjacent to the corner point area; Obtaining an intersection point between the first straight line and the second straight line as an optimized corner point corresponding to the corner point; The step of optimizing the key points of the corner point region based on the geometric constraint information between the key points of the corner point region to obtain the optimized key points of the corner point region further includes: Obtaining a first distance between the left boundary point and the optimized corner point; Acquire a second distance between the right boundary point and the optimized corner point; Obtaining a distance difference between the first distance and the second distance; Determining whether the distance difference is greater than a preset distance threshold; If the distance difference is greater than a preset distance threshold, and the first distance is greater than the second distance, the left boundary point is moved along the first straight line by half of the distance difference in a direction close to the optimized corner point to obtain the optimized left boundary point corresponding to the left boundary point; the right boundary point is moved along the second straight line by half of the distance difference in a direction away from the optimized corner point to obtain the optimized right boundary point corresponding to the right boundary point; If the distance difference is greater than a preset distance threshold and the first distance is less than the second distance, the left boundary point is moved along the first straight line in a direction away from the optimized corner point by half of the distance difference to obtain the optimized left boundary point corresponding to the left boundary point; the right boundary point is moved along the second straight line in a direction close to the optimized corner point by half of the distance difference to obtain the optimized right boundary point corresponding to the right boundary point; The step of optimizing the key points of the corner point region based on the geometric constraint information between the key points of the corner point region to obtain the optimized key points of the corner point region further includes: Obtaining the midpoint between the optimized left boundary point and the optimized right boundary point; Determine a third straight line based on the optimized left boundary point and the optimized right boundary point; obtain a fourth straight line that is perpendicular to the third straight line and passes through the midpoint; The orthocenter from the incenter to the fourth straight line is obtained as the optimized incenter corresponding to the incenter.
2. The high-precision measurement method for workpiece dimensions with corner points according to claim 1 is characterized in that: The step of acquiring the workpiece region in the preprocessed workpiece image based on a preset edge detection model to obtain an image of a region of interest includes: Acquiring edge information of the preprocessed workpiece image based on a preset edge detection model; Acquire the maximum circumscribed rectangle of the edge information to obtain the workpiece area in the preprocessed workpiece image; A workpiece region in the preprocessed workpiece image is intercepted to obtain the region of interest image.
3. The high-precision measurement method for workpiece dimensions with corner points according to claim 1 is characterized in that: The detecting the key points of the corner point area based on the preset second target detection model includes: After scaling the corner point region to a preset target size, the region is input into the second target detection model, and the key points of the corner point region are detected by the second target detection model.
4. The high-precision measurement method for workpiece dimensions with corner points according to claim 1, characterized in that: The preprocessing of the original workpiece image of the target workpiece to obtain the preprocessed workpiece image includes: The original workpiece image of the target workpiece is subjected to equalization processing to obtain the preprocessed workpiece image.
5. A high-precision measuring device for workpiece dimensions with corner points, characterized in that: The method comprises a unit for executing the method according to any one of claims 1 to 4.
6. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 can be implemented.
Citation Information
Patent Citations
Workpiece dimension measuring method based on binocular stereo vision
CN110425996A
Image processing method and device and moving tool
CN117765230A