AOI graph template matching method, computer control system and storage medium

Through the AOI graphic template matching method, system calibration, contour extraction and affine transformation technologies are used to solve the problem of matching flexible products in traditional technologies, and achieve higher matching accuracy and efficiency.

CN118967839AActive Publication Date: 2024-11-15广东德智矩阵科技有限公司

Patent Information

Application Number
CN202411458458.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2024-11-15
Estimated Expiration
2044-10-18

AI Technical Summary

Technical Problem

Traditional graphic template matching technology is difficult to match flexible products in the plastic, textile and flexible packaging industries, resulting in problems such as failure of matching, low matching degree and inaccurate calculation of product position and form.

Method used

AOI graphic template matching method is adopted, including system calibration, contour extraction, deformation coefficient setting, virtual generation and affine transformation. Multiple reference models are generated by calculating the distortion and scaling parameters of the product outline, finding the closest figure for matching, and calculating the product Position and angle.

Benefits of technology

It improves the matching accuracy and efficiency of products with different shapes, sizes and texture profiles, and significantly improves the template matching of flexible products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118967839A_ABST
    Figure CN118967839A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of computers, and provides an AOI graph template matching method, a computer control system and a storage medium, the method comprises the steps of system calibration, contour extraction, deformation coefficient, virtual generation and graph matching, a micron-sized calibration plate is adopted, and a camera image is mapped into a world coordinate system; then calculating shape contour features of an actual product and setting a deformation coefficient, wherein the deformation coefficient is composed of parameter distortion and parameter scaling; further generating a plurality of reference models in a database according to the deformation range; and finally, extracting contour information of a to-be-matched product, calculating basic information of each contour edge, searching a closest graph in the reference model as optimal matching, and calculating the position and angle of the product through affine transformation. Therefore, the template matching of products with different shapes, sizes, texture contours and the like is further improved, the precision and efficiency of pattern matching are greatly improved, and the adaptability is extremely high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of visual image processing, and in particular relates to an AOI graphic template matching method, a computer control system and a storage medium. Background Art

[0002] Template matching is a technique used in machine vision inspection (or automatic optical inspection AOI) to find the most matching part of another template image in one image. It is widely used in target positioning, object recognition, object tracking and optical character recognition (OCR). The basic principle of template matching is to compare the template image with the target image to find the most matching area for subsequent processing and production operations. This process involves sliding the template image on the target image and calculating the similarity of each position.

[0003] Traditional pattern template matching technology requires that the pattern template and the actual product shape have similar shapes, sizes, and grayscale differences. However, in the plastics industry, textile industry, flexible packaging industry, and other industries, the shapes, sizes, texture contours, etc. of the same type of products are different. Using traditional pattern matching technology will result in matching failure, low matching degree, inaccurate calculation of product position and morphology, and other problems. Therefore, the present invention aims at the problem of difficult pattern matching of flexible products and proposes a pattern matching method that allows overall and local deformation. Summary of the invention

[0004] The purpose of the present invention is to provide an AOI graphic template matching method, a computer control system and a storage medium, aiming to solve the problems of matching failure, low matching degree, inaccurate calculation of product position and shape, etc. caused by the inability of the prior art to provide an effective deformable graphic template matching method.

[0005] In one aspect, the present invention provides an AOI graphic template matching method, the method comprising the following steps: System calibration: Use a micron-level calibration plate to calibrate the camera's intrinsic parameters, extrinsic parameters, posture, and lens distortion, and map the camera image to the world coordinate system; Contour extraction: calculate the grayscale information on the actual product and extract shape contour features; Deformation coefficient: Set the deformation coefficient of the product shape contour. It can be applied to all contours of the product or set separately for local contours. The deformation coefficient consists of distortion parameters and scaling parameters. Virtual generation: Generate multiple reference models of different sizes and shapes in the database according to the deformation range; Graphics matching: extract the contour information of the product to be matched, calculate the basic information of each contour edge, find the closest graphic in the reference model as the best match, and calculate the position and angle of the product through affine transformation; Among them, the basic information of each contour edge includes length, scanning thickness, direction, and position association.

[0006] In the AOI graphic template matching method of the present invention, the distortion formula is as follows: X-axis is the reference: , ; ; Y axis is the reference: , ; ; in, = x-axis coordinate of target contour; = original contour x-axis coordinate; = y-axis coordinate of target contour; = original contour y-axis coordinate; and Both are distortion transformation matrices.

[0007] In the AOI graphic template matching method of the present invention, the scaling formula is as follows: ; in, The coordinates of the image after scaling The pixel value at ; (x,y) is the pixel value of the original image at coordinate (x,y); δx is the coordinate offset in the x direction; δy is the coordinate offset in the y direction; The offset direction represents scaling; I1, I2, I3 and I4 are the pixel values ​​of the four neighboring pixels of the original image at the coordinate (x, y).

[0008] In the AOI graphic template matching method of the present invention, the affine transformation includes displacement and rotation, and the calculation process is first rotation and then displacement, wherein the rotation formula and the displacement formula are respectively as follows: Rotation formula: x0=(xr x0 )*cos(a)-(yr y0 )*sin(a)+r x0 ; y0=(xr x0 )*sin(a)-(yr y0 )*cos(a)+r y0 ; In the above formula: x and y are the pixel values ​​of the original contour coordinates (x, y); x0 and y0 are the new coordinate values ​​after (x,y) rotation; a is the rotation in radians; r x0 and r y0 is the center of rotation; Rotation formula: x'=x+x t ; y'=y+y t ; In the above formula: x' is the x-axis coordinate of the pixel after displacement; y' is the y-axis coordinate of the pixel after displacement; x is the x-axis coordinate of the original contour pixel; y is the y-axis coordinate of the original contour pixel; x t is the displacement distance in the x-axis direction; y t is the displacement distance in the y-axis direction.

[0009] On the other hand, the present invention also provides a computer control system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0010] On the other hand, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0011] The beneficial effect of the present invention is that, through the steps of extracting product contours, graphic analysis calculations, distortion iterative calculations and finally generating graphic templates, the adaptability of template matching for products with different shapes, sizes and texture contours can be further improved, the accuracy and efficiency of graphic matching are greatly improved, and the template matching degree for flexible products is higher. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 It is a flow chart for realizing the AOI graphic template matching method of the present invention.

[0013] Figure 2 It is a logic flow chart of the AOI graphic template matching method of the present invention when matching the products to be matched. DETAILED DESCRIPTION

[0014] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0015] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments: Embodiment 1

[0016] Figure 1 and 2 The implementation process of the AOI graphic template matching method provided in the first embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows: The AOI graphic template matching method specifically includes: System calibration: Use a micron-level calibration plate to calibrate the camera's intrinsic parameters, extrinsic parameters, posture, and lens distortion, and map the camera image to the world coordinate system; Contour extraction: calculate the grayscale information on the actual product and extract shape contour features; Deformation coefficient setting: Set the deformation coefficient of the product shape contour, which can be applied to all contours of the product or set separately for local contours. The deformation coefficient consists of distortion parameters and scaling parameters; Virtual generation: Generate multiple reference models of different sizes and shapes in the database according to the deformation range; Graphics matching: extract the contour information of the product to be matched, calculate the basic information of each contour edge, find the closest graphic in the reference model as the best match, and calculate the position and angle of the product through affine transformation; Among them, the basic information of each contour edge includes length, scanning thickness, direction, and position association; Specifically, when matching products, the product profile information is first extracted for the products, and then the extracted profile information is matched cyclically with multiple models in the database. If the match is successful, the matching cost is output, and the product is further tested. If the match is unsuccessful, a re-loop matching instruction is output, and the database is entered for repeated matching. If the cyclic matching reaches a certain number of times, the loop is triggered to end. At this time, the information that cannot be matched is marked as an exception, which makes it easier for operators to take corresponding measures.

[0017] In this embodiment, the distortion formula is as follows: X-axis is the reference: , ; ; Y axis is the reference: , ; ; in, = x-axis coordinate of target contour; = original contour x-axis coordinate; = y-axis coordinate of target contour; = original contour y-axis coordinate; and Both are distortion transformation matrices.

[0018] In this embodiment, the scaling formula is as follows: ; in, The coordinates of the image after scaling The pixel value at ; (x,y) is the pixel value of the original image at coordinate (x,y); δx is the coordinate offset in the x direction; δy is the coordinate offset in the y direction; The offset direction represents scaling; I1, I2, I3 and I4 are the pixel values ​​of the four neighboring pixels of the original image at the coordinate (x, y).

[0019] In this embodiment, the affine transformation includes displacement and rotation, and the calculation process is rotation first and then displacement, wherein the rotation formula and the displacement formula are as follows: Rotation formula: x0=(xr x0 )*cos(a)-(yr y0 )*sin(a)+r x0 ; y0=(xr x0 )*sin(a)-(yr y0 )*cos(a)+r y0 ; In the above formula: x and y are the pixel values ​​of the original contour coordinates (x, y); x0 and y0 are the new coordinate values ​​after (x,y) rotation; a is the rotation in radians; r x0 and r y0 is the center of rotation; Rotation formula: x'=x+x t ; y'=y+y t; In the above formula: x' is the x-axis coordinate of the pixel after displacement; y' is the y-axis coordinate of the pixel after displacement; x is the x-axis coordinate of the original contour pixel; y is the y-axis coordinate of the original contour pixel; x t is the displacement distance in the x-axis direction; y t is the displacement distance in the y-axis direction.

[0020] * indicates a multiplication relationship.

[0021] Through the steps of extracting product contours, graphic analysis calculations, distortion iterative calculations and finally generating graphic templates, the adaptability of template matching for products with different shapes, sizes and texture contours can be further improved, which greatly improves the accuracy and efficiency of graphic matching and has a higher template matching degree for flexible products. Embodiment 2

[0022] In an embodiment of the present invention, a computer control system is provided. For ease of description, only parts related to the embodiment of the present invention are shown.

[0023] The computer control system of the embodiment of the present invention comprises a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned AOI graphic template matching method embodiment are implemented.

[0024] In an embodiment of the present invention, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned AOI graphic template matching method embodiment are implemented. Embodiment 3

[0025] The computer-readable storage medium of the embodiment of the present invention may include any entity or device or recording medium capable of carrying computer program code, for example, ROM / RAM, magnetic disk, optical disk, flash memory and other memories.

[0026] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. An AOI graphic template matching method, characterized in that: The method comprises the following steps: System calibration: Use a micron-level calibration plate to calibrate the camera's intrinsic parameters, extrinsic parameters, posture, and lens distortion, and map the camera image to the world coordinate system; Contour extraction: calculate the grayscale information on the actual product and extract shape contour features; Deformation coefficient: Set the deformation coefficient of the product shape contour. It can be applied to all contours of the product or set separately for local contours. The deformation coefficient consists of distortion parameters and scaling parameters. Virtual generation: Generate multiple reference models of different sizes and shapes in the database according to the deformation range; Graphics matching: extract the contour information of the product to be matched, calculate the basic information of each contour edge, find the closest graphic in the reference model as the best match, and calculate the position and angle of the product through affine transformation; Among them, the basic information of each contour edge includes length, scanning thickness, direction, and position association.

2. The AOI graphic template matching method according to claim 1, characterized in that: The twist formula is as follows: X-axis is the reference: , ; ; Y axis is the reference: , ; ; in, = x-axis coordinate of target contour; = original contour x-axis coordinate; = y-axis coordinate of target contour; = original contour y-axis coordinate; and Both are distortion transformation matrices.

3. The AOI graphic template matching method according to claim 2, characterized in that: The scaling formula is as follows: ; in, The coordinates of the image after scaling The pixel value at ; (x,y) is the pixel value of the original image at coordinate (x,y); δx is the coordinate offset in the x direction; δy is the coordinate offset in the y direction; The offset direction represents scaling; I1, I2, I3 and I4 are the pixel values ​​of the four neighboring pixels of the original image at the coordinate (x, y).

4. The AOI graphic template matching method according to claim 3, characterized in that: Affine transformation includes displacement and rotation. The calculation process is rotation first and then displacement. The rotation formula and displacement formula are as follows: Rotation formula: x0=(xr x0 )*cos(a)-(yr y0 )*sin(a)+r x0 ; y0=(x-r x0 )*sin(a)-(y-r y0 )*cos(a)+r y0 ; In the above formula: x and y are the pixel values ​​of the original contour coordinates (x, y); x0 and y0 are the new coordinate values ​​after (x,y) rotation; a is the rotation in radians; r x0 and r y0 is the center of rotation; Rotation formula: x’=x+x t ; y'=y+y t ; In the above formula: x' is the x-axis coordinate of the pixel after displacement; y' is the y-axis coordinate of the pixel after displacement; x is the x-axis coordinate of the original contour pixel; y is the y-axis coordinate of the original contour pixel; x t is the displacement distance in the x-axis direction; y t is the displacement distance in the y-axis direction.

5. A computer control system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Industrial robot visual recognition positioning grabbing method, computer device and computer readable storage medium

    CN110660104A

  • Template matching method based on gradient vector features of edge contour

    CN115131587A

  • All-weather license plate monocular distance measurement method and device based on affine transformation

    CN115713736A

  • Calculation method of line-of-sight direction based on analysis and match of iris contour in human eye image

    US20170293354A1

Cited By

  • Embroidery positioning printing method and device based on machine vision and storage medium

    CN120279238A

  • A machine vision-based embroidery positioning printing method, equipment, and storage medium

    CN120279238B

  • Multi-component object matching method and system based on graph matching

    CN121095607A