Template information acquisition method, device and computer readable storage medium

By using pyramid images and Canny operators to extract edge information and automatically calculate thresholds in the machine vision system, the problem of manually setting pixel point comparison values ​​affecting positioning accuracy in the existing technology is solved, and the accuracy of template information acquisition and matching positioning are improved. accuracy.

CN113409344BActive Publication Date: 2024-08-30SHENZHEN INOVANCE TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202110514524.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-11
Publication Date
2024-08-30
Estimated Expiration
2041-05-11

AI Technical Summary

Technical Problem

During the offline training process of existing contour-based matching and positioning methods, the positioning accuracy is affected due to improper comparison values ​​of manually specified pixel points.

Method used

By creating several layers of pyramid images, extract the gradient information of each layer of pyramid images, generate high thresholds and low thresholds, obtain edge position points, and generate a gradient information list, including a gradient position, direction and amplitude list, using the Canny operator and The mask image eliminates interfering edge points and automatically calculates thresholds to improve the accuracy of edge location points.

Benefits of technology

It improves the accuracy of template information and matching positioning, reduces manual intervention, and enhances the automation and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113409344B
    Figure CN113409344B
Patent Text Reader

Abstract

The present invention provides a template information acquisition method, device and computer-readable storage medium, the method comprising: creating several layers of pyramid images according to a template image, and extracting gradient information of each layer of pyramid images to form template information for image recognition, and the extraction of template gradient information of each layer of pyramid images to form template information for image recognition comprises: generating a median value of the gradient amplitude of the current layer according to the gradient amplitude of each pixel point in the current layer pyramid image, and generating a high threshold and a low threshold according to the median value of the gradient amplitude of the current layer; acquiring edge position points according to the high threshold and the low threshold, and generating gradient information of the current layer pyramid image according to the edge position points. By automatically generating a list for determining edge position points through each layer of pyramid images, the accuracy of template information can be greatly improved, thereby improving the progress of matching positioning points.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of machine vision, and more specifically, to a template information acquisition method, device and computer-readable storage medium. Background Art

[0002] In various automation equipment, the method of directly providing high-precision positioning through mechanical structure has very high requirements for mechanical processing, installation and debugging, and is costly. By installing a vision system in the automation equipment and using the machine vision system to provide positioning, it has the advantages of low cost, simple application, high flexibility, and strong adaptability.

[0003] In machine vision systems, commonly used matching and positioning methods include grayscale-based, feature point-based, and contour-based matching methods. Grayscale-based matching methods directly use grayscale information, which requires large amounts of calculation, slow speed, and high requirements for image consistency; feature point-based matching methods require feature points with specific structures, which are complex to calculate and not very versatile; contour-based matching technology uses contour edge information, which requires small amounts of calculation, stable matching results, and high accuracy.

[0004] Contour-based matching technology is the most commonly used positioning method. Since the contour edge of the image contains the most important information in the image, it is not easily disturbed by various internal and external factors, and has high stability and consistency. The edge gradient of the image is also very convenient when processing translation, scaling, rotation, etc., without complex image operations, and only simple geometric transformation operations are required. Using the edge gradient of the image contour for matching and positioning is the most commonly used and effective technology among various matching and positioning methods. Due to its simple calculation, strong anti-interference ability, stable and reliable matching results, easy parallel acceleration, simple processing of rotation and scaling, etc., it has become the most common standard method in the field of machine vision.

[0005] like Figure 1 As shown, the existing matching and positioning scheme using the edge gradient of the image contour includes an offline training and an online matching process. In the offline training process, a template image containing specific image features undergoes a training process to obtain template information; in the online matching process, the above template information and the target image are used to undergo a matching process, and finally the matching position of the template feature in the target image is obtained.

[0006] During the offline training process of the above-mentioned contour-based matching positioning scheme, it is necessary to manually specify the comparison value of the pixel points to obtain the edge position points. Since the color, contrast, etc. of each template image are different, it is very easy to affect the positioning accuracy due to improper comparison value setting. Summary of the invention

[0007] The embodiments of the present invention provide a template information acquisition method, device and computer-readable storage medium to address the problem that the positioning accuracy is affected by manually specifying the comparison values ​​of pixel points during the offline training process of the above-mentioned contour-based matching positioning solution.

[0008] The technical solution to solve the above technical problem is to provide a template information acquisition method, including:

[0009] Creating a plurality of layers of pyramid images according to the template image, and extracting gradient information of each layer of the pyramid image to form template information for image recognition, wherein extracting the template gradient information of each layer of the pyramid image to form template information for image recognition includes:

[0010] Generate a median value of the gradient amplitude of the current layer according to the gradient amplitude of each pixel in the pyramid image of the current layer, and generate a high threshold and a low threshold according to the median value of the gradient amplitude of the current layer;

[0011] An edge position point is acquired according to the high threshold and the low threshold, and gradient information of a pyramid image of a current layer is generated according to the edge position point, wherein the gradient information of the pyramid image of the current layer includes a gradient position list, a gradient direction list, and a gradient magnitude list, wherein the gradient position list includes the coordinates of each edge position point, the gradient direction list includes the gradient direction of each edge position point, and the gradient magnitude list includes the gradient magnitude of each edge position point.

[0012] Preferably, the method further comprises:

[0013] Generate a first mask image according to the gradient information of the bottom pyramid image, wherein the first mask image is formed by dilating edge position points in the bottom pyramid image;

[0014] For each layer of pyramid image, the first mask image is used to eliminate interference edge position points in each layer of pyramid image.

[0015] Preferably, acquiring edge position points according to the high threshold and the low threshold comprises:

[0016] For the current pyramid image, use the Canny operator to perform edge extraction calculations to obtain all edge pixel points that meet the high threshold and low threshold requirements;

[0017] A connected domain operation is performed on the edge pixel points to obtain a plurality of independent edge curve segments, and edge pixel points on the edge curve segments that meet preset conditions are used as edge position points.

[0018] Preferably, the step of taking edge pixel points on edge curve segments meeting preset conditions as edge position points comprises:

[0019] taking an edge curve segment whose length is not less than a first preset length as a candidate edge curve segment;

[0020] When the sum of the lengths of all candidate edge curve segments is greater than a second preset length, redundant edge pixels in the candidate edge curve segments are deleted, and all edge pixels on the candidate edge curve segments after the redundant edge pixels are deleted are used as edge position points.

[0021] Preferably, the deleting redundant edge pixels in the candidate edge curve segment comprises:

[0022] A preset number of adjacent edge pixel points on the candidate edge curve segment are used as pixel points to be processed, and the curvature at each pixel point to be processed and the average curvature of all pixel points to be processed are obtained;

[0023] All the pixels to be processed whose curvature is not closest to the average curvature are deleted as redundant edge pixels.

[0024] Preferably, the deleting redundant edge pixels in the candidate edge curve segment comprises:

[0025] A preset number of adjacent edge pixel points on the candidate edge curve segment are used as pixel points to be processed, and the gradient amplitudes of all the pixel points to be processed are compared;

[0026] All pixels to be processed whose gradient amplitude is not the largest are deleted as redundant edge pixels.

[0027] Preferably, generating the current layer gradient amplitude median according to the gradient amplitude of each pixel in the current layer pyramid image includes:

[0028] Get the gradient magnitude of each pixel in the current layer pyramid image;

[0029] Create a magnitude histogram based on the gradient magnitudes of all pixels in the current layer pyramid image;

[0030] The current layer gradient amplitude median is generated according to the amplitude histogram.

[0031] Preferably, the method further comprises:

[0032] generating a second mask image according to external input information, wherein the external input information includes a designated image area on the template image;

[0033] For each layer of pyramid image, the second mask image is used to eliminate interference edge position points in each layer of pyramid image.

[0034] An embodiment of the present invention further provides a template information acquisition device, comprising a memory and a processor, wherein the memory stores a computer program executable in the processor, and when the processor executes the computer program, the steps of the template information acquisition method as described in any one of the above items are implemented.

[0035] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the steps of any of the above template information acquisition methods.

[0036] The template information acquisition method, device and computer-readable storage medium of the embodiment of the present invention can greatly improve the accuracy of template information and thus improve the matching and positioning point progress by automatically generating a list for determining edge position points through each layer of pyramid image. The present invention can further improve the accuracy of template information by excluding interfering edge position points in each pyramid image through a first mask image formed by dilating the edge position points of the bottom pyramid image. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a schematic diagram of a matching and positioning scheme using the edge gradient of the image contour;

[0038] Figure 2 is a schematic diagram of a flow chart of a method for obtaining template information provided by an embodiment of the present invention;

[0039] Figure 3 It is a schematic diagram of the process of obtaining the median value of the gradient amplitude of the current layer in the template information acquisition method provided in an embodiment of the present invention;

[0040] Figure 4 It is a schematic diagram of the process of obtaining edge position points according to edge curve segments in the template information obtaining method provided by an embodiment of the present invention;

[0041] Figure 5 It is a schematic diagram of a process of generating gradient information of a pyramid image of a current layer in a template information acquisition method provided by an embodiment of the present invention;

[0042] Figure 6 is a schematic diagram of eliminating interference points in the template information acquisition method provided by an embodiment of the present invention;

[0043] Figure 7 It is a schematic diagram of a template information acquisition device provided by an embodiment of the present invention. DETAILED DESCRIPTION

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

[0045] The template information acquisition method of the present invention can be applied to a machine vision system based on edge gradient matching. On the basis of traditional pyramid strategy matching, when extracting edge information from a template image, a method of automatically calculating the Canny edge high and low thresholds is used to extract edge position points, thereby greatly improving the accuracy of the template information.

[0046] like Figure 2 FIG. 1 is a flow chart of a method for obtaining template information provided by an embodiment of the present invention, wherein the method generates template information corresponding to a template image in a visual system through template training. The method of the present embodiment obtains template information for image recognition by creating several layers of pyramid images and extracting gradient information of each layer of pyramid images. Specifically, the method of the present embodiment comprises the following steps:

[0047] Step S21: Acquire the template image as the current layer pyramid image, that is, take the template image as the bottom layer of the pyramid image, and set the number of pyramid layers to one. The above template image can be generated by photographing with a camera, and it contains specific image features. Of course, in practical applications, the template image can also be generated by other means, such as directly drawn by graphics software.

[0048] Step S22: determining whether the size of the pyramid image of the current layer is smaller than the first preset size Smin, and executing step S27 if the size of the pyramid image of the current layer is smaller than the first preset size Smin, otherwise executing step S23.

[0049] In this step, the image length and width can be used as the size of the current layer pyramid image for determination. In practical applications, the maximum and minimum position spacing of edge points in the current layer pyramid image can also be used as the size of the current layer pyramid image.

[0050] The first preset size Smin can be set to a fixed value, or can be adjusted automatically or manually according to actual applications. For example, the first preset size Smin can be set according to the size of the template image itself, the position matching accuracy requirement of the machine vision system, etc. It is only necessary to ensure that the number of edge position points in the current layer pyramid image is not too small, so that the matching will not be completed during online matching due to too little template information.

[0051] Step S23: generating a median value of the gradient amplitude of the current layer according to the gradient amplitude of each pixel in the pyramid image of the current layer, and generating a high threshold and a low threshold according to the median value of the gradient amplitude of the current layer.

[0052] In this step, the grayscale gradient of each pixel in the pyramid image of the current layer in the x and y directions (i.e., two directions perpendicular to each other in the pyramid image of the current layer) is first calculated by the Sobel operator, and then the gradients in the x and y directions calculated by the Sobel operator are transformed into polar coordinates to obtain the gradient direction and gradient amplitude of each pixel. Among them, the Sobel operator is a relatively common method for calculating image gradients, which will not be described here. In practical applications, other common methods for calculating image gradients can also be used to obtain the gradient amplitude of each pixel in the pyramid image of the current layer.

[0053] After obtaining the gradient amplitude of each pixel in the current layer pyramid image, the median value of the gradient amplitude of the current layer pyramid image is obtained according to the gradient amplitude of each pixel, and the high threshold and the low threshold for the Canny edge detection algorithm are generated. Specifically, the high threshold may be the product of the median value of the gradient amplitude and the first coefficient, and the low threshold may be the product of the median value of the gradient amplitude and the second coefficient, wherein the first coefficient and the second coefficient are numbers greater than zero and less than 1, respectively, and the first coefficient is greater than the value of the second coefficient. The first coefficient and the second coefficient may be set in advance based on experience. For example, in one embodiment of the present invention, the first coefficient may be set to 0.9 and the second coefficient to 0.7.

[0054] In the above manner, there is no need to manually set the high threshold and the low threshold of the Canny edge detection algorithm. Instead, the high threshold and the low threshold of the Canny edge detection algorithm are automatically generated according to the features of each pixel in the current layer pyramid image, so that the high threshold and the low threshold are adapted to the features (including shape, color, etc.) of the current layer pyramid image.

[0055] Step S24: acquiring edge position points of the pyramid image of the current layer according to the high threshold and the low threshold obtained in step S23, and generating gradient information of the pyramid image of the current layer according to the obtained edge position points, wherein the gradient information of the pyramid image of the current layer includes a gradient position list, a gradient direction list, and a gradient magnitude list, and the gradient position list includes the coordinates of each edge position point, the gradient direction list includes the gradient direction of each edge position point, and the gradient magnitude list includes the gradient magnitude of each edge position point.

[0056] In this embodiment, the number of edge position points in the gradient position list, the number of elements in the gradient direction list, and the number of elements in the gradient magnitude list are the same, and the number of any one of them is the gradient information length of the current layer pyramid image.

[0057] Step S25: determining whether the length of the gradient information of the current layer pyramid image is smaller than the second preset size Ptmin, and executing step S27 if the length of the gradient information of the current layer pyramid image is smaller than the second preset size Ptmin, otherwise executing step S26.

[0058] Similarly, the second preset size Ptmin can be set to a fixed value, or can be adjusted automatically or manually according to actual applications. For example, the second preset size Ptmin can be set according to the size of the template image itself, the position matching accuracy requirement of the machine vision system, etc. It is only necessary to ensure that the gradient information in the current layer pyramid image is not too little, so that the matching will not be completed during online matching due to too little template information.

[0059] Step S26: Reduce the current layer pyramid image by a preset ratio to serve as a new current layer pyramid image, and increase the number of pyramid layers by one, and then execute step S22. For example, the size of the current layer pyramid image can be reduced by half to serve as a new current layer pyramid image. In actual applications, the preset ratio can be adjusted according to requirements such as recognition accuracy.

[0060] Step S27: Generate template information data of the template image.

[0061] In this step, the gradient position list, gradient direction list and gradient amplitude list of all layers of pyramid images are taken to obtain the edge point gradient list of the current template image, and then the edge point gradient list and the number of pyramid layers are combined to form the template information data, which can be used for subsequent matching.

[0062] The above template information acquisition method automatically generates comparison values ​​for determining edge position points through each layer of pyramid image, namely, high threshold and low threshold for Canny edge detection algorithm, which can greatly improve the accuracy of template information and thus improve the matching positioning point progress.

[0063] Combination Figure 3 FIG. 1 is a flow chart of obtaining the median value of the gradient amplitude of the current layer in the template information obtaining method provided in an embodiment of the present invention. Specifically, the median value of the gradient amplitude of the current layer can be obtained by the following steps:

[0064] Step S231: Obtain the gradient magnitude of each pixel in the pyramid image of the current layer. For example, the grayscale gradient of each pixel in the pyramid image of the current layer in the x and y directions (i.e., two directions perpendicular to each other in the pyramid image of the current layer) is first calculated by the Sobel operator, and then the gradients in the x and y directions calculated by the Sobel operator are transformed into polar coordinates to obtain the gradient direction and gradient magnitude of each pixel.

[0065] Step S232: Create an amplitude histogram Hm(n) according to the gradient amplitudes of all pixels in the current layer pyramid image, which is expressed as follows:

[0066]

[0067] Where Mi is the value of the i-th element in the histogram, n is the gradient amplitude of the n-th pixel in the current layer pyramid image, and n is an integer greater than or equal to 1.

[0068] Step S233: Generate the median value of the gradient amplitude of the current layer according to the amplitude histogram. Specifically, the median value of the gradient amplitude of the current layer Mimedian can be calculated according to the following calculation formula (2):

[0069]

[0070] Accordingly, when the first coefficient is 0.9 and the second coefficient is 0.7, the high threshold Tmax and the low threshold Tmin for the Canny edge detection algorithm are:

[0071] Tmax=0.9×Mimedian (3)

[0072] Tmin=0.7×Mimedian (4)

[0073] In practical applications, in addition to obtaining the median value of the current layer gradient amplitude through a histogram, the median value of the current layer gradient amplitude can also be obtained by other means, such as by calculating the weighted average value of the gradient amplitude of each pixel in the current layer pyramid image, etc. When calculating the high threshold Tmax and the low threshold Tmin for the Canny edge detection algorithm according to the median value of the current layer gradient amplitude, the corresponding first coefficient and the second coefficient can be adjusted to ensure the accuracy of the template information data.

[0074] Combination Figure 4 FIG. 1 is a flow chart of obtaining edge position points of a pyramid image of a current layer in a method for obtaining template information provided by an embodiment of the present invention. Specifically, the edge position points of a pyramid image of a current layer may be obtained by the following steps:

[0075] Step S241: For the current layer pyramid image, use the Canny operator to perform edge extraction calculation to obtain all pixel edge points that meet the requirements of the high threshold Tmax and the low threshold Tmin.

[0076] The use of the Canny operator to perform edge extraction calculations is an existing technology in the field. For example, when performing edge extraction calculations, pixels in the current layer pyramid image whose grayscale values ​​are greater than a high threshold are marked as white, and pixels whose grayscale values ​​are less than a low threshold are marked as black. If the grayscale value of a pixel is between the high and low thresholds, then the necessary and sufficient condition for it to become a boundary is that it is directly connected to the "edge pixel" (eight neighborhoods) and is connected to the "edge pixel" through pixels whose grayscale values ​​are between the high and low thresholds.

[0077] Step S242: After edge pixels are obtained, connected domain operations are performed on the edge pixels to connect adjacent edge pixels to obtain a number of independent edge curve segments. Connected domain operations are known in the art and will not be described in detail herein.

[0078] Step S243: taking edge pixel points on edge curve segments that meet preset conditions as edge position points. That is, after obtaining a plurality of independent edge curve segments, edge curve segments that meet preset conditions are selected from the plurality of independent edge curve segments, and edge pixel points are obtained from the selected edge curve segments.

[0079] Combination Figure 5 FIG. 1 is a flow chart of obtaining edge position points according to edge curve segments in the template information obtaining method provided by an embodiment of the present invention. Specifically, the edge position points of the current layer pyramid image can be obtained according to the edge curve segments through the following steps:

[0080] Step S2431: The edge curve segments whose length is not less than the first preset length Lmin are selected as candidate edge curve segments. The edge curve segments whose length is less than or equal to the first preset length Lmin are usually just areas with large noise or fine texture on the image surface, not contour lines, and need to be deleted. If the number of candidate edge curve segments is zero, the three empty lists of gradient position list, gradient direction list and gradient amplitude list are directly returned.

[0081] Step S2432: When the sum of the lengths of all candidate edge curve segments is greater than the second preset length Ptman, delete the redundant edge pixel points in the candidate edge curve segments so that the total number of edge position points is less than the second preset length Ptmax, and use all edge pixel points on the candidate edge curve segments after deleting the redundant edge pixel points as edge position points.

[0082] There are many ways to delete redundant edge pixels. For example, the set granularity coefficient Gmin can be used to limit the spacing and select edge pixels through the set granularity parameter Gmin. The actual set granularity coefficient Gmin can be adjusted according to the current actual edge pixels and the second preset length Ptmax. In one scenario, the set granularity coefficient Gmin can be used to delete by trend edge. The average curvature of the adjacent Gmin edge points is calculated, and the excessive curvature is eliminated. Only the point with the curvature closest to the average curvature is left, and the other points are deleted. In this method, the edge pixel points of the preset number (i.e., Gmin) of adjacent edge pixels on the candidate edge curve segment are first used as the pixels to be processed, and the curvature at each pixel to be processed and the average curvature of all the pixels to be processed are obtained; then all the pixels to be processed whose curvature is not closest to the average curvature are deleted as redundant edge pixels.

[0083] In addition, the gradient amplitude information can also be used, that is, among the adjacent Gmin edge pixels, the edge pixel with the largest gradient amplitude is retained. In this method, the edge pixels of the preset number (i.e., Gmin) adjacent to the candidate edge curve segment can be first used as the pixels to be processed, and the gradient amplitudes of all the pixels to be processed can be compared; then, all the pixels to be processed whose gradient amplitude is not the largest can be deleted as redundant edge pixels.

[0084] After the total number of edge pixels in the candidate edge curve segment is less than the second preset length Ptmax, the gradient direction Di and gradient amplitude Mi corresponding to the position of each remaining edge pixel point (i.e., edge position point) are extracted (the gradient direction Di needs to be normalized), added to the gradient direction list and the gradient amplitude list, and the coordinates of each edge position point are added to the gradient position list ListPi. After all are added, the three lists are returned.

[0085] When the input is only the template image, the training of the template edge can only be modified by adjusting the template training parameters. When the template image contains other interfering edges, such as defects and dirt, there is no way to eliminate these interferences by adjusting the parameters. In this case, manual intervention is required in the generation process of the template edge. Figure 6As shown, this manual intervention can be completed by inputting another mask image, namely, the second mask image 62. The second mask image 62 is a black and white binary image. The white area indicates that the edge points in the area can be used, and the black area indicates that the edge points in the area need to be removed. This method can make appropriate interactive functions on the human-computer interaction interface of the application, and the user generates the second mask image 62 through interaction. For example, in the human-computer interaction interface, the template image is displayed, and the extracted edge points are also displayed on the template image. The template image is painted with the mouse (that is, external input information is generated), and the areas where the interference points are located are painted. Then, the human-computer interaction interface generates the second mask image 62 according to the above external input information, and passes it into the training process (for example Figure 2 Since the pyramid image is multi-layered, it is troublesome to display the edge position points of all layers. In one embodiment of the present invention, the second mask image 62 can be generated by interactively smearing only the edge position points of the bottom pyramid image.

[0086] If a certain area of ​​a certain layer of the pyramid image has a strong interference point edge, then there is no way to eliminate the interference point edge of the pyramid image of this layer. In one embodiment of the present invention, a first mask image 61 can be introduced. The first mask image 61 can be generated by dilation processing on the edge position points of the bottom pyramid image, that is, the coordinates of each edge position point are expanded to a region in all directions (for example, m pixels are expanded in each direction, and m is an integer greater than 1), and the area formed after the expansion of all edge position points is used as the first mask image 61, and is passed into the training process (for example, Figure 2 In step S24).

[0087] In each layer of the pyramid image, the actual effect is equivalent to performing an "AND" operation on the first mask image 61 and the second mask 62, and then using them as the actual mask image of the current layer of the pyramid image. By adding the first mask image 61, it is ensured that the influence of the interference point area is eliminated in all layers of the pyramid image.

[0088] The embodiment of the present invention further provides a template information acquisition device, which can be located in a machine vision system and realize matching positioning. The template information acquisition device 7 of this embodiment includes a memory 71 and a processor 72, wherein the memory 71 stores a computer program that can be executed in the processor 72, and when the processor 72 executes the computer program, the following is realized: Figure 2-6 The steps of the template information acquisition method described in the embodiment.

[0089] The motor controller in this embodiment is the same as the above Figure 2-6The template information acquisition method in the corresponding embodiment belongs to the same concept, and its specific implementation process is detailed in the corresponding method embodiment, and the technical features in the method embodiment are applicable in the device embodiment, which will not be repeated here.

[0090] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the template information acquisition method as described above.

[0091] The computer-readable storage medium in this embodiment is the same as the above Figure 2-6 The template information acquisition method in the corresponding embodiment belongs to the same concept, and its specific implementation process is detailed in the corresponding method embodiment, and the technical features in the method embodiment are applicable in the device embodiment, which will not be repeated here.

[0092] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0093] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0094] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0095] In the embodiments provided in the present application, it should be understood that the disclosed template information acquisition method and device can be implemented in other ways.

[0096] The present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or interface switching device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0097] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. Various changes can be made within the knowledge of ordinary technicians in the relevant technical field without departing from the purpose of the present invention. In addition, the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.

Claims

1. A template information acquisition method, characterized in that: include: Creating a plurality of layers of pyramid images according to the template image, and extracting gradient information of each layer of the pyramid image to form template information for image recognition, wherein extracting the gradient information of each layer of the pyramid image to form template information for image recognition includes: Generate a median value of the gradient amplitude of the current layer according to the gradient amplitude of each pixel in the pyramid image of the current layer, and generate a high threshold and a low threshold according to the median value of the gradient amplitude of the current layer; An edge position point is acquired according to the high threshold and the low threshold, and gradient information of a pyramid image of a current layer is generated according to the edge position point, wherein the gradient information of the pyramid image of the current layer includes a gradient position list, a gradient direction list, and a gradient magnitude list, wherein the gradient position list includes the coordinates of each edge position point, the gradient direction list includes the gradient direction of each edge position point, and the gradient magnitude list includes the gradient magnitude of each edge position point.

2. The template information acquisition method according to claim 1, characterized in that: The method further comprises: Generate a first mask image according to the gradient information of the bottom pyramid image, wherein the first mask image is formed by dilating edge position points in the bottom pyramid image; For each layer of pyramid image, the first mask image is used to eliminate interference edge position points in each layer of pyramid image.

3. The template information acquisition method according to claim 1 or 2, characterized in that: The step of obtaining edge position points according to the high threshold and the low threshold comprises: For the current pyramid image, use the Canny operator to perform edge extraction calculations to obtain all edge pixel points that meet the high threshold and low threshold requirements; A connected domain operation is performed on the edge pixel points to obtain a plurality of independent edge curve segments, and edge pixel points on the edge curve segments that meet preset conditions are used as edge position points.

4. The template information acquisition method according to claim 3, characterized in that: The step of taking edge pixel points on edge curve segments meeting preset conditions as edge position points comprises: taking an edge curve segment whose length is not less than a first preset length as a candidate edge curve segment; When the sum of the lengths of all candidate edge curve segments is greater than a second preset length, redundant edge pixels in the candidate edge curve segments are deleted, and all edge pixels on the candidate edge curve segments after the redundant edge pixels are deleted are used as edge position points.

5. The template information acquisition method according to claim 4, characterized in that: The deleting redundant edge pixel points in the candidate edge curve segment includes: A preset number of adjacent edge pixel points on the candidate edge curve segment are used as pixel points to be processed, and the curvature at each pixel point to be processed and the average curvature of all pixel points to be processed are obtained; All the pixels to be processed whose curvature is not closest to the average curvature are deleted as redundant edge pixels.

6. The template information acquisition method according to claim 4, characterized in that: The deleting redundant edge pixel points in the candidate edge curve segment includes: A preset number of adjacent edge pixel points on the candidate edge curve segment are used as pixel points to be processed, and the gradient amplitudes of all the pixel points to be processed are compared; All pixels to be processed whose gradient amplitude is not the largest are deleted as redundant edge pixels.

7. The template information acquisition method according to claim 1 or 2, characterized in that: According to the gradient amplitude of each pixel in the pyramid image of the current layer, the median of the gradient amplitude of the current layer is generated, including: Get the gradient magnitude of each pixel in the current layer pyramid image; Create a magnitude histogram based on the gradient magnitudes of all pixels in the current layer pyramid image; The current layer gradient amplitude median is generated according to the amplitude histogram.

8. The template information acquisition method according to claim 1, characterized in that: The method further comprises: generating a second mask image according to external input information, wherein the external input information includes a designated image area on the template image; For each layer of pyramid image, the second mask image is used to eliminate interference edge position points in each layer of pyramid image.

9. A template information acquisition device, comprising a memory and a processor, characterized in that: The memory stores a computer program executable in the processor, and the processor implements the steps of the template information acquisition method according to any one of claims 1 to 8 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the steps of the template information acquisition method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Self-adaption method and system of parameters in template matching

    CN107590512A

  • Image matching method based on edge direction and gradient characteristics

    CN110197232A

  • Template matching algorithm based on edge and gradient features

    CN110472674A

  • Image processing method, image processing apparatus, program, and recording medium

    US20160012312A1

  • Template matching algorithm based on edge and gradient feature

    WO2021017361A1