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

By adopting micron-level calibration, contour extraction and affine transformation processing in AOI graphic template matching, matching failure and inefficiency problems caused by shape and texture differences in traditional technology are solved, and high-precision matching of flexible products is achieved.

CN118967839BActive Publication Date: 2025-01-10广东德智矩阵科技有限公司
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Traditional graphic template matching technology in the plastic, textile and flexible packaging industries has caused failure in matching, low matching degree and inaccurate calculation of product position and shape due to differences in product shape, size and texture profile.

Method used

The AOI graphic template matching method is used to process the image through distortion, scaling and affine transformation to adapt to shape changes by using micron-level calibration, contour extraction, deformation coefficient setting, virtual generation reference model, and affine transformation.

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118967839B_ABST
    Figure CN118967839B_ABST
Patent Text Reader

Abstract

The present invention is applicable to the field of computer technology, and provides an AOI graphic template matching method, a computer control system and a storage medium. The method includes system calibration, contour extraction, deformation coefficient, virtual generation and graphic matching steps, and uses a micron-level calibration plate to map a camera image to a world coordinate system; then calculates the shape contour characteristics of the actual product and sets the deformation coefficient, wherein the deformation coefficient consists of parameter distortion and parameter scaling; further generates multiple reference models in a database according to the deformation range; finally, extracts the contour information of the product to be matched, calculates the basic information of each contour edge, searches the closest graphic in the reference model as the best match, and calculates the position and angle of the product through affine transformation; thereby further improving the template matching of products with different shapes, sizes and texture contours, greatly improving the accuracy and efficiency of graphic matching, and having extremely high adaptability.
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:

[0006] 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;

[0007] Contour extraction: calculate the grayscale information on the actual product and extract shape contour features;

[0008] 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.

[0009] Virtual generation: Generate multiple reference models of different sizes and shapes in the database according to the deformation range;

[0010] 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;

[0011] Among them, the basic information of each contour edge includes length, scanning thickness, direction, and position association.

[0012] In the AOI graphic template matching method of the present invention, the distortion formula is as follows:

[0013] X-axis is the reference: , ;

[0014] ;

[0015] Y axis is the reference: , ;

[0016] ;

[0017] in, = x-axis coordinate of target contour;

[0018] = original contour x-axis coordinate;

[0019] = y-axis coordinate of target contour;

[0020] =y-axis coordinate of the original contour;

[0021] and Both are distortion transformation matrices.

[0022] In the AOI graphic template matching method of the present invention, the scaling formula is as follows:

[0023] ;

[0024] in, is the pixel value of the scaled image at coordinate (x′, y′);

[0025] (x,y) is the pixel value of the original image at coordinate (x,y);

[0026] δx is the coordinate offset in the x direction;

[0027] δy is the coordinate offset in the y direction;

[0028] The offset direction represents scaling;

[0029] I1, I2, I3 and I4 are the pixel values ​​of the four neighboring pixels of the original image at the coordinate (x, y).

[0030] 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:

[0031] Rotation formula:

[0032] x0=(xr x0 )*cos(a)-(yr y0 )*sin(a)+r x0 ;

[0033] y0=(xr x0 )*sin(a)-(yr y0 )*cos(a)+r y0 ;

[0034] In the above formula:

[0035] x and y are the pixel values ​​of the original contour coordinates (x, y);

[0036] x0 and y0 are the new coordinate values ​​after (x,y) rotation;

[0037] a is the rotation in radians;

[0038] r x0 and r y0 is the center of rotation;

[0039] Displacement formula:

[0040] x'=x+x t ;

[0041] y'=y+y t ;

[0042] In the above formula:

[0043] x' is the x-axis coordinate of the pixel after displacement;

[0044] y' is the y-axis coordinate of the pixel after displacement;

[0045] x is the x-axis coordinate of the original contour pixel;

[0046] y is the y-axis coordinate of the original contour pixel;

[0047] x t is the displacement distance in the x-axis direction;

[0048] y t is the displacement distance in the y-axis direction.

[0049] 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.

[0050] 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.

[0051] 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

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

[0053] 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

[0054] 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.

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

[0056] Embodiment 1

[0057] 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:

[0058] The AOI graphic template matching method specifically includes:

[0059] 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;

[0060] Contour extraction: calculate the grayscale information on the actual product and extract shape contour features;

[0061] 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;

[0062] Virtual generation: Generate multiple reference models of different sizes and shapes in the database according to the deformation range;

[0063] 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;

[0064] Among them, the basic information of each contour edge includes length, scanning thickness, direction, and position association;

[0065] 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.

[0066] In this embodiment, the distortion formula is as follows:

[0067] X-axis is the reference: , ;

[0068] ;

[0069] Y axis is the reference: , ;

[0070] ;

[0071] in, = x-axis coordinate of target contour;

[0072] = original contour x-axis coordinate;

[0073] = y-axis coordinate of target contour;

[0074] =y-axis coordinate of the original contour;

[0075] and Both are distortion transformation matrices.

[0076] In this embodiment, the scaling formula is as follows:

[0077] ;

[0078] in, is the pixel value of the scaled image at coordinate (x′, y′);

[0079] (x,y) is the pixel value of the original image at coordinate (x,y);

[0080] δx is the coordinate offset in the x direction;

[0081] δy is the coordinate offset in the y direction;

[0082] The offset direction represents scaling;

[0083] I1, I2, I3 and I4 are the pixel values ​​of the four neighboring pixels of the original image at the coordinate (x, y).

[0084] 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:

[0085] Rotation formula:

[0086] x0=(xr x0 )*cos(a)-(yr y0 )*sin(a)+r x0 ;

[0087] y0=(xr x0 )*sin(a)-(yr y0 )*cos(a)+r y0 ;

[0088] In the above formula:

[0089] x and y are the pixel values ​​of the original contour coordinates (x, y);

[0090] x0 and y0 are the new coordinate values ​​after (x,y) rotation;

[0091] a is the rotation in radians;

[0092] r x0 and r y0 is the center of rotation;

[0093] Displacement formula:

[0094] x'=x+x t ;

[0095] y'=y+yt ;

[0096] In the above formula:

[0097] x' is the x-axis coordinate of the pixel after displacement;

[0098] y' is the y-axis coordinate of the pixel after displacement;

[0099] x is the x-axis coordinate of the original contour pixel;

[0100] y is the y-axis coordinate of the original contour pixel;

[0101] x t is the displacement distance in the x-axis direction;

[0102] y t is the displacement distance in the y-axis direction;

[0103] * indicates a product relationship.

[0104] 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.

[0105] Embodiment 2

[0106] 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.

[0107] 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.

[0108] Embodiment 3

[0109] 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.

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

[0111] 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; The distortion formula is as follows: X-axis is the reference: , ; ; Y axis is the reference: , ; ; In the above formula, = x-axis coordinate of target contour; = original contour x-axis coordinate; = y-axis coordinate of target contour; =y-axis coordinate of the original contour; and All are distortion transformation matrices; The scaling formula is as follows: ; In the above formula, is the pixel value of the scaled image at coordinate (x′, y′); (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 at the coordinate (x, y) of the original image; Among them, 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; Displacement 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.

2. 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 claim 1 are implemented.

3. 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 claim 1 are implemented.

Citation Information

Patent Citations

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

    CN115131587A