Graphical image based position size comparison method

By using a position and size comparison method based on graphic images, and leveraging machine vision and DXF files, automatic detection of holes in connecting components of large spatial truss structures was achieved. This solved the problems of time-consuming, labor-intensive, and error-prone manual inspection, and improved inspection efficiency and quality.

CN114549408BActive Publication Date: 2026-01-06HEBEI UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210029494.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-12
Publication Date
2026-01-06
Estimated Expiration
2042-01-12

AI Technical Summary

Technical Problem

The irregular arrangement of holes on mechanical parts, especially the connecting components of large space truss structures, makes manual inspection time-consuming, labor-intensive, and prone to errors, making it difficult to guarantee processing standards and installation quality.

Method used

A positional size comparison method based on graphic images is adopted. Using machine vision acquisition equipment and DXF graphic files, automatic hole detection is achieved through pixel equivalent calibration, image transformation and coordinate system transformation.

Benefits of technology

It reduces human error, enables rapid and accurate batch testing, lowers costs, and improves the testing efficiency and quality of finished products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114549408B_ABST
    Figure CN114549408B_ABST
Patent Text Reader

Abstract

The application provides a position and size comparison method based on a graphic image, comprising the following steps: obtaining design size through a graphic file, calibrating pixel equivalent, collecting an image file of a processing product, extracting position and size from the processing product image, calculating correction pixel equivalent, converting the position and size of the processing product from a pixel coordinate system to a processing coordinate system, establishing the processing coordinate system, realizing conversion from a world coordinate system to the processing coordinate system, and detecting the precision of the processing workpiece. The application solves the comparison problem between the fitting size data of hole features and the design size data, analyzes the comparison method and error of the position coordinates and diameter size of all the holes after sorting, can quickly and accurately detect the position and size error of hole processing, and saves cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for comparing position and size, and more particularly to a method for comparing position and size based on graphic images. Background Technology

[0002] Mechanical parts are generally manufactured according to design drawings. When the finished products are inspected manually, it is difficult to meet the manufacturing standards and guarantee the installation quality of the mechanical devices. For large-scale space truss structures like iron towers, which have many connecting components, numerous holes need to be machined in irregular positions on these components. The dimensional accuracy of these holes must meet the manufacturing requirements; otherwise, the installation quality will be significantly affected. Manual inspection of such components is time-consuming, labor-intensive, and prone to large errors. Therefore, there is an urgent need for a method that can quickly, accurately, and in batches inspect the contours and dimensions of finished products. Summary of the Invention

[0003] The problem this invention aims to solve is to provide a method for comparing the position and size of graphic images.

[0004] To solve the above-mentioned technical problems, the technical solution provided by the present invention is as follows:

[0005] A method for positional size comparison based on graphic images includes the following steps:

[0006] Step 1: Obtain design dimensions from graphic files: The design dimensions include the number of contour edge points, the number of holes, the center design coordinates and design diameter of each hole, and the design coordinates of each contour edge point;

[0007] Step 2: Pixel equivalent calibration: The calibration board is parallel to the machine vision acquisition device; the pixel equivalent is the ratio K' of the actual length of the calibration line segment to its corresponding pixel distance in the image;

[0008] Step 3: Acquire image files of the finished product: Use the machine vision acquisition device calibrated in Step 2 to acquire image files of the finished product, with the finished product placed parallel to the machine vision acquisition device;

[0009] Step 4: Extract position and size from the finished product image: Extract the number of contour edge points m of the finished product and the number of holes processed. , And detect the pixel coordinates of each contour edge point, the center pixel coordinates of each hole, and the pixel diameter;

[0010] Step 5: Calculate the corrected pixel equivalent :

[0011]

[0012] The distance between the camera and the finished product. For the thickness of the finished product;

[0013] Step 6: Transform the position and size of the finished product from pixel coordinates to machining coordinates: Convert the pixel coordinates of each contour edge point and the center pixel coordinates of each hole of the finished product into coordinates in the world coordinate system.

[0014]

[0015] In the formula Coordinates in the world coordinate system; These are coordinates in the pixel coordinate system;

[0016] Convert the pixel diameter of each hole to the corresponding machining diameter in the world coordinate system;

[0017]

[0018] Step 7: Establish the machining coordinate system:

[0019] Step 7-1: Select point A, which is closest to the X-axis of the world coordinate system, and point B, which is closest to the Y-axis of the world coordinate system;

[0020] Step 7-2: Select an edge point adjacent to point A as point C in a counterclockwise direction; determine whether point B is collinear with points A and C; if so, proceed to step 7-3; otherwise, proceed to step 7-4.

[0021] Step 7-3: Select a point adjacent to point A in a clockwise direction as point C;

[0022] Step 7-4: Calculate the tilt angle :

[0023]

[0024] In the formula, a is the slope of line L1 passing through points A and C;

[0025] Step 7-5: Establish a line L2 that passes through point B and is perpendicular to line L1;

[0026] Step 7-6: Determine the origin of the machining coordinate system by simultaneously solving the equations of line L1 and line L2. Coordinates in the world coordinate system ;

[0027] Step 8: Perform the transformation from the world coordinate system to the machining coordinate system:

[0028]

[0029] In the formula, , , The rotation angle; The origin of the machining coordinate system; The coordinates for the machining coordinate system; Coordinates in the world coordinate system;

[0030] Step 9: Inspect the accuracy of the machined workpiece:

[0031] Step 9-1: Compare the center design coordinates and corresponding center machining coordinates of each hole in the finished product, calculate the position error of each hole one by one, and determine whether it is greater than the preset hole position error value. If the position of a hole is greater than the preset hole position error value, the finished product is determined to be a defective product.

[0032] Step 9-2: Compare the diameter design coordinates and corresponding diameter processing coordinates of each hole in the finished product, calculate the diameter error one by one, and determine whether it is greater than the preset diameter error value. If there is a hole with a diameter error value greater than the preset diameter error value, the finished product is determined to be a defective product.

[0033] Further, in step 1, the design dimensions are obtained by loading a DXF graphic file. Starting from the beginning of the text file, the scan begins with group codes and group values, searching for the start marker of an entity segment. If the read group code is 0 and the group value is EOF, the file scan ends immediately; otherwise, it continues scanning until a group code of 0 and a group value of SECTION appear. When a group code and group value appear as a code segment identifier, if the corresponding group code, group value, and ENTITIES are 2, then that segment is identified as an entity segment, and the scan continues with the next group code and group value. When the read group code is 0, the corresponding group value string is determined. If it is LINE, it indicates that the part contains data related to a straight line; if it is CIRCLE, it indicates that the part contains data related to a circle; if it is POINT, it indicates that the part contains data related to a point.

[0034] Furthermore, in step 2, the calibration plate includes n holes, where n>1, and the average pixel equivalent... The calculation method is as follows:

[0035]

[0036] l i To determine the actual distance between the i-th hole and the (i+1)-th hole on the calibration board, p i Let be the pixel center distance between the i-th hole and the (i+1)-th hole on the calibration board.

[0037] Furthermore, in step 9, the method for calculating the positional error of the hole is as follows:

[0038]

[0039] In the formula, and These are the design coordinates of the hole's center and the machining coordinates of the hole's center, respectively.

[0040] The diameter error is:

[0041]

[0042] In the formula, and These are the design diameter and the machining diameter of the hole, respectively.

[0043] The beneficial effects achieved by adopting the above technical solution are as follows:

[0044] 1. This invention utilizes machine vision images to replace manual inspection of the precision of processed workpieces, thereby reducing errors caused by manual operation;

[0045] Using DXF graphic files for positional dimension comparison enables integrated management of design data and processing quality, reducing waste of manpower and resources and saving costs for factory production. Attached Figure Description

[0046] Figure 1 This is a schematic diagram illustrating the calibration of pixel equivalents in the machine vision acquisition device according to Embodiment 1 of the present invention.

[0047] Figure 2 This is a schematic diagram of the machining coordinate system rotating counterclockwise relative to the world coordinate system in Embodiment 1 of the present invention;

[0048] Figure 3 This is a schematic diagram of the machining coordinate system rotating clockwise relative to the world coordinate system in Embodiment 1 of the present invention;

[0049] Figure 4 The graphic in Embodiment 1 of the present invention is drawn according to the design dimensions in the graphic file;

[0050] Figure 5 This is a schematic diagram illustrating the calculation of hole position error in Embodiment 1 of the present invention;

[0051] Figure 6 This is a schematic diagram illustrating the calculation of hole diameter error in Embodiment 1 of the present invention;

[0052] in:

[0053] 1-Machine vision acquisition equipment; 2-Finished product; 3-Calibration plate position; 4-Workbench plane; 5-Design diameter; 6-Processing diameter. Detailed Implementation

[0054] Example 1:

[0055] A method for positional size comparison based on graphic images includes the following steps:

[0056] Step 1: Obtain design dimensions from graphic files: The design dimensions include the number of contour edge points, the number of holes, the center design coordinates and design diameter of each hole, and the design coordinates of each contour edge point;

[0057] In step 1, the design dimensions are obtained by loading a DXF graphic file. Starting from the beginning of the text file, the scan begins with group codes and group values, searching for the start marker of an entity segment. If the read group code is 0 and the group value is EOF, the file scan ends immediately; otherwise, it continues scanning until a group code of 0 and a group value of SECTION appear. When a group code and group value appear as a code segment identifier, if the corresponding group code, group value, and ENTITIES are 2, then that segment is identified as an entity segment, and the scan continues with the next group code and group value. When the read group code is 0, the corresponding group value string is determined. If it is LINE, it indicates that the part contains data related to a straight line; if it is CIRCLE, it indicates that the part contains data related to a circle; if it is POINT, it indicates that the part contains data related to a point.

[0058] Step 2: Pixel Equivalent Calibration: The calibration board is parallel to the machine vision acquisition device; the pixel equivalent is the ratio of the actual length of the calibration line segment to its corresponding pixel distance in the image. ;

[0059] The calibration board has n holes, where n>1, and the average pixel equivalent is... The calculation method is as follows:

[0060]

[0061] l i To determine the actual distance between the i-th hole and the (i+1)-th hole on the calibration board, p i Let be the pixel center distance between the i-th hole and the (i+1)-th hole on the calibration board.

[0062] Step 3: Acquire image files of the finished product: Use the machine vision acquisition device calibrated in Step 2 to acquire image files of the finished product, with the finished product placed parallel to the machine vision acquisition device;

[0063] Step 4: Extract position and size from the finished product image: Extract the number of contour edge points m of the finished product and the number of holes processed. , And detect the pixel coordinates of each contour edge point, the center pixel coordinates of each hole, and the pixel diameter;

[0064] Step 5: Calculate the corrected pixel equivalent :

[0065]

[0066] The distance between the camera and the finished product. For the thickness of the finished product;

[0067] Step 6: Transform the position and size of the finished product from pixel coordinates to machining coordinates: Convert the pixel coordinates of each contour edge point and the center pixel coordinates of each hole of the finished product into coordinates in the world coordinate system.

[0068]

[0069] In the formula (x w, y w (u,v) represents the coordinates in the world coordinate system; (u,v) represents the coordinates in the pixel coordinate system.

[0070] Convert the pixel diameter of each hole to the corresponding machining diameter in the world coordinate system;

[0071]

[0072] Step 7: Establish the machining coordinate system:

[0073] Step 7-1: Select point A, which is closest to the X-axis of the world coordinate system, and point B, which is closest to the Y-axis of the world coordinate system;

[0074] Step 7-2: Select an edge point adjacent to point A as point C in a counterclockwise direction; determine whether point B is collinear with points A and C; if so, proceed to step 7-3; otherwise, proceed to step 7-4.

[0075] Step 7-3: Select a point adjacent to point A in a clockwise direction as point C;

[0076] Step 7-4: Calculate the tilt angle :

[0077]

[0078] In the formula, a is the slope of line L1 passing through points A and C;

[0079] Step 7-5: Establish a line L2 that passes through point B and is perpendicular to line L1;

[0080] Step 7-6: Determine the origin of the machining coordinate system by simultaneously solving the equations of line L1 and line L2. Coordinates in the world coordinate system ;

[0081] Step 8: Perform the transformation from the world coordinate system to the machining coordinate system:

[0082]

[0083] In the formula, , , The rotation angle; The origin of the machining coordinate system; The coordinates for the machining coordinate system; Coordinates in the world coordinate system;

[0084] Step 9: Inspect the accuracy of the machined workpiece:

[0085] Step 9-1: Compare the center design coordinates and corresponding center machining coordinates of each hole in the finished product, calculate the position error of each hole one by one, and determine whether it is greater than the preset hole position error value. If the position of a hole is greater than the preset hole position error value, the finished product is determined to be a defective product.

[0086] Step 9-2: Compare the diameter design coordinates and corresponding diameter processing coordinates of each hole in the finished product, calculate the diameter error one by one, and determine whether it is greater than the preset diameter error value. If there is a hole with a diameter error value greater than the preset diameter error value, the finished product is determined to be a defective product.

[0087] This embodiment addresses the challenges of large-scale production and limited sample size in the manufacturing of iron tower components. It employs a graphical object-oriented approach to automatically detect the position and dimensions of machined holes in these components. The embodiment utilizes a sub-pixel edge detection algorithm based on Zernike moments for image feature edge extraction. Least squares are used to fit the hole edges, and a pixel clustering method is employed to improve the Hough transform line detection algorithm, resolving the issue of incomplete outer contour line segment recognition. The structure of the DXF file is analyzed, and a dimensional data extraction process is developed. Feature data is converted from pixel coordinates to world coordinates, and then further converted to manufacturing coordinates. This enables the comparison of hole dimensions in iron tower components based on DXF files, allowing for the detection of the position and dimensions of feature holes after machining measurement.

[0088] The pixel equivalent method utilizes a high-precision object of known size. After being photographed by a camera, its pixel dimensions are obtained. The actual physical size corresponding to each pixel unit is calculated, thereby obtaining the correspondence between the actual physical size and the pixel distance. This embodiment uses Hough circle detection to identify each circle on the circular array calibration target. After calculating the center position of each circle, the center pixel distance in the horizontal and vertical directions is obtained. Then, the ratio between the actual physical size and pixel distance between adjacent circle centers is calculated to obtain the pixel equivalent value between adjacent circle centers. To reduce the influence of random errors, this embodiment calculates the average of all pixel equivalent values ​​as the pixel equivalent of the camera under the current plane of the calibration plate. In this embodiment, when the calibration plate is placed on the worktable for calibration, due to the thickness of the workpiece, the plane of the calibration plate and the plane of the workpiece to be measured are not on the same plane. If the pixel equivalent of the calibration plate is directly used for calculation, the average pixel equivalent value calculated at the height of the workpiece surface will be inaccurate. The distance between the camera and the plane of the workpiece to be measured is known to be... The distance between the calibration plane and the plane of the workpiece to be measured is That is, the thickness of the workpiece to be measured. Assume the actual physical dimension is the center distance of any set of circles within the calibration plate plane. The actual physical dimensions of the workpiece inspection plane correspond to: After converting the actual physical dimensions measured by the calibration plate to obtain the actual physical dimensions corresponding to the detection plane of the workpiece, the pixel equivalent value is then calculated. and The transformation relationship is as follows:

[0089]

[0090] Let the pixel distance between each hole on the calibration board be... ,but Average pixel equivalent under group pixel equivalent values The calculation method is as follows:

[0091]

[0092] World Coordinate System (O) w -X w Y w Z w The world coordinate system is the absolute coordinate system in the actual environment, used to describe the camera's position. For ease of workpiece inspection, this paper establishes the world coordinate system directly above the worktable. There is a certain displacement and angular deviation between the world coordinate system and the machining coordinate system; therefore, the world coordinates of the workpiece to be measured need to be transformed to obtain the feature dimension data of the workpiece in the machining coordinate system. First, the world coordinate system is rotated by a specific angle, and then... shaft and After translating a certain distance along the axis, the transformation between the world coordinate system and the workpiece machining coordinate system is achieved. During inspection, the workpiece is typically positioned with either clockwise or counterclockwise offset. A coordinate system is established on the workpiece, assuming the offset angle is... The world coordinate system is The machining coordinate system of the workpiece after transformation is The transformation steps of the workpiece coordinate system are as follows:

[0093] refer to Figures 2-3 The origin of the machining coordinate system is workpiece edge Given the coordinates of a point, find the line. slope :

[0094]

[0095] Incline angle :

[0096]

[0097] The origin of the machining coordinate system can be obtained by solving the simultaneous linear equations. coordinates in world coordinates .

[0098]

[0099]

[0100] In this embodiment, the finished product is a steel tower component. All points of the steel tower component in the world coordinate system are along... Translation in the negative direction of the axis coordinate units, and along Translation in the negative direction of the axis Each coordinate unit rotates all the coordinates of the translated tower components by one angle. This allows for the transformation between the world coordinate system and the workpiece machining coordinate system. The expression for coordinate system transformation is:

[0101]

[0102] When placed counterclockwise, When placed clockwise, it is considered positive. It is negative.

[0103] After completing the coordinate system transformation, calculating the dimensional error of the holes in the tower components is the final step in determining whether the workpiece is qualified. The measurement parameters for the holes in the tower components include the position and diameter of each machined hole on the surface. Only when the positional and diameter errors of each machined hole are within the allowable range can the workpiece be judged as qualified. Different models of tower components have different designed hole positions and diameters. To ensure that the calculated error values ​​for each hole have true reference value, before calculating the error for each hole, the sequence of each hole extracted from the image recognition and DXF file should be matched. This embodiment uses the workpiece machining coordinate system origin of the recognized image to align and match the design coordinate system origin in the DXF file. This comparison method is more consistent with the actual situation of workpiece machining in the factory. Ideally, the origin and coordinate axis directions of the workpiece machining coordinate system and the design coordinate system in the DXF file are the same. However, due to factors such as non-standard machining of the steel plate edges of the tower components or misalignment of the workpiece with the top plate during machining and installation, the workpiece machining coordinate system and the DXF file coordinate system may not completely coincide, causing inspection errors. The sorting method for all measuring holes is as follows: first, arrange the hole numbers in ascending order according to the magnitude of the horizontal coordinate value of each hole's center, and then arrange them in descending order according to the vertical coordinate value.

[0104] The hole position error is calculated as follows:

[0105]

[0106] In practice, the origin and coordinate axes of the workpiece's machining coordinate system and the DXF file's design coordinate system are...

[0107] The two coordinate systems are not completely coincident; there is an angular error and a displacement error between them. The errors are calculated below:

[0108] Assume the angle between the two coordinate systems is The position of the circular hole is detected in the center position of the circle in the workpiece machining coordinate system. The coordinates of this element in the DXF file design coordinate system are calculated as follows:

[0109]

[0110] The hole position error is calculated as follows:

[0111]

[0112] After calculating the positional errors of each hole in the workpiece, the maximum error of the hole is used as the criterion for whether the hole is qualified.

[0113] Based on the criteria, each hole is judged. When the error value is greater than the maximum error of 0.5mm, the hole is judged to be unqualified, and the workpiece to be tested is a defective product.

[0114] Hole diameter measurement involves calculating the error value of each hole's diameter, and then determining the magnitude of the calculated error.

[0115] Whether the hole diameter is within the allowable range is used to determine if it is acceptable. Assume the hole diameter in the workpiece's DXF file and the inspection hole diameter are respectively... and Then the diameter error is:

[0116]

Claims

1. A method of position size comparison based on a graphical image, characterized by, The method comprises the following steps: Step 1: obtaining design size through a graphic file: the design size comprises the number of contour edge points, the design number o of holes, the center design coordinates and design diameter of each hole, and the design coordinates of each contour edge point; Step 2: calibrating pixel equivalent: a calibration plate is parallel to a machine vision acquisition device; the pixel equivalent is the ratio K' of the actual length of a calibration line segment to the corresponding pixel distance in an image; Step 3: acquiring an image file of a processed product: using the machine vision acquisition device calibrated in the step 2 to acquire an image file of a processed product, the processed product being placed parallel to the machine vision acquisition device; Step 4: Extracting position and size from the processed product image: extracting the number m of contour edge points of the processed product, the number of processed holes , , and detecting the pixel coordinates of each contour edge point, the center pixel coordinates of each hole, and the pixel diameter; Step 5: Calculate the corrected pixel equivalent : for the distance of the camera from the processed product, for the thickness of the processed product; Step 6: converting the position and size of the processed product from a pixel coordinate system to a processing coordinate system: converting the pixel coordinates of each contour edge point and the center pixel coordinates of each hole into coordinates in a world coordinate system: where (x w, y w ) are coordinates in the world coordinate system; (u, v) are coordinates in the pixel coordinate system; converting the pixel diameter of each hole into the corresponding processing diameter in the world coordinate system; Step 7: establishing a processing coordinate system: Step 7-1: selecting a point A closest to the X axis of the world coordinate system and a point B closest to the Y axis of the world coordinate system; Step 7-2: selecting an edge point adjacent to the point A as a point C in a counterclockwise direction; judging whether the point B is collinear with the point A and the point C; if yes, turning to step 7-3, otherwise, turning to step 7-4; Step 7-3: selecting a point adjacent to the point A as a point C in a clockwise direction; Step 7-4: Calculate the tilt angle : wherein a is the slope of a straight line L1 passing through the point A and the point C; Step 7-5: establishing a straight line L2 passing through the point B and being perpendicular to the straight line L1; Step 7-6: Find the origin of the machining coordinate system by intersecting the straight line L1 and the straight line L2 In the coordinate system of the world coordinate system ; Step 8: realizing the conversion from the world coordinate system to the processing coordinate system: In the formula, , , is a rotation angle; is an origin of a machining coordinate system; is a coordinate of the machining coordinate system; is a coordinate of a world coordinate system; Step 9: detecting the precision of the processed workpiece: Step 9-1: comparing the center design coordinates of each hole of the processed product with the corresponding center processing coordinates, calculating the position error of each hole one by one, and judging whether it is greater than a preset hole position error value; if the position of a hole greater than the preset hole position error value appears, the processed product is determined to be an unqualified product; Step 9-2: comparing the diameter design coordinates of each hole of the processed product with the corresponding diameter processing coordinates, calculating the diameter error one by one, and judging whether it is greater than a preset diameter error value; if a hole greater than the preset diameter error value appears, the processed product is determined to be an unqualified product.

2. The method of claim 1, wherein, In the step 1, the design size is obtained by loading a DXF graphic file, starting from scanning the group code and group value at the beginning of the text file, searching for the start mark of the entity section, if the read group code is 0 and the group value is EOF, the file scanning is immediately ended, otherwise, the scanning is continued until the group code is 0 and the group value is SECTION; When the group code and the group value are the code section identifier, if the corresponding group code and group value of this part are 2 and ENTITIES, the section is determined to be an entity section, and the following group code and group value are continuously read; when the read group code is 0, the corresponding group value string is judged, if it is LINE, it indicates that this part is the related data information of a straight line; if it is CIRCLE, it indicates that this part is the related data information of a circle; if it is POINT, it indicates that this part is the related data information of a point.

3. The method of claim 1, wherein: The calibration plate comprises n holes, n > 1, average pixel equivalent The calculation is as follows: l i pi+1= actual distance between the i-th and i+1-th holes on the calibration plate i pi+1= pixel center distance between the i-th and i+1-th holes on the calibration plate 4. The method of claim 1, wherein: The method for calculating the position error of the hole is: wherein and are the center design coordinates of the hole and the center machining coordinates of the hole, respectively; The diameter error is: wherein and D and d are the design diameter and the machined diameter of the hole, respectively.

Citation Information

Patent Citations

  • Machine vision process

    GB8726633D0

  • Visual line direction estimation system, visual line direction estimation method and visual line direction estimation program

    JP2016173313A