Method and apparatus for automatically aligning cad bounding boxes with thumbnails
By performing scale normalization processing and multi-parameter coupled iterative correction on the thumbnails, the problem of aligning the CAD detection box with the thumbnail, which relies on manual operation, is solved, achieving high-precision automatic alignment and improving detection stability and consistency.
Patent Information
- Application Number
- CN202511588762.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-03
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2045-11-03
AI Technical Summary
In existing technologies, the alignment of the CAD inspection box with the thumbnail relies on manual operation, which makes the accuracy dependent on the operator's experience, making it difficult to meet the requirements of high precision and automated inspection, and easily leading to misjudgment and omission of components.
By performing scale normalization on the thumbnail to generate a geometric standard image, identifying marker points to select a set of effective reference points, constructing a similarity transformation model, performing multi-parameter coupled iterative correction, optimizing the pose parameters of the CAD detection box, and achieving automatic alignment.
It achieves high-precision automatic alignment between the CAD inspection frame and the thumbnail, eliminating the uncertainty and error accumulation of manual adjustment, improving the stability and consistency of the inspection process, and meeting the requirements of high-efficiency and high-precision inspection.
Smart Images

Figure CN121053179B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to a method and apparatus for automatic alignment and correction of CAD detection boxes and thumbnails. Background Technology
[0002] In the surface mount production line for printed circuit board (PCB) inspection, online automatic optical inspection (AOI) equipment needs to import files through computer-aided design (CAD) programming to draw inspection frames in order to accurately inspect the soldering quality, installation status, and solder paste printing effect of components. The alignment accuracy between the CAD inspection frame and the PCB thumbnail directly determines the accuracy of the inspection results. Image processing technology is the core support for establishing the connection between the two. It can connect the image and the CAD coordinate system through preprocessing, feature extraction, and other means, providing a basis for adjusting the pose of the inspection frame. This is of great significance for ensuring the inspection stability of AOI equipment and reducing the production defect rate.
[0003] However, in current AOI equipment, the alignment of the CAD inspection frame and the thumbnail largely relies on manual operation. Operators must manually adjust the X / Y offset and rotation angle of the inspection frame in the CAD editing interface, achieving a rough alignment through repeated trial and error. This method not only consumes a significant amount of programming time, but the alignment accuracy also depends entirely on the operator's experience, making it prone to frame misalignment due to human error. When inspecting small components or batches of PCBs, fluctuations in the accuracy of manual alignment can directly lead to misjudgments and missed detections, reducing production line efficiency and failing to meet the demands of high-precision, automated inspection. Therefore, achieving multi-parameter coupled alignment correction between the CAD inspection frame and the thumbnail has become a challenging problem for the industry. Summary of the Invention
[0004] This application provides a method and apparatus for automatic alignment and correction of CAD inspection frames and thumbnails, which can realize multi-parameter coupled alignment and correction of CAD inspection frames and thumbnails.
[0005] In a first aspect, this application provides a method for automatic alignment and correction of CAD inspection boxes and thumbnails, including:
[0006] The thumbnail is scaled and normalized to generate a geometrically standard image that matches the CAD coordinate system.
[0007] In the geometric standard image, multiple preset marker points on the thumbnail are identified, and then the set of effective reference points that meet the registration accuracy threshold is selected by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file.
[0008] Based on the image coordinates and CAD theoretical coordinates of the effective reference point set, a similarity transformation model of the coordinate system is constructed to determine the translation, rotation, and scale constraint parameters.
[0009] Extract the pose deviation features of each CAD detection box in the geometric standard image, and then perform multi-parameter coupled iterative correction of the pose of the CAD detection box based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box.
[0010] When the error of the multi-parameter coupled iterative correction converges to a preset threshold, the obtained pose optimization parameters are updated in the CAD detection box attributes to achieve automatic alignment between the CAD detection box and the thumbnail.
[0011] In some embodiments, performing scale normalization on the thumbnail to generate a geometrically standardized image that matches the CAD coordinate system specifically includes:
[0012] Obtain the pixel dimensions of the thumbnail and the coordinate range information of the CAD file;
[0013] Calculate the scale conversion factor based on the coordinate range of the CAD file and the pixel size of the thumbnail, and convert the pixel units of the thumbnail into physical units in the CAD coordinate system;
[0014] The size of the thumbnail is adjusted based on the scale conversion factor so that the thumbnail is consistent with the CAD coordinate system in scale, thereby generating a geometrically standard image.
[0015] In some embodiments, the plurality of marker points refers to two or more marker points.
[0016] In some embodiments, the selection of a set of valid reference points that meets the registration accuracy threshold by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file specifically includes:
[0017] Obtain the image coordinates of each identified point in the geometric standard image;
[0018] Extract the CAD coordinates of the theoretical marker points corresponding to each identification marker point from the CAD file;
[0019] Calculate the spatial Euclidean distance between the image coordinates of each identification marker and the CAD coordinates of the corresponding theoretical marker;
[0020] Set a registration accuracy threshold and include the markers whose spatial Euclidean distance is less than or equal to the threshold into the effective reference point set.
[0021] In some embodiments, constructing a similarity transformation model of the coordinate system based on the image coordinates and CAD theoretical coordinates of the effective reference point set, and determining the translation, rotation, and scale constraint parameters specifically includes:
[0022] Using the image coordinates of the effective reference point set as input and the corresponding CAD theoretical coordinates as output, a similarity transformation model describing the mapping relationship between the two is constructed.
[0023] The translation parameters are determined based on the positional relationship between the effective set of reference points in the image coordinates and the CAD theoretical coordinates.
[0024] The rotation parameters are determined based on the directional differences of the effective reference point set in the two coordinate systems.
[0025] The scale constraint parameters are determined based on the size ratio of the effective reference point set in the two coordinate systems.
[0026] The translation, rotation, and scale constraint parameters are integrated to form a similarity transformation model.
[0027] In some embodiments, extracting the pose deviation features of each CAD detection box in the geometric standard image specifically includes:
[0028] Determine the theoretical pose information of each CAD detection box in the CAD coordinate system, wherein the theoretical pose information includes position coordinates and orientation angle;
[0029] The theoretical pose of the CAD inspection box is mapped to the geometric standard image through an initial transformation to obtain the theoretical mapped pose;
[0030] Obtain the actual display pose of each CAD inspection box in the geometric standard image;
[0031] Calculate the position offset and direction deflection angle between the actual displayed pose and the theoretical mapped pose to determine the pose deviation characteristics of the corresponding CAD detection box in the geometric standard image.
[0032] In some embodiments, the pose of the CAD detection box is corrected by multi-parameter coupled iterative correction based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box, specifically including:
[0033] Using the aforementioned pose deviation characteristics as the initial error, a multi-parameter coupled correction equation is constructed by combining the translation, rotation, and scale constraint parameters in the similarity transformation model;
[0034] Initialize pose correction parameters, including translation correction, rotation correction, and scale correction.
[0035] Apply the correction parameters to the current pose of the CAD inspection box and calculate the corrected pose deviation;
[0036] Adjust the correction parameters based on the updated pose deviation and repeat the iterative calculation;
[0037] When the change in pose deviation after multiple consecutive corrections is less than the set threshold, the iteration is terminated, and the final correction parameters are used as the pose correction parameters of the CAD detection box.
[0038] Secondly, this application provides an automatic alignment and correction device for CAD detection frames and thumbnails, comprising:
[0039] The preprocessing module performs scale normalization on the thumbnails to generate a geometrically standardized image that matches the CAD coordinate system.
[0040] The feature processing module is used to identify multiple preset marker points on the thumbnail in the geometric standard image, and then filter out a set of effective reference points that meet the registration accuracy threshold by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file.
[0041] The feature processing module is also used to construct a similarity transformation model of the coordinate system based on the image coordinates and CAD theoretical coordinates of the effective reference point set, and to determine the translation, rotation and scale constraint parameters.
[0042] The feature processing module is also used to extract the pose deviation features of each CAD detection box in the geometric standard image, and then perform multi-parameter coupled iterative correction of the pose of the CAD detection box based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box.
[0043] The alignment module is used to update the obtained pose optimization parameters to the CAD detection box attributes when the error of the multi-parameter coupled iterative correction converges to a preset threshold, thereby realizing the automatic alignment of the CAD detection box and the thumbnail.
[0044] Thirdly, this application provides a computer device, the computer device including a memory and a processor, the memory storing code, and the processor configured to acquire the code and execute the above-described automatic alignment correction method for CAD detection boxes and thumbnails.
[0045] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described automatic alignment and correction method between the CAD detection box and the thumbnail.
[0046] The technical solutions provided by the embodiments disclosed in this application have the following beneficial effects:
[0047] In this embodiment, the thumbnail is scaled and normalized to generate a geometric standard image that matches the CAD coordinate system. Multiple preset marker points on the thumbnail are identified in the geometric standard image. Then, the spatial Euclidean distance error between the identified marker points and their corresponding theoretical marker points in the CAD file is calculated to filter out a set of valid reference points that meet the registration accuracy threshold. A similarity transformation model of the coordinate system is constructed based on the image coordinates of the valid reference point set and the CAD theoretical coordinates to determine translation, rotation, and scale constraint parameters. The pose deviation features of each CAD detection box in the geometric standard image are extracted. Then, based on the pose deviation features and the similarity transformation model, the pose of the CAD detection box is corrected using multi-parameter coupling iterative correction to obtain the pose correction parameters of the CAD detection box. When the error of the multi-parameter coupling iterative correction converges to a preset threshold, the obtained pose optimization parameters are updated in the CAD detection box attributes to achieve automatic alignment between the CAD detection box and the thumbnail.
[0048] Therefore, this application performs multi-parameter coupled iterative correction of the CAD detection box pose based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box. The obtained pose optimization parameters are then updated in the CAD detection box attributes, thereby achieving automatic alignment between the CAD detection box and the thumbnail. First, a geometric standard image is generated by scaling the thumbnail, ensuring that the physical scale and orientation of the image coordinate system are consistent with the CAD coordinate system, providing a quantifiable basis for pose correction. This process ensures the reliability of subsequent marker point matching and coordinate transformation. Then, preset marker points are identified in the geometric standard image, and a set of effective reference points is selected based on spatial Euclidean distance, enabling subsequent similarity transformations... The model's construction relies entirely on high-confidence data points, effectively avoiding interference from noise points in pose calculation, thus ensuring the accuracy of translation, rotation, and scale parameter solutions. This combination of high-confidence reference point selection and similarity transformation models enables the pose correction of the CAD inspection frame to not only accurately reflect real physical deviations but also unify the constraints of multi-parameter correction, achieving coordinated optimization of translation, rotation, and scale. Finally, through iterative correction, when the error converges to a preset threshold, the optimized pose parameters are directly updated to the CAD inspection frame, achieving automatic alignment between the inspection frame and the thumbnail. This fundamentally eliminates the uncertainty and error accumulation of manual adjustments, ensuring the accuracy and consistency of the inspection frame in PCB inspection scenarios. Overall, the technical advantage of this solution lies in its core approach of mathematical modeling and iterative optimization, combining multi-parameter coupled correction with high-confidence reference point selection. This fundamentally improves the automatic alignment accuracy and stability of the CAD inspection frame during AOI inspection, forming a high-precision, fully automated pose correction method that is unattainable by existing technologies. Attached Figure Description
[0049] Figure 1This is an exemplary flowchart of an automatic alignment and correction method for CAD detection boxes and thumbnails according to some embodiments of this application;
[0050] Figure 2 This is a flowchart illustrating the process of determining a valid set of reference points according to some embodiments of this application;
[0051] Figure 3 This is a schematic diagram of the structure of the CAD detection frame and thumbnail automatic alignment correction device according to some embodiments of this application;
[0052] Figure 4 This is a schematic diagram of the structure of a computer device that implements an automatic alignment and correction method for CAD detection frames and thumbnails according to some embodiments of this application. Detailed Implementation
[0053] To better understand the technical solution of this application, the technical solution of this application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0054] refer to Figure 1 The figure is an exemplary flowchart of an automatic alignment and correction method for CAD detection boxes and thumbnails according to some embodiments of this application. The automatic alignment and correction method for CAD detection boxes and thumbnails mainly includes the following steps:
[0055] In step 101, the thumbnail is scaled to generate a geometric standard image that matches the CAD coordinate system.
[0056] It should be noted that the method in this application is applied to the inspection scenario of printed circuit boards (PCBs) in surface mount technology (SMT) production lines using online automatic optical inspection (AOI) equipment. This equipment is used to inspect the soldering quality, mounting status, and solder paste printing effect of PCB components. CAD programming requires importing CAD files to draw the inspection frame for accurate inspection. In existing operations, the alignment of the CAD inspection frame and the PCB thumbnail often relies on manual adjustment of X / Y offset and rotation angle, which is not only time-consuming but also susceptible to human experience. Alignment deviations can easily lead to missed or misjudged components, affecting batch inspection efficiency and production quality. To solve this problem, it is necessary to achieve accurate alignment between the CAD inspection frame and the thumbnail through automation, ensuring the stability of AOI equipment inspection and meeting the high-efficiency, high-precision inspection requirements of SMT production lines.
[0057] In some embodiments, performing scale normalization on the thumbnail to generate a geometrically standardized image that matches the CAD coordinate system can be achieved through the following steps:
[0058] Obtain the pixel dimensions of the thumbnail and the coordinate range information of the CAD file;
[0059] Calculate the scale conversion factor based on the coordinate range of the CAD file and the pixel size of the thumbnail, and convert the pixel units of the thumbnail into physical units in the CAD coordinate system;
[0060] The size of the thumbnail is adjusted based on the scale conversion factor so that the thumbnail is consistent with the CAD coordinate system in scale, thereby generating a geometrically standard image.
[0061] It should be noted that the scale conversion factor in this application refers to the scaling factor used to convert the thumbnail pixel units to the physical units of the CAD coordinate system; the geometric standard image in this application refers to the standardized image used to provide a unified spatial reference for CAD detection box pose correction, so that the image coordinates can be directly corresponded to the CAD physical coordinates.
[0062] In practice, firstly, for thumbnails stored in PNG or JPG format, the pixel size information of the image is extracted using common image processing libraries (such as OpenCV or Python Imaging Library), where the height of the image represents the number of pixels in the vertical direction and the width represents the number of pixels in the horizontal direction. For CAD files stored in DWG or DXF format, the file content can be read using a CAD parsing library (such as ezdxf or AutoCAD's ObjectARX interface), extracting the coordinate boundary information of all graphic objects in the model space. The minimum X-value, maximum X-value, minimum Y-value, and maximum Y-value of each object are calculated, and the global coordinate range of the CAD file is obtained through traversal and merging. Next, the physical lengths in the X and Y directions are calculated based on the global CAD coordinate range, denoted as Lx and Ly respectively. Then, based on the thumbnail's pixel width Px and pixel height Py, the scale conversion factors Kx and Ky in each direction are calculated, with values equal to Lx / Px and Ly / Py respectively, to represent the proportional relationship between CAD physical units and image pixels. Considering that the origin of the thumbnail's coordinate system is located in the upper left corner and increases vertically downwards, while the origin of the CAD coordinate system is located in the lower left corner and increases vertically upwards, the conversion... During the transformation process, coordinate axis orientation adjustment is required. For any pixel, its position in the thumbnail coordinate system is (u, v), and its physical coordinates (X, Y) in the CAD coordinate system can be calculated through a linear mapping relationship, i.e., X = Xmin + u × Kx, Y = Ymin + (Py - 1 - v) × Ky. This linear mapping achieves orientation unification and scale correspondence between the two coordinate systems. Then, the target pixel size of the scaled image is determined according to the global physical range of CAD and the conversion factor, where the target width is equal to the rounded value of Lx / Kx and the target height is equal to the rounded value of Ly / Ky. When the target size is inconsistent with the original thumbnail size, the thumbnail is scaled using an image interpolation algorithm. Taking bilinear interpolation as an example, this algorithm generates the target pixel value by using the gray-level weighting method of adjacent pixels, which can effectively reduce the jagged effect after scaling. After the scaling operation is performed by the image processing function, the obtained image is the geometrically standard image.
[0063] In step 102, multiple preset marker points on the thumbnail are identified in the geometric standard image, and then the set of effective reference points that meet the registration accuracy threshold is selected by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file.
[0064] In some embodiments, identifying multiple preset marker points on the thumbnail in the geometric standard image refers to locating reference points with known positions or features in the thumbnail using image processing algorithms to establish the correspondence between the image and the CAD coordinate system. Specifically, known image processing algorithms can be used to extract features from the region, including but not limited to edge detection, corner detection, key point descriptor matching, or template matching. Candidate feature points are extracted using these methods, and the image features of the candidate feature points are matched with those of the preset marker points. Matching points are selected based on feature similarity or correlation coefficients, and the selected matching points are used as the preset marker points on the thumbnail.
[0065] In some embodiments, reference Figure 2 As shown in the figure, this is a flowchart illustrating the process of determining the effective reference point set in some embodiments of this application. In this embodiment, the effective reference point set that meets the registration accuracy threshold is selected by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file. This can be achieved through the following steps:
[0066] In step 1021, the image coordinates of each marker point identified in the geometric standard image are obtained;
[0067] In step 1022, the CAD coordinates of the theoretical marker points corresponding to each identification marker point are extracted from the CAD file;
[0068] In step 1023, the spatial Euclidean distance between the image coordinates of each identification marker and the CAD coordinates of the corresponding theoretical marker is calculated;
[0069] In step 1024, a registration accuracy threshold is set, and the markers whose spatial Euclidean distance is less than or equal to the threshold are included in the effective reference point set.
[0070] It should be noted that the effective reference point set in this application refers to the set of high-confidence marker points selected from the correspondence between geometric standard images and CAD coordinates.
[0071] In specific implementation, firstly, the coordinate information of multiple identified marker points in the image coordinate system is obtained from the geometric standard image. Each marker point corresponds to a two-dimensional coordinate vector, which can be obtained through the aforementioned feature extraction and matching algorithms. Secondly, for the theoretical marker points corresponding to each identified marker point in the CAD file, their coordinate information is obtained using well-known CAD parsing tools. For example, for DXF files, all graphic objects or annotation point objects in the model space can be read using the ezdxf library, and the X and Y coordinates of each object can be extracted to form a set of CAD theoretical marker point coordinates. Then, the spatial Euclidean distance between the coordinates of each identified marker point in the geometric standard image and the coordinates of the corresponding CAD theoretical marker point is calculated. That is, the square difference of each dimension coordinate is summed and the square root is taken to obtain the spatial distance error of each pair of marker points. This calculation can be completed using general mathematical function libraries or vector operation tools, such as Python's NumPy library or C++ standard library functions. Finally, a registration accuracy threshold is set according to the system's requirements for registration accuracy. The spatial distance error of each marker point is compared with the threshold, and marker points with errors less than or equal to the threshold are included in the effective reference point set.
[0072] In step 103, a similarity transformation model of the coordinate system is constructed based on the image coordinates and CAD theoretical coordinates of the effective reference point set, and the translation, rotation and scale constraint parameters are determined.
[0073] In some embodiments, the following steps can be used to construct a similarity transformation model of the coordinate system based on the image coordinates and CAD theoretical coordinates of the effective reference point set, and to determine the translation, rotation, and scale constraint parameters:
[0074] Using the image coordinates of the effective reference point set as input and the corresponding CAD theoretical coordinates as output, a similarity transformation model describing the mapping relationship between the two is constructed.
[0075] The translation parameters are determined based on the positional relationship between the effective set of reference points in the image coordinates and the CAD theoretical coordinates.
[0076] The rotation parameters are determined based on the directional differences of the effective reference point set in the two coordinate systems.
[0077] The scale constraint parameters are determined based on the size ratio of the effective reference point set in the two coordinate systems.
[0078] The translation, rotation, and scale constraint parameters are integrated to form a similarity transformation model.
[0079] It should be noted that the similarity transformation model in this application refers to the functional relationship used to map image coordinates to CAD coordinates, maintaining the shape of the graphic unchanged through translation, rotation, and scaling transformations, thus achieving coordinate system uniformity; the translation parameter in this application refers to the amount used in the similarity transformation to move the image coordinates along the X and Y axes to align with the CAD coordinates; the rotation parameter in this application refers to the amount used in the similarity transformation to rotate the image coordinates around the origin by a certain angle to match the direction of the CAD coordinates; the scale constraint parameter in this application refers to the amount used in the similarity transformation to scale the image coordinates proportionally to maintain consistency with the CAD coordinates in size.
[0080] In specific implementation, firstly, a similarity transformation model framework is constructed. This similarity transformation model describes the mapping relationship between image coordinates and CAD coordinates. It allows translation, rotation, and scaling while maintaining the shape of the graphic. For any point in the effective reference point set, its corresponding CAD coordinates can be obtained from the image coordinates through translation, rotation, and scaling transformations, realizing a unified conversion from the image coordinate system to the CAD coordinate system. Secondly, when determining the translation parameters, the initial values of the translation parameters are obtained by calculating the centroid position of the effective reference point set in the image coordinate system and the centroid position of the corresponding theoretical CAD coordinates. These initial values are used for subsequent transformation parameter optimization. Then, the rotation parameters and scale constraint parameters are determined. Rotation parameters are obtained by comparing the directional differences between corresponding point pairs in the image coordinate system and the CAD coordinate system. The average directional difference of multiple point pairs can be used to reduce single-point errors, and can be further adjusted using the least squares optimization method to minimize the error between the mapped image coordinates and CAD coordinates. Scale constraint parameters are obtained by calculating the distance ratio of corresponding point pairs in the effective reference point set in the image coordinates and CAD coordinates. The average ratio of all point pairs is taken to obtain the initial scale, which can be combined with rotation parameter optimization to accurately determine the final scale value. Finally, the optimized translation, rotation, and scale parameters are integrated to form a complete similarity transformation model, realizing the mapping from image coordinates to CAD coordinates. After the model is established, effective reference points can be randomly selected and their image coordinates substituted into the model to calculate the corresponding CAD coordinates. The model coordinates are then compared with the actual CAD coordinates to verify whether the model accuracy meets the preset registration accuracy requirements. If the requirements are not met, the above steps are repeated for iterative optimization until the accuracy requirements are met.
[0081] In step 104, the pose deviation features of each CAD detection box in the geometric standard image are extracted, and then the pose of the CAD detection box is corrected by multi-parameter coupling iterative correction based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box.
[0082] In some embodiments, extracting the pose deviation features of each CAD detection box in the geometric standard image can be achieved using the following steps:
[0083] Determine the theoretical pose information of each CAD detection box in the CAD coordinate system, wherein the theoretical pose information includes position coordinates and orientation angle;
[0084] The theoretical pose of the CAD inspection box is mapped to the geometric standard image through an initial transformation to obtain the theoretical mapped pose;
[0085] Obtain the actual display pose of each CAD inspection box in the geometric standard image;
[0086] Calculate the position offset and direction deflection angle between the actual displayed pose and the theoretical mapped pose to determine the pose deviation characteristics of the corresponding CAD detection box in the geometric standard image.
[0087] It should be noted that the position offset in this application refers to the difference in distance between the actual display center of the CAD detection frame and its theoretical mapping center in the geometric standard image along the horizontal and vertical directions; the direction deflection angle in this application refers to the difference in rotation angle between the actual display direction of the CAD detection frame and its theoretical mapping direction in the geometric standard image; and the pose deviation feature in this application is a feature index that measures the degree of deviation between the actual display pose of the CAD detection frame and its theoretical pose.
[0088] In specific implementation, firstly, the theoretical pose information of the CAD detection box in the CAD coordinate system is obtained. This theoretical pose information includes the center position coordinates and orientation angle of the detection box. This information can be obtained by reading the geometric objects or annotation points of the corresponding detection box in the CAD file. For DWG or DXF format CAD files, well-known CAD parsing tools such as the ezdxf library or the AutoCAD secondary development interface ObjectARX can be used to extract the center coordinates and orientation angle of each detection box. Secondly, the theoretical pose of the CAD detection box is mapped to a geometric standard image through an initial transformation. This initial transformation is based on the translation parameters, rotation parameters, and... in the aforementioned similarity transformation model. Specifically, the scale constraint parameters involve applying a linear transformation formula to the center point coordinates of the CAD coordinates to calculate the image coordinates, and adjusting the orientation angles according to the rotation parameters to obtain the theoretical mapped pose of each detection box in the geometric standard image. Then, the actual display pose of each CAD detection box in the geometric standard image is obtained, which can be achieved through image processing algorithms, such as using edge detection or contour extraction methods to identify the contour of the detection box, and calculating the contour center coordinates and main orientation angles to form the actual display pose data. Finally, the position offset and orientation deflection angle between the actual display pose and the theoretical mapped pose are calculated, and this offset and deflection angle are used as the pose deviation features of the corresponding CAD detection box in the geometric standard image.
[0089] In some embodiments, the pose correction parameters of the CAD detection box can be obtained by performing multi-parameter coupled iterative correction on the pose deviation features and the similarity transformation model, based on the pose deviation features and the similarity transformation model. This can be achieved through the following steps:
[0090] Using the aforementioned pose deviation characteristics as the initial error, a multi-parameter coupled correction equation is constructed by combining the translation, rotation, and scale constraint parameters in the similarity transformation model;
[0091] Initialize pose correction parameters, including translation correction, rotation correction, and scale correction.
[0092] Apply the correction parameters to the current pose of the CAD inspection box and calculate the corrected pose deviation;
[0093] Adjust the correction parameters based on the updated pose deviation and repeat the iterative calculation;
[0094] When the change in pose deviation after multiple consecutive corrections is less than the set threshold, the iteration is terminated, and the final correction parameters are used as the pose correction parameters of the CAD detection box.
[0095] It should be noted that the multi-parameter coupled correction equation in this application refers to a mathematical expression that uses translation, rotation and scale parameters to jointly correct the pose of the CAD inspection box. Its function is to minimize the pose deviation by adjusting each parameter simultaneously, thereby achieving high-precision alignment. The pose correction parameters in this application are used to adjust the position, orientation and scale of the CAD inspection box so that it is precisely aligned with the geometric standard image.
[0096] In specific implementation, firstly, the pose deviation features of each CAD detection box in the geometric standard image, including position offsets ΔX, ΔY, and orientation deflection angle Δθ, are used as initial error inputs. Then, combined with the translation parameters tx, ty, rotation parameter θ, and scale parameter s from the similarity transformation model, a multi-parameter coupled correction equation is constructed. For the current image coordinates (u, v) of the CAD detection box, its corrected coordinates (u', v') can be expressed as: u' = s × [(u + Δux) × cos(θ + Δx)]. θ)-(v+Δuy)×sin(θ+Δθ)]+tx+Δtx,v'=s×[(u+Δux)×sin(θ+Δθ)+(v+Δuy)×cos(θ+Δθ)]+ty+Δty, where Δux and Δuy are the translation correction components in the image coordinate system, Δθ is the rotation correction, Δtx and Δty are the translation offset compensation, s is the scale parameter, θ is the rotation parameter, and tx and ty are the initial translation parameters. This equation explicitly includes translation, rotation, and scale. The three correction quantities are coupled for calculation to ensure the joint correction effect of each correction quantity on the pose deviation. Then, the correction parameters Δux, Δuy, and Δθ are initialized to zero or based on previous estimates. The equation is applied to the current pose of the CAD detection frame, and the corrected pose coordinates (u', v') are calculated through linear algebra and vector operations. Then, the new pose deviations ΔX', ΔY', and Δθ' are calculated by combining the theoretical CAD pose. The calculation can be completed using the Euclidean distance formula and the vector direction difference formula. The correction parameters are adjusted according to the deviation value: Δux←Δux+ΔX', Δuy←Δuy+ΔY', Δθ←Δθ+Δθ'. The iteration is repeated until the deviation change is lower than the preset threshold after multiple iterations. Throughout the process, the joint correction of translation, rotation, and scale is explicitly calculated through the above equations to achieve multi-parameter coupled optimization. The iterative calculation and convergence judgment both adopt well-known iterative optimization methods and convergence criteria. Finally, the Δux, Δuy, and Δθ obtained after the iteration are the pose correction parameters of the CAD detection frame.
[0097] It should be noted that the proposed solution utilizes pose deviation features and a similarity transformation model to construct a multi-parameter coupled iterative correction process, effectively solving the problem of the inability to uniformly handle multi-dimensional errors in CAD detection box pose correction in existing technologies. Existing technologies typically adjust only a single parameter, such as translation or rotation, which easily leads to cumulative errors and local mismatches. In contrast, this solution establishes a multi-parameter correction equation that includes translation, rotation, and scale constraints, using pose deviation features as the initial error input and iteratively updating the correction parameters. This allows the positional offset and orientation deflection angle of the CAD detection box in the geometric standard image to converge synchronously. Through continuous iteration until the change in pose deviation is lower than a preset threshold, the final pose correction parameters ensure the overall accurate alignment of the CAD detection box in translation, rotation, and scale, thereby significantly improving registration accuracy, reducing the risk of pose error accumulation, ensuring high consistency between the thumbnail and the CAD coordinate system, and achieving automated and highly reliable detection box correction. This solves the technical bottleneck of existing technologies in multi-parameter coupled correction and accuracy control.
[0098] In step 105, when the error of the multi-parameter coupled iterative correction converges to a preset threshold, the obtained pose optimization parameters are updated in the CAD detection box attributes to achieve automatic alignment between the CAD detection box and the thumbnail.
[0099] In some embodiments, when the error of the multi-parameter coupled iterative correction converges to a preset threshold, the obtained pose optimization parameters are updated to the CAD detection box attributes to achieve automatic alignment between the CAD detection box and the thumbnail. This means that during the iterative correction process, when the change in pose deviation of the CAD detection box is lower than a preset threshold, the finally calculated translation, rotation, and scale correction parameters are applied to update the attributes of the CAD detection box, thereby completing the automatic and precise alignment of the CAD detection box and the thumbnail in position, orientation, and scale. It should be noted that, in the specific implementation of updating the obtained pose optimization parameters to the CAD detection box attributes to achieve automatic alignment between the CAD detection box and the thumbnail, the final translation correction amount and rotation correction amount obtained from the multi-parameter coupled iterative correction can be used. The translation and scale correction values are used as the updated values of the CAD detection box in the image coordinate system. Then, the corresponding CAD detection box object is accessed through the CAD file parsing interface or CAD secondary development interface. The translation, rotation angle and scale values are written into its attribute fields or transformation matrix. Then, the CAD software or graphics rendering module is called to redraw the updated CAD detection box so that its new position, orientation and size in the geometric standard image reflect the pose correction results. Furthermore, by randomly selecting a number of marker points or key vertices of the detection box, the updated image coordinates are mapped back to the CAD coordinates. The deviation from the theoretical CAD coordinates is calculated to verify whether the alignment accuracy meets the preset threshold. If it does, automatic alignment is completed. Otherwise, the iteration steps can be returned for further optimization.
[0100] On the other hand, in some embodiments, this application provides an automatic alignment and correction device for CAD detection frames and thumbnails, with reference to... Figure 3 The figure is a schematic diagram of the structure of an automatic alignment and correction device for CAD detection frames and thumbnails according to some embodiments of this application. The automatic alignment and correction device for CAD detection frames and thumbnails includes: a preprocessing module 401, a feature processing module 402, and an alignment module 403, which are described below:
[0101] The preprocessing module 401 is used to perform scale normalization processing on the thumbnail to generate a geometric standard image that matches the CAD coordinate system.
[0102] The feature processing module 402 is used to identify multiple preset marker points on the thumbnail in the geometric standard image, and then filter out a set of effective reference points that meet the registration accuracy threshold by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file.
[0103] The feature processing module 402 is also used to construct a similarity transformation model of the coordinate system based on the image coordinates and CAD theoretical coordinates of the effective reference point set, and to determine the translation, rotation and scale constraint parameters.
[0104] The feature processing module 402 is also used to extract the pose deviation features of each CAD detection box in the geometric standard image, and then perform multi-parameter coupled iterative correction of the pose of the CAD detection box based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box.
[0105] The alignment module 403 is used to update the obtained pose optimization parameters to the CAD detection box attributes when the error of the multi-parameter coupled iterative correction converges to a preset threshold, so as to realize the automatic alignment of the CAD detection box and the thumbnail.
[0106] In addition, this application also provides a computer device, the computer device including a memory and a processor, the memory storing code, the processor being configured to acquire the code and execute the above-described automatic alignment correction method for CAD detection boxes and thumbnails.
[0107] In some embodiments, reference Figure 4 This figure is a schematic diagram of the structure of a computer device implementing an automatic alignment and correction method for CAD detection frames and thumbnails according to some embodiments of this application. The automatic alignment and correction method for CAD detection frames and thumbnails in the above embodiments can be achieved through... Figure 4 The computer device shown is used to implement this, and the computer device 500 includes at least one processor 501, a communication bus 502, a memory 503, and at least one communication interface 504.
[0108] Processor 501 can be a general-purpose central processing unit (CPU) or an application-specific integrated circuit (ASIC).
[0109] The communication bus 502 can be used to transmit information between the aforementioned components.
[0110] Memory 503 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.), magnetic disks or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 503 may exist independently and be connected to processor 501 via communication bus 502. Memory 503 may also be integrated with processor 501.
[0111] The memory 503 stores program code that executes the solution of this application, and its execution is controlled by the processor 501. The processor 501 executes the program code stored in the memory 503. The program code may include one or more software modules. In the above embodiment, the automatic alignment and correction method between the CAD detection box and the thumbnail can be implemented by the processor 501 and one or more software modules in the program code in the memory 503.
[0112] Communication interface 504 uses any transceiver-like device to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0113] In a specific implementation, as one example, a computer device may include multiple processors, each of which may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. Here, a processor may refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).
[0114] The aforementioned computer device can be a general-purpose computer device or a special-purpose computer device. In specific implementations, the computer device can be a desktop computer, a portable computer, a network server, a handheld digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device. This application does not limit the type of computer device.
[0115] In addition, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for automatic alignment and correction of CAD detection boxes and thumbnails.
[0116] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0117] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for automatic alignment and correction of CAD inspection boxes and thumbnails, characterized in that, include: The thumbnail is scaled and normalized to generate a geometrically standard image that matches the CAD coordinate system. In the geometric standard image, multiple preset marker points on the thumbnail are identified, and then the set of effective reference points that meet the registration accuracy threshold is selected by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file. Based on the image coordinates and CAD theoretical coordinates of the effective reference point set, a similarity transformation model of the coordinate system is constructed to determine the translation, rotation, and scale constraint parameters. Extract the pose deviation features of each CAD detection box in the geometric standard image, and then perform multi-parameter coupled iterative correction of the pose of the CAD detection box based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box. When the error of the multi-parameter coupled iterative correction converges to a preset threshold, the obtained pose optimization parameters are updated in the CAD detection box attributes to achieve automatic alignment between the CAD detection box and the thumbnail.
2. The method as described in claim 1, characterized in that, Performing scale normalization on the thumbnails to generate a geometrically standardized image that matches the CAD coordinate system specifically includes: Obtain the pixel dimensions of the thumbnail and the coordinate range information of the CAD file; Calculate the scale conversion factor based on the coordinate range of the CAD file and the pixel size of the thumbnail, and convert the pixel units of the thumbnail into physical units in the CAD coordinate system; The size of the thumbnail is adjusted based on the scale conversion factor so that the thumbnail is consistent with the CAD coordinate system in scale, thereby generating a geometrically standard image.
3. The method as described in claim 1, characterized in that, The term "multiple markers" refers to two or more markers.
4. The method as described in claim 1, characterized in that, The effective set of reference points that meets the registration accuracy threshold is selected by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file. Specifically, this includes: Obtain the image coordinates of each identified point in the geometric standard image; Extract the CAD coordinates of the theoretical marker points corresponding to each identification marker point from the CAD file; Calculate the spatial Euclidean distance between the image coordinates of each identification marker and the CAD coordinates of the corresponding theoretical marker; Set a registration accuracy threshold and include the markers whose spatial Euclidean distance is less than or equal to the threshold into the effective reference point set.
5. The method as described in claim 1, characterized in that, Based on the image coordinates and CAD theoretical coordinates of the effective reference point set, a similarity transformation model of the coordinate system is constructed, and the translation, rotation, and scale constraint parameters are determined, specifically including: Using the image coordinates of the effective reference point set as input and the corresponding CAD theoretical coordinates as output, a similarity transformation model describing the mapping relationship between the two is constructed. The translation parameters are determined based on the positional relationship between the effective set of reference points in the image coordinates and the CAD theoretical coordinates. The rotation parameters are determined based on the directional differences of the effective reference point set in the two coordinate systems. The scale constraint parameters are determined based on the size ratio of the effective reference point set in the two coordinate systems. The translation, rotation, and scale constraint parameters are integrated to form a similarity transformation model.
6. The method as described in claim 1, characterized in that, Extracting the pose deviation features of each CAD detection box in the geometric standard image specifically includes: Determine the theoretical pose information of each CAD detection box in the CAD coordinate system, wherein the theoretical pose information includes position coordinates and orientation angle; The theoretical pose of the CAD inspection box is mapped to the geometric standard image through an initial transformation to obtain the theoretical mapped pose; Obtain the actual display pose of each CAD inspection box in the geometric standard image; Calculate the position offset and direction deflection angle between the actual displayed pose and the theoretical mapped pose to determine the pose deviation characteristics of the corresponding CAD detection box in the geometric standard image.
7. The method as described in claim 1, characterized in that, Based on the pose deviation features and the similarity transformation model, the pose of the CAD detection box is corrected using multi-parameter coupled iterative correction. The specific pose correction parameters of the CAD detection box include: Using the aforementioned pose deviation characteristics as the initial error, a multi-parameter coupled correction equation is constructed by combining the translation, rotation, and scale constraint parameters in the similarity transformation model; Initialize pose correction parameters, including translation correction, rotation correction, and scale correction. Apply the correction parameters to the current pose of the CAD inspection box and calculate the corrected pose deviation; Adjust the correction parameters based on the updated pose deviation and repeat the iterative calculation; When the change in pose deviation after multiple consecutive corrections is less than the set threshold, the iteration is terminated, and the final correction parameters are used as the pose correction parameters of the CAD detection box.
8. A device for automatic alignment and correction of CAD detection frames and thumbnails, characterized in that, include: The preprocessing module performs scale normalization on the thumbnails to generate a geometrically standardized image that matches the CAD coordinate system. The feature processing module is used to identify multiple preset marker points on the thumbnail in the geometric standard image, and then filter out a set of effective reference points that meet the registration accuracy threshold by calculating the spatial Euclidean distance error between the identified marker points and the corresponding theoretical marker points in the CAD file. The feature processing module is also used to construct a similarity transformation model of the coordinate system based on the image coordinates and CAD theoretical coordinates of the effective reference point set, and to determine the translation, rotation and scale constraint parameters. The feature processing module is also used to extract the pose deviation features of each CAD detection box in the geometric standard image, and then perform multi-parameter coupled iterative correction of the pose of the CAD detection box based on the pose deviation features and the similarity transformation model to obtain the pose correction parameters of the CAD detection box. The alignment module is used to update the obtained pose optimization parameters to the CAD detection box attributes when the error of the multi-parameter coupled iterative correction converges to a preset threshold, thereby realizing the automatic alignment of the CAD detection box and the thumbnail.
9. A computer device comprising a memory and a processor, the memory storing code, characterized in that, The processor is configured to acquire the code and execute the CAD detection box and thumbnail automatic alignment correction method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the automatic alignment and correction method for CAD detection boxes and thumbnails as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Object pose prediction method based on CAD model
CN110706285A
Method for calibrating position of cutting head of tunneling equipment based on image acquisition
CN120525963A