A Generative Machine Vision Matching Method

Through the generated machine vision matching method, users can outline custom templates with the mouse, solving the problem that traditional visual matching technology cannot support custom drawing templates, and achieving flexible and convenient visual matching.

CN119850985BActive Publication Date: 2025-05-23SHENZHEN RUIDA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510323167.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-05-23
Estimated Expiration
2045-03-19

AI Technical Summary

Technical Problem

Traditional visual matching technology requires users to provide real images as templates, and cannot support users' need to customize drawing templates.

Method used

Using a generative machine vision matching method, the first pixel node set is generated by outlining the mouse, interpolated to generate the interpolated pixel nodes of the template, calculate the node direction, crop to determine the width and height of the template, compress and merge the sampling hierarchical pixel nodes, and perform image matching.

Benefits of technology

It realizes that without real template pictures, users can visually match custom templates with the mouse, which is suitable for scenes where template pictures are blurred or feature difficult to extract, improving the flexibility and convenience of matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850985B_ABST
    Figure CN119850985B_ABST
Patent Text Reader

Abstract

The present invention discloses a generative machine vision matching method, which belongs to the field of visual matching technology, including calculating the matching degree of the top-level search image based on the node direction of the pixel nodes of the top-level template image and the gradient direction of the pixel nodes of the top-level search image, retaining the result whose matching degree is greater than the user input threshold; based on the matching result of the top-level search image, calculating the matching result of the next-level search image layer by layer, until the calculation of the matching results of all sampling layers of the search image is completed; based on the matching results of all sampling layers of the search image, combining the width and height of the template, drawing a rectangle, and determining the final matching result of the visual matching according to the overlap rate of multiple rectangles. The present invention can support users to draw templates or generate templates of other shapes by mouse outlines or custom generated templates for visual matching without providing real template images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of visual matching, and in particular to a generative machine vision matching method. Background Art

[0002] Visual matching technology is an important component of automated production in the industrial field and is usually used in defect detection, product positioning, intelligent guidance and other aspects. Visual image matching refers to the process of finding the same or similar areas in the target image as the template image by analyzing the similarity and consistency of features such as grayscale, edges, shape structure and correspondence between the template image and the target image. The image pattern matching process generally includes two stages: learning and matching. In the learning stage, the algorithm extracts feature information for image matching from the template image and stores them in the template image in a searchable manner for later use.

[0003] However, traditional visual matching requires users to provide real images taken by the camera for feature extraction to make templates. Template matching can only be performed through existing images, which cannot meet the user's needs for custom drawing templates.

[0004] Therefore, how to provide a visual matching method that can support users to draw templates with the mouse or customize templates of other shapes for visual matching without providing real template images is a technical problem that needs to be urgently solved by technical personnel in this field. Summary of the invention

[0005] To this end, the present invention provides a generative machine vision matching method to solve the problem in the prior art that the user's need for custom drawing templates cannot be met because template matching can only be performed through existing images.

[0006] In order to achieve the above object, the present invention provides the following technical solutions:

[0007] A generative machine vision matching method comprises the following steps:

[0008] Step S1: Based on the mouse outlining method, a plurality of first pixel nodes are generated to obtain a first pixel node set;

[0009] Step S2: interpolating an interpolated pixel node of a template according to two adjacent first pixel nodes in the first pixel node set, and forming a second pixel node with the plurality of interpolated pixel nodes and the first pixel nodes to obtain a second pixel node set;

[0010] Step S3: calculating the node direction of the second pixel node in the second pixel node set;

[0011] Step S4: cropping the second pixel nodes in the second pixel node set and determining the width and height of the template;

[0012] Step S5: taking the second pixel node cropped in step S4 as the pixel node in the top-level template image, and calculating the pixel nodes of the template images at other sampling levels by compression and merging;

[0013] Step S6: based on the search image input by the user, down-sampling is performed to obtain a search image sequence of n sampling levels, and the gradient direction of each pixel node of the search image of each sampling level is calculated;

[0014] Step S7: Based on the node directions of the pixel nodes of the top template image in step S5 and the gradient directions of the pixel nodes of the top search image in step S6, the matching degree of the top search image is calculated, and the results whose matching degree is greater than the user input threshold are retained;

[0015] Step S8: Based on the matching result of the top-level search image, the matching result of the next-level search image is calculated layer by layer, until the matching results of all sampling layers of the search image are calculated;

[0016] Step S9: Based on the matching results of all sampling layers of the search image, a rectangle is drawn in combination with the width and height of the template, and the final matching result of the visual matching is determined according to the overlap rate of multiple rectangles.

[0017] Furthermore, in the step S1, based on the mouse outlining method, a plurality of first pixel nodes are generated to obtain a first pixel node set, specifically:

[0018] The user uses the mouse to draw a template pattern in a blank space, or draws it along the outline of an existing image template;

[0019] Each time the mouse is clicked, a line is drawn between the current pixel point of the mouse and the pixel point clicked last time. At this time, the pixel coordinate position of the node at the moment of the mouse click is recorded as the first pixel node. Multiple first pixel nodes constitute a first pixel node set S.

[0020] Furthermore, in step S2, interpolation pixel nodes of the template are generated according to two adjacent first pixel nodes in the first pixel node set, and multiple interpolation pixel nodes and the first pixel nodes form a second pixel node to obtain a second pixel node set, specifically:

[0021] Based on the first pixel node set S, two adjacent first pixel nodes are taken out, and a pixel node between the two adjacent first pixel nodes is generated as an interpolation pixel node by using a linear interpolation method;

[0022] Traversing all adjacent first pixel nodes in the first pixel node set S to obtain a plurality of interpolation pixel nodes;

[0023] The plurality of interpolation pixel nodes and the first pixel node in the first pixel node set S form a second pixel node, thereby obtaining a second pixel node set P.

[0024] Furthermore, in step S3, the node direction of the second pixel node in the second pixel node set is calculated, specifically:

[0025] If the second pixel node P in the second pixel node set i is the first pixel node, then obtain the second pixel node P i The previous first pixel node and the next first pixel node, the second pixel node P i The calculation formula of the node direction e is:

[0026] ;

[0027] ;

[0028] ;

[0029] Among them, arctan is the inverse trigonometric function of tan, e 0 is the first intermediate angle, e 1 is the second intermediate angle, (x i-1 ,y i-1 ) is the coordinate of the previous first pixel node, (x i ,y i ) is the second pixel node P i The coordinates of (x i+1 ,y i+1 ) is the coordinate of the next first pixel node, P i is the i-th second pixel node in the second pixel node set, i is a positive integer from 0 to m-1, and m is the number of second pixel nodes in the second pixel node set;

[0030] If the second pixel node P in the second pixel node set i is the interpolation pixel node, then obtain the pixel value corresponding to the second pixel node P i Two adjacent first pixel nodes and second pixel node P i The node direction The calculation formula is:

[0031] ;

[0032] Among them, (x 1 ,y 1) is the coordinate of the first pixel point adjacent to the front, (x 2 ,y 2 ) is the coordinate of the first adjacent pixel point.

[0033] Furthermore, in step S4, the second pixel nodes in the second pixel node set are cropped and the width and height of the template are determined, specifically:

[0034] Traverse the second pixel node set P and record the maximum x coordinate value x in the set P max , the minimum x-coordinate value x min , the maximum value of y coordinate y max , minimum y coordinate value y min , the calculation formula for the width w and height h of the generated template is:

[0035] ;

[0036] ;

[0037] For each point P in the second pixel node set P i , perform cropping to obtain the cropped second pixel node P i The corresponding pixel coordinates (P i-x , P i-y ), the calculation formula is:

[0038] ;

[0039] ;

[0040] Among them, (P i-x0 , P i-y0 ) is the second pixel node P before clipping i The corresponding pixel coordinates.

[0041] Furthermore, in step S5, the second pixel node cropped in step S4 is used as the pixel node in the top-level template image, and pixel nodes of template images at other sampling levels are calculated by compression and merging, specifically:

[0042] The user inputs the number of image sampling levels n, and the cropped second pixel node obtained in step S4 is used as the pixel node of the 0th sampling level;

[0043] Compress the pixel nodes at the 0th sampling level until all pixel nodes are compressed, traverse the compressed pixel nodes, and merge the pixel nodes with the same coordinates after compression into a new pixel node;

[0044] The coordinates of the pixel nodes with the same coordinates are taken as the coordinates of the new pixel nodes, and the average value of the node directions of the pixel nodes with the same coordinates is taken as the node direction of the new pixel node. ;

[0045] After all pixel nodes are merged, the merged new pixel nodes and the unprocessed pixel nodes are used as the pixel nodes of the first sampling level;

[0046] The above compression and merging pixel node operations are repeated until the calculation of the n-1th template image sampling level is completed.

[0047] Furthermore, in step S6, based on the search image input by the user, downsampling is performed to obtain a search image sequence of n sampling levels, and the gradient direction of each pixel node of the search image of each sampling level is calculated, specifically:

[0048] According to the sampling level n input by the user in step S5, pyramid downsampling is performed on the input search image I to obtain a search image sequence M of n sampling levels;

[0049] Based on the search image M at each sampling level j , where j is a positive integer from 0 to n-1, and n is the sampling level input by the user. j Gaussian filtering is performed to remove noise, and the Sobel operator is used to calculate the gradients in the x and y directions of the Gaussian filtered image. Then, the gradient direction m corresponding to each pixel node in the search image is calculated. The calculation formula is:

[0050] ;

[0051] Among them, a x and a y They are the gradient sizes in the x and y directions calculated by the Sobel operator for the current pixel node;

[0052] Repeat the above operation and continuously traverse each sampling level until the gradient direction calculation is completed for each pixel node of the search image at each sampling level.

[0053] Furthermore, in step S7, based on the node direction of the pixel node of the top template image in step S5 and the gradient direction of the pixel node of the top search image in step S6, the matching degree of the top search image is calculated, and the result whose matching degree is greater than the user input threshold is retained, specifically:

[0054] Based on the pixel nodes of the top-level template image in step S5, the pixel nodes of the top-level search image are continuously traversed in the form of a sliding window to obtain the matching degree s of the top-level search image, which is calculated as follows:

[0055] ;

[0056] Among them, E v is the node direction of the vth pixel node of the top template image, m v is the gradient direction corresponding to the vth pixel node in the top-level search image, and b is the number of pixel nodes in the top-level template image;

[0057] The matching degree is less than the user input threshold t 0 The corresponding positions are removed, and the remaining positions are the top-level matching positions.

[0058] Furthermore, in step S8, based on the matching results of the top-level search image, the matching results of the next-level search image are calculated layer by layer until the matching results of all sampling layers of the search image are calculated. Specifically, step S7 is repeated to calculate the matching degree of the next-level search image, and the matching degree of the next-level search image is eliminated. 0 The position results are calculated until the matching degree calculation of the n-1th layer search image is completed.

[0059] Furthermore, in step S9, based on the matching results of all sampling layers of the search image, combined with the width and height of the template, a rectangle is drawn, and the final matching result of the visual matching is determined according to the overlap rate of multiple rectangles, specifically:

[0060] The width w and height h obtained in step S4 are used as the width and height of the rectangle, and the position of the matching result calculated in step S8 is used as the center of the rectangle to draw the rectangle. At this time, the rectangle and the matching position result are in a one-to-one correspondence;

[0061] If the area overlap ratio of two rectangles exceeds the area threshold t 1 , then the matching results with lower matching degree in the two rectangles are eliminated;

[0062] Traverse all rectangles until all rectangles meet the overlap requirement, and the final matching result is the final matching result of the visual matching.

[0063] The present invention has the following advantages:

[0064] The present invention generates a plurality of first pixel nodes based on a mouse outlining method to obtain a first pixel node set; interpolates and generates an interpolation pixel node of a template according to two adjacent first pixel nodes in the first pixel node set, and the plurality of interpolation pixel nodes and the first pixel node form a second pixel node to obtain a second pixel node set; calculates the node direction of the second pixel node in the second pixel node set; crops the second pixel nodes in the second pixel node set and determines the width and height of the template; uses the second pixel nodes cropped in step S4 as the pixel nodes in the top-level template image, and calculates the pixel nodes of the template images of other sampling levels through compression and merging; performs down sampling based on a search image input by a user; A search image sequence of n sampling levels is obtained, and the gradient direction of each pixel node of the search image of each sampling level is calculated; based on the node direction of the pixel node of the top template image in step S5 and the gradient direction of the pixel node of the top search image in step S6, the matching degree of the top search image is calculated, and the result with a matching degree greater than a user input threshold is retained; based on the matching result of the top search image, the matching result of the next search image is calculated layer by layer, until the calculation of the matching results of all sampling layers of the search image is completed; based on the matching results of all sampling layers of the search image, a rectangle is drawn in combination with the template width and height, and the final matching result of the visual matching is determined according to the overlap rate of multiple rectangles.

[0065] The present invention proposes a generative visual matching method that can support users to draw templates with the mouse or customize templates of other shapes for visual matching without providing real template images. In scenarios where the template image is fuzzy and it is difficult to extract features, compared with traditional visual matching, the algorithm proposed in the present invention is more flexible and convenient, and can successfully complete template production and matching. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.

[0067] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment of size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.

[0068] Figure 1 A flow chart of a generative machine vision matching method provided by the present invention. DETAILED DESCRIPTION

[0069] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0070] A generative machine vision matching method, such as Figure 1 As shown, the following steps are included:

[0071] Step S1: Based on the mouse outlining method, a plurality of first pixel nodes are generated to obtain a first pixel node set, specifically:

[0072] The user uses the mouse to draw a template pattern in a blank space, or draws it along the outline of an existing image template;

[0073] Each time the mouse is clicked, a line is drawn between the current pixel point of the mouse and the pixel point clicked last time. At this time, the pixel coordinate position of the node at the moment of the mouse click is recorded as the first pixel node. Multiple first pixel nodes constitute a first pixel node set S.

[0074] For example, to generate a square template, the user can use the mouse to click the four corner points of the square in sequence to outline the square, and at this time record the pixel coordinates of the four corners as the first pixel node.

[0075] Step S2: interpolating the interpolated pixel nodes of the template according to two adjacent first pixel nodes in the first pixel node set, and forming a second pixel node with the plurality of interpolated pixel nodes and the first pixel nodes to obtain a second pixel node set, specifically:

[0076] Based on the first pixel node set S, two adjacent first pixel nodes are taken out, and a pixel node between the two adjacent first pixel nodes is generated as an interpolation pixel node by using linear interpolation; for example, the coordinates of the two adjacent first pixel nodes are (0, 1) and (0, 3), respectively, and (0, 2) is generated as the interpolation pixel node by interpolation.

[0077] Traversing all adjacent first pixel nodes in the first pixel node set S to obtain a plurality of interpolation pixel nodes;

[0078] The plurality of interpolation pixel nodes and the first pixel node in the first pixel node set S form a second pixel node, thereby obtaining a second pixel node set P.

[0079] Step S3: Calculate the node direction of the second pixel node in the second pixel node set, specifically:

[0080] If the second pixel node P in the second pixel node set i is the first pixel node S i , then obtain the second pixel node P i Previous first pixel node S i-1 and the next first pixel node S i+1 , the second pixel node P i The calculation formula of the node direction e is:

[0081] ;

[0082] ;

[0083] ;

[0084] Among them, arctan is the inverse trigonometric function of tan, e 0 is the first intermediate angle, e 1 is the second intermediate angle, (x i-1 ,y i-1 ) is the coordinate of the previous first pixel node, (x i ,y i ) is the second pixel node P i The coordinates of (x i+1 ,y i+1 ) is the coordinate of the next first pixel node, P i is the i-th second pixel node in the second pixel node set, i is a positive integer from 0 to m-1, and m is the number of second pixel nodes in the second pixel node set;

[0085] If the second pixel node P in the second pixel node set i is the interpolation pixel node, then obtain the pixel value corresponding to the second pixel node P i Two adjacent first pixel nodes and second pixel node P i The node direction The calculation formula is:

[0086] ;

[0087] Among them, (x 1 ,y 1 ) is the coordinate of the first pixel point adjacent to the front, (x 2 ,y2 ) is the coordinate of the first adjacent pixel point.

[0088] Step S4: cropping the second pixel nodes in the second pixel node set and determining the width and height of the template, specifically:

[0089] Traverse the second pixel node set P and record the maximum x coordinate value x in the set P max , the minimum x-coordinate value x min , the maximum value of y coordinate y max , minimum y coordinate value y min , the calculation formula for the width w and height h of the generated template is:

[0090] ;

[0091] ;

[0092] For each point P in the second pixel node set P i , perform cropping to obtain the cropped second pixel node P i The corresponding pixel coordinates (P i-x , P i-y ), the calculation formula is:

[0093] ;

[0094] ;

[0095] Among them, (P i-x0 , P i-y0 ) is the second pixel node P before clipping i The corresponding pixel coordinates.

[0096] Step S5: Taking the second pixel node cropped in step S4 as the pixel node in the top-level template image, the pixel nodes of the template images at other sampling levels are calculated by compression and merging, specifically:

[0097] The user inputs the number of image sampling levels n, and the cropped second pixel node obtained in step S4 is used as the pixel node of the 0th sampling level;

[0098] Compress the pixel nodes at the 0th sampling level until all pixel nodes are compressed, traverse the compressed pixel nodes, and merge the pixel nodes with the same coordinates after compression into a new pixel node;

[0099] The coordinates of the pixel nodes with the same coordinates are taken as the coordinates of the new pixel nodes, and the average value of the node directions of the pixel nodes with the same coordinates is taken as the node direction of the new pixel node. ;

[0100] in, The calculation formula can be:

[0101] ;

[0102] ;

[0103] .

[0104] After all pixel nodes are merged, the merged new pixel nodes and the unprocessed pixel nodes are used as the pixel nodes of the first sampling level;

[0105] The above compression and merging pixel node operations are repeated until the calculation of the n-1th template image sampling level is completed.

[0106] For the j-th sampling layer (j=0, 1, 2, 3…n-1), let the pixel node set of the next i-1-th sampling layer be Q. First, for each pixel node Q i The coordinates of the compressed image are compressed. The calculation formula of the compressed coordinates is:

[0107] ;

[0108] ;

[0109] Among them, round is the floor rounding function. (Q i-x0 , Q i-y0 ) are the pixel node coordinates before compression.

[0110] For example, the points on the 0th layer are (2, 2), (4, 2), and the coordinates of the 1st layer compressed according to the above formula are (1, 1), (2, 1).

[0111] Among them, the pixel node coordinates of the first layer are obtained by compressing and merging the pixel node coordinates of the 0th layer, the pixel node coordinates of the second layer are obtained by compressing and merging the pixel node coordinates of the first layer, and so on.

[0112] Step S6: Based on the search image input by the user, down-sampling is performed to obtain a search image sequence of n sampling levels, and the gradient direction of each pixel node of the search image of each sampling level is calculated, specifically:

[0113] According to the sampling level n input by the user in step S5, the input search image I is pyramid downsampled to obtain a search image sequence M of n-level sampling levels; the search image is an image containing multiple target template images, and the purpose of visual matching is to find the position of the target template in the search image, where M 0 Corresponding to the 0th layer sampling sequence (i.e., input search image I).

[0114] Based on the search image M at each sampling level j , where j is a positive integer from 0 to n-1, and n is the sampling level input by the user. j Gaussian filtering is performed to remove noise, and the Sobel operator is used to calculate the gradients in the x and y directions of the Gaussian filtered image. Then, the gradient direction m corresponding to each pixel node in the search image is calculated. The calculation formula is: ;

[0115] Among them, a x and a y They are the gradient sizes in the x and y directions calculated by the Sobel operator for the current pixel node;

[0116] Repeat the above operation and continuously traverse each sampling level until the gradient direction calculation is completed for each pixel node of the search image at each sampling level.

[0117] Step S7: Based on the node direction of the pixel nodes of the top template image in step S5 and the gradient direction of the pixel nodes of the top search image in step S6, the matching degree of the top search image is calculated, and the results whose matching degree is greater than the user input threshold are retained, specifically:

[0118] Based on the pixel nodes of the top-level template image in step S5, the pixel nodes of the top-level search image are continuously traversed in the form of a sliding window to obtain the matching degree s of the top-level search image, which is calculated as follows:

[0119] Among them, E v is the node direction of the vth pixel node of the top template image, m v is the gradient direction corresponding to the vth pixel node in the top-level search image, and b is the number of pixel nodes in the top-level template image; E v Specifically, it can be e, or .

[0120] The matching degree is less than the user input threshold t 0 The corresponding positions are removed, and the remaining positions are the top-level matching positions.

[0121] Step S8: Based on the matching results of the top-level search image, calculate the matching results of the next-level search image layer by layer until the matching results of all sampling layers of the search image are calculated. Specifically, repeat step S7 to calculate the matching degree of the next-level search image, and remove the matching results of the next-level search image with a matching degree lower than the user-input threshold t. 0 The position results are calculated until the matching degree calculation of the n-1th layer search image is completed.

[0122] Step S9: Based on the matching results of all sampling layers of the search image, combined with the width and height of the template, a rectangle is drawn, and the final matching result of the visual matching is determined according to the overlap rate of multiple rectangles, specifically:

[0123] The width w and height h obtained in step S4 are used as the width and height of the rectangle, and the position of the matching result calculated in step S8 is used as the center of the rectangle to draw the rectangle. At this time, the rectangle and the matching position result are in a one-to-one correspondence;

[0124] If the area overlap ratio of two rectangles exceeds the area threshold t 1 , then the matching results with lower matching degree in the two rectangles are eliminated; the area threshold t 1 Set by the user, because usually the high overlap of the rectangles means the high overlap of the two objects. In actual applications, users usually only take one if there is more overlap.

[0125] Traverse all rectangles until all rectangles meet the overlap requirement, and the final matching result is the final matching result of the visual matching.

[0126] The present invention proposes a generative visual matching method that can support users to draw templates with the mouse or customize templates of other shapes for visual matching without providing real template images. In scenarios where the template image is fuzzy and it is difficult to extract features, compared with traditional visual matching, the algorithm proposed in the present invention is more flexible and convenient, and can successfully complete template production and matching.

[0127] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.

Claims

1. A generative machine vision matching method, characterized in that: The following steps are involved: Step S1: Based on the mouse outlining method, a plurality of first pixel nodes are generated to obtain a first pixel node set; Step S2: interpolating an interpolated pixel node of a template according to two adjacent first pixel nodes in the first pixel node set, and forming a second pixel node with the plurality of interpolated pixel nodes and the first pixel nodes to obtain a second pixel node set; Step S3: calculating the node direction of the second pixel node in the second pixel node set; Step S4: cropping the second pixel nodes in the second pixel node set and determining the width and height of the template; Step S5: taking the second pixel node cropped in step S4 as the pixel node in the top-level template image, and calculating the pixel nodes of the template images at other sampling levels by compression and merging; Step S6: based on the search image input by the user, down-sampling is performed to obtain a search image sequence of n sampling levels, and the gradient direction of each pixel node of the search image of each sampling level is calculated; Step S7: Based on the node direction of the pixel nodes of the top template image in step S5 and the gradient direction of the pixel nodes of the top search image in step S6, the pixel nodes of the top search image are continuously traversed in the form of a sliding window, and the matching degree s of the top search image is calculated, and the corresponding positions with matching degrees less than the user input threshold t0 are eliminated, and the results with matching degrees greater than the user input threshold t0 are retained. The retained position results are the position results of the top matching; ; Among them, E v is the node direction of the vth pixel node of the top template image, m v is the gradient direction corresponding to the vth pixel node in the top-level search image, and b is the number of pixel nodes in the top-level template image; Step S8: Based on the matching result of the top-level search image, the matching result of the next-level search image is calculated layer by layer, until the matching results of all sampling layers of the search image are calculated; Step S9: Based on the matching results of all sampling layers of the search image, combined with the width and height of the template, a rectangle is drawn, and the final matching result of the visual matching is determined according to the overlap rate of multiple rectangles.

2. The generative machine vision matching method according to claim 1, characterized in that: In the step S1, based on the mouse outlining method, a plurality of first pixel nodes are generated to obtain a first pixel node set, specifically: The user uses the mouse to draw a template pattern in a blank space, or draws it along the outline of an existing image template; Each time the mouse is clicked, a line is drawn between the current pixel point of the mouse and the pixel point clicked last time. At this time, the pixel coordinate position of the node at the moment of the mouse click is recorded as the first pixel node. Multiple first pixel nodes constitute a first pixel node set S.

3. The generative machine vision matching method according to claim 2, characterized in that: In step S2, interpolation pixel nodes of the template are generated according to two adjacent first pixel nodes in the first pixel node set, and multiple interpolation pixel nodes and the first pixel nodes form a second pixel node to obtain a second pixel node set, specifically: Based on the first pixel node set S, two adjacent first pixel nodes are taken out, and a pixel node between the two adjacent first pixel nodes is generated as an interpolation pixel node by using a linear interpolation method; Traversing all adjacent first pixel nodes in the first pixel node set S to obtain a plurality of interpolation pixel nodes; The plurality of interpolation pixel nodes and the first pixel node in the first pixel node set S form a second pixel node, thereby obtaining a second pixel node set P.

4. The generative machine vision matching method according to claim 3, characterized in that: In step S3, the node direction of the second pixel node in the second pixel node set is calculated, specifically: If the second pixel node P in the second pixel node set i is the first pixel node, then obtain the second pixel node P i The previous first pixel node and the next first pixel node, the second pixel node P i The calculation formula of the node direction e is: ; ; ; Among them, arctan is the inverse trigonometric function of tan, e0 is the first intermediate angle, e1 is the second intermediate angle, (x i-1 ,y i-1 ) is the coordinate of the previous first pixel node, (x i ,y i ) is the second pixel node P i The coordinates of (x i+1 ,y i+1 ) is the coordinate of the first pixel node, P i is the i-th second pixel node in the second pixel node set, i is a positive integer from 0 to m-1, and m is the number of second pixel nodes in the second pixel node set; If the second pixel node P in the second pixel node set i is the interpolation pixel node, then obtain the pixel value corresponding to the second pixel node P i Two adjacent first pixel nodes and second pixel node P i The node direction The calculation formula is: ; Among them, (x1, y1) is the coordinate of the first pixel point adjacent to the front, and (x2, y2) is the coordinate of the first pixel point adjacent to the back.

5. The generative machine vision matching method according to claim 4, characterized in that: In step S4, the second pixel nodes in the second pixel node set are cropped and the width and height of the template are determined, specifically: Traverse the second pixel node set P and record the maximum x coordinate value x in the set P max , the minimum x-coordinate value x min , the maximum value of y coordinate y max , minimum y coordinate value y min , the calculation formula for the width w and height h of the generated template is: ; ; For each point P in the second pixel node set P i , perform cropping to obtain the cropped second pixel node P i The corresponding pixel coordinates (P i-x , P i-y ), the calculation formula is: ; ; Among them, (P i-x0 , P i-y0 ) is the second pixel node P before clipping i The corresponding pixel coordinates.

6. The generative machine vision matching method according to claim 5, characterized in that: In step S5, the second pixel node cropped in step S4 is used as the pixel node in the top-level template image, and the pixel nodes of the template images at other sampling levels are calculated by compression and merging, specifically: The user inputs the number of image sampling levels n, and the cropped second pixel node obtained in step S4 is used as the pixel node of the 0th sampling level; Compress the pixel nodes at the 0th sampling level until all pixel nodes are compressed, traverse the compressed pixel nodes, and merge the pixel nodes with the same coordinates after compression into a new pixel node; The coordinates of the pixel nodes with the same coordinates are taken as the coordinates of the new pixel nodes, and the average value of the node directions of the pixel nodes with the same coordinates is taken as the node direction of the new pixel node. ; After all pixel nodes are merged, the merged new pixel nodes and the unprocessed pixel nodes are used as the pixel nodes of the first sampling level; The above compression and merging pixel node operations are repeated until the calculation of the n-1th template image sampling level is completed.

7. The generative machine vision matching method according to claim 6, characterized in that: In step S6, based on the search image input by the user, downsampling is performed to obtain a search image sequence of n sampling levels, and the gradient direction of each pixel node of the search image of each sampling level is calculated, specifically: According to the sampling level n input by the user in step S5, pyramid downsampling is performed on the input search image I to obtain a search image sequence M of n sampling levels; Based on the search image M at each sampling level j , where j is a positive integer from 0 to n-1, and n is the sampling level input by the user. j Gaussian filtering is performed to remove noise, and the Sobel operator is used to calculate the gradients in the x and y directions of the Gaussian filtered image. Then, the gradient direction m corresponding to each pixel node in the search image is calculated. The calculation formula is: ; Among them, a x and a y They are the gradient sizes in the x and y directions calculated by the Sobel operator for the current pixel node; Repeat the above operation and continuously traverse each sampling level until the gradient direction calculation is completed for each pixel node of the search image at each sampling level.

8. The generative machine vision matching method according to claim 7, characterized in that: In the step S8, based on the matching results of the top-level search image, the matching results of the next-level search image are calculated layer by layer until the matching results of all sampling layers of the search image are calculated. Specifically, step S7 is repeated to calculate the matching degree of the next-level search image, and the position results with matching degrees lower than the user-input threshold t0 are eliminated until the matching degree calculation of the n-1th level search image is completed.

9. The generative machine vision matching method according to claim 8, characterized in that: In step S9, based on the matching results of all sampling layers of the search image, combined with the width and height of the template, a rectangle is drawn, and the final matching result of the visual matching is determined according to the overlap rate of multiple rectangles, specifically: The width w and height h obtained in step S4 are used as the width and height of the rectangle, and the position of the matching result calculated in step S8 is used as the center of the rectangle to draw the rectangle. At this time, the rectangle and the matching position result are in a one-to-one correspondence; If the area overlap ratio of two rectangles exceeds the area threshold t1, the matching result with the lower matching degree in the two rectangles is eliminated; Traverse all rectangles until all rectangles meet the overlap requirement, and the final matching result is the final matching result of the visual matching.

Citation Information

Patent Citations

  • Machine vision matching method and device, storage medium and product

    CN118365914A

  • Multi-scale machine vision matching method

    CN119649068A