Image template matching method, electronic equipment and storage medium

By obtaining the image pyramid and matching the pose information of the target object layer by layer based on the rotational symmetry of the outer edge of the object to be detected, the problem of loss of symmetric object features is solved and the accuracy and efficiency of image template matching are improved.

CN118570508APending Publication Date: 2024-08-30ZHEJIANG HUARAY TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410621620.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-16
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the existing technology, during the image template matching process, some distinguishable features of the symmetrical object are lost, causing the matching to fail. It is difficult to improve the accuracy of the target image of the symmetrical object in the template matching on the premise of improving the matching efficiency.

Method used

By obtaining the image pyramid of the object to be detected, based on the rotational symmetry of the outer edge of the object to be detected, the pose information of the target object is matched layer by layer, and reference information is generated to retain distinguishable features and improve matching efficiency and accuracy.

Benefits of technology

On the premise of maintaining matching efficiency, the accuracy of template matching for target images containing symmetric objects is improved, and the probability of false detection of template matching by symmetric features is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570508A
    Figure CN118570508A
Patent Text Reader

Abstract

The invention discloses an image template matching method, electronic equipment and a storage medium. The method comprises the steps of obtaining an image pyramid based on a target image of a to-be-detected object; selecting the candidate object in the template image as a target object based on a matching result of the first-layer sub-image in the image pyramid and the template image of each candidate object; determining reference information based on the target angle and the attitude information of the target object; and matching the second layer of sub-images in the image pyramid based on the reference information, and executing template matching about the target image layer by layer to obtain a template matching result about the target image. According to the scheme, on the premise that the matching efficiency is improved as much as possible, the accuracy of the target image containing the symmetric object in template matching can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image recognition technology, and in particular to an image template matching method, as well as electronic devices and storage media. Background Technology

[0002] Image template matching in the field of computer vision can be used to find objects similar to the object to be detected in a template image and obtain their positions. It is widely used in target recognition, workpiece localization, video target extraction and other fields.

[0003] In existing technologies, to maximize the matching efficiency of image template matching, an image pyramid is applied during the template matching process. Based on sub-images of different resolutions of the target image within the image pyramid, a more precise matching pose of the target object within the template image is continuously searched, achieving a coarse-to-fine matching between the target object and the template image. However, due to the inherent symmetry of symmetrical objects and the characteristics of the image pyramid, distinguishable features of symmetrical objects may be lost during the matching process, leading to template matching failure. Therefore, improving the accuracy of target images containing symmetrical objects in template matching while maximizing matching efficiency has become a pressing problem. Summary of the Invention

[0004] The main technical problem addressed by this application is to provide an image template matching method, electronic device, and storage medium that can improve the accuracy of target images containing symmetrical objects in template matching while maximizing matching efficiency.

[0005] To address the aforementioned technical problems, the first aspect of this application provides an image template matching method, comprising: acquiring an image pyramid based on a target image of an object to be detected; wherein the outer edge of the object to be detected is rotationally symmetric about a target angle, and the image pyramid contains several sub-image layers obtained by sampling the target image at different scales, with the resolution of the sub-image layers arranged in ascending order; selecting candidate objects in the template images as target objects based on the matching results of the first sub-image layer in the image pyramid with template images of each candidate object; determining reference information based on the target angle and the pose information of the target object; wherein the pose information includes at least the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected; performing matching on the second sub-image layer in the image pyramid based on the reference information, and performing template matching layer by layer with respect to the target image to obtain a template matching result for the target image.

[0006] To address the aforementioned technical problems, a second aspect of this application provides an electronic device including a memory and a processor coupled to each other. The memory stores program instructions, and the processor executes the program instructions to implement the image template matching method described in the first aspect.

[0007] To address the aforementioned technical problems, a third aspect of this application provides a computer-readable storage medium storing program instructions executable by a processor, the program instructions being used to implement the image template matching method described in the first aspect.

[0008] The above scheme obtains an image pyramid based on the target image of the object to be detected, and the outer edge of the object to be detected is rotationally symmetrical about the target angle. The image pyramid contains several sub-images obtained by sampling the target image at different scales, and the resolution of the sub-images is arranged in order from low to high. Based on the matching results of the first sub-image in the image pyramid with the template images of each candidate object, the candidate object in the template image is selected as the target object. Based on the target angle and at least the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected, reference information is determined. Based on the reference information, matching is performed on the second sub-image in the image pyramid, and template matching with respect to the target image is performed layer by layer to obtain the template matching result with respect to the target image. Therefore, when the outer edge of the object to be detected is rotationally symmetrical about the target angle, after generating the target object based on the matching results of the first layer sub-image in the image pyramid with the template images of each candidate object, reference information about the target angle and the pose of the target object is generated. Thus, the reference information can retain as many distinguishable features as possible that can be searched by the second layer sub-image of the image pyramid based on the symmetry characteristics of the object to be detected. Therefore, it can improve the accuracy of the target image containing symmetrical objects in template matching while maximizing the matching efficiency. Attached Figure Description

[0009] Figure 1 This is a flowchart illustrating an embodiment of the image template matching method of this application;

[0010] Figure 2 This is a schematic diagram of the frame of an embodiment of the image template matching device of this application;

[0011] Figure 3 This is a schematic diagram of the framework of an embodiment of the electronic device of this application;

[0012] Figure 4 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. Detailed Implementation

[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0014] In this paper, the terms "system" and "network" are often used interchangeably. The term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this paper means two or more.

[0015] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the image template matching method of this application. Specifically, it may include the following steps:

[0016] Step S10: Obtain the image pyramid based on the target image of the object to be detected.

[0017] In this embodiment of the disclosure, the target image may be a frame image in the video to be detected, a photograph of the workpiece, etc., and the image format of the target image is not limited in this application, such as bmp, jpg, png, etc.

[0018] In one implementation scenario, after acquiring the target image, edge detection is performed on the target image to extract the edge features of the object to be detected. Based on the edge features about the outer edge of the object, the symmetry of the object is then determined. It should be noted that in practical applications, the object to be detected is not strictly symmetrical in a mathematical sense. Understandably, within a certain error range, the outer edge of the object can be considered to conform to the symmetry described in this application. For example, if the outer edge of the object is a non-smooth circle, the centroid of the point set is calculated based on the outer edge point set. The maximum and minimum distances from each point in the point set to the centroid are calculated. When the minimum distance is greater than the product of the maximum distance and a reduction factor (e.g., a reduction factor of 0.9), the outer edge of the object can be considered symmetrical, and the target angle of rotational symmetry about the object is consistent with the angle of rotational symmetry of the circle.

[0019] In a specific implementation scenario, before determining whether the outer edge of the object to be detected is symmetrical, the shape of the outer edge of the object to be detected can also be determined. For example, it can be determined whether the outer edge shape of the object to be detected is a common symmetrical shape, such as a circle, rectangle, or rhombus.

[0020] In a specific implementation scenario, as one possible approach, an edge detection model can be pre-trained. This model can include, but is not limited to, an Encoder-Decoder architecture network model. To ensure the accuracy of the edge detection model, sample images labeled with ground truth edges and their symmetries can be collected. Based on this, the sample images can be processed using the edge detection model to obtain predicted edges and their symmetries. The network parameters of the edge detection model can then be adjusted based on the differences between ground truth edges and predicted edges, as well as the differences between the symmetries of ground truth edges and predicted edges, until the model training converges. The converged edge detection model can then be used to process the target image, yielding a target image containing the symmetry of the outer edges of the detected object. It should be noted that the specific processing steps of the edge detection model can be found in technical details such as those of Encoder-Decoder architecture network models, and will not be elaborated upon here.

[0021] In one implementation scenario, the outer edge of the object to be detected in the target image is rotationally symmetric about the target angle. For example, the target angle about the outer edge shape of an isosceles triangle is 60 degrees, the target angle about the outer edge shape of a square is 90 degrees, and the target angle about the outer edge shape of a rectangle is 90 degrees. Understandably, the target angle about the outer edge shape of a circle is any value. For the determination of the specific target angle, please refer to the technical details about axial symmetry, central symmetry, etc., which will not be elaborated here.

[0022] In a specific implementation scenario, the detection object whose outer edge is rotationally symmetric about the target angle may have the following characteristics: there are minor feature loss at the edge, and / or minor features inside, and / or symmetric features inside.

[0023] In one implementation scenario, an image pyramid is acquired. The image pyramid contains several sub-image layers obtained by sampling the target image at different scales, and the resolution of the sub-image layers is arranged in ascending order. For example, the resolution of the first sub-image layer of the image pyramid is 64×64, the resolution of the second sub-image layer is 128×128, the resolution of the third sub-image layer is 256×256, and so on.

[0024] It should be noted that the original resolution of the target image is not limited in this application.

[0025] Step S20: Based on the matching results of the first layer sub-image in the image pyramid with the template images of each candidate object, select the candidate object in the template image as the target object.

[0026] In one implementation scenario, the template image of each candidate object is globally traversed from the origin on the first layer of sub-images in the image pyramid to calculate the degree of difference between the sub-image covered by the template image and the template image, so as to find the best matching position, that is, to obtain the matching results of the first layer of sub-images in the image pyramid with the template images of each candidate object.

[0027] In a specific implementation scenario, based on the matching results of the first layer sub-images in the image pyramid with the template images of each candidate object, the maximum similarity between the edge features of the object to be detected at each position coordinate and the edge features of the candidate objects in the template image is obtained, as well as the rotation angle corresponding to the maximum similarity at each position coordinate. Based on the position coordinates corresponding to the maximum value between each maximum similarity and the rotation angle corresponding to the position coordinates, the target object is determined.

[0028] In a specific implementation scenario, the similarity between the edge features of the object to be detected at various coordinates and the edge features of the candidate object in the template image can be calculated based on the cosine angle, as shown in the following formula:

[0029]

[0030]

[0031]

[0032] In formula (1), (m x ,m y ) represents the gradient information of each edge point in the target image, and A represents the normalized value of the gradient information of the target image. In formula (2), (n x ,n y ) represents the gradient information of each edge point in the template image, B represents the normalized value of the gradient information of the template image, and S represents the cosine angle in formula (3). It can be understood that when S is smaller, it indicates that there is a higher degree of matching between the candidate object in the template image and the object to be detected in the target image based on the current search parameters. Conversely, when S is larger, it indicates that there is a lower degree of matching between the candidate object in the template image and the object to be detected in the target image based on the current search parameters. The theoretical maximum value of S is 1, and the theoretical minimum value is 0.

[0033] In a specific implementation scenario, when obtaining the similarity between the edge features of the object to be detected at any position coordinate and the edge features of the candidate object in the template image, it is necessary to traverse various search angles and search scales, compare the similarity calculated based on each search angle and search scale, and take the set of search scales and search angles with the largest similarity value as the pose information corresponding to the position coordinates.

[0034] In a specific implementation scenario, the template images of each candidate object are globally traversed from the origin on the first layer of sub-images in the image pyramid. The overall search space is a four-dimensional space, specifically including angle, scale, horizontal axis direction, and vertical axis direction. As one possible implementation, no scale change occurs between the sub-image and the template image during the search process; only angle change and position coordinate change are considered. In another possible implementation, scale change occurs between the sub-image and the template image during the search process. This application does not impose any limitations on this.

[0035] In a specific implementation scenario, based on the lower-resolution sub-images provided by the first layer of the image pyramid, template images that match the object to be detected in the target image, as well as the target object in the template images, are quickly selected. This approach maximizes the efficiency of image template matching.

[0036] Step S30: Determine reference information based on the target angle and the pose information of the target object.

[0037] In this embodiment of the disclosure, the pose information of the target object includes at least the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected. Therefore, the reference information generated about the target angle and the pose information of the target object can, based on the symmetry characteristics of the object to be detected, retain as many distinguishable features as possible that can be searched by the second-level sub-images of the image pyramid. Thus, it can improve the accuracy of target images containing symmetrical objects in template matching while maximizing matching efficiency.

[0038] In one implementation scenario, the reference information includes at least one new template image generated from the template image of the target object. Due to the symmetry of the object to be detected and the low resolution of the first-layer sub-image of the image pyramid, when traversing the template image based on the first-layer sub-image to obtain the maximum similarity, there may be a situation where, at a certain angle, the outer edge of the object to be detected has a high matching degree with the candidate object in the template image, but the internal features of the object to be detected cannot be matched by the first-layer sub-image. Therefore, when selecting the maximum value in the similarity as the pose information of the target object, when matching the target object in the template image based on the sub-images of subsequent layers of the image pyramid, the higher-resolution sub-images of subsequent layers cannot find their own distinguishable features in the target object, thus leading to the failure of the final template matching. Therefore, at least one new template image generated based on the template image of the target object can be used to add a certain number of new template images to the template matching of the second-layer sub-image of the image pyramid with the template image containing the target object, so as to minimize the false detection probability of the symmetry features of the object to be detected in the template matching. Thus, the accuracy of the target image containing the symmetrical object in the template matching can be improved while maximizing the matching efficiency.

[0039] In a specific implementation scenario, at least one candidate angle is determined based on the rotation angle and the target angle. For example, if the rotation angle of the target object relative to the object to be detected is 100 degrees, the target angle is 60 degrees, and the candidate angles are 100 degrees, 160 degrees, 40 degrees, 220 degrees, -20 degrees, 280 degrees, and -80 degrees. It can be understood that the smaller the target angle, the richer the symmetry features representing the object to be detected. When matching the object to be detected based on the sub-images of the first layer of the image pyramid, the probability of a false match is higher. Therefore, a larger number of candidate angles can be determined to generate a richer new template image. Conversely, the larger the target angle, the poorer the symmetry features representing the object to be detected. When matching the object to be detected based on the sub-images of the first layer of the image pyramid, the probability of a false match is lower. Therefore, a smaller number of candidate angles can be determined to generate a richer new template image. It should be noted that the above embodiments are only one possible implementation method, and the method for generating candidate angles and the number of candidate angles generated are not limited in this application. The template image of the target object is adjusted based on at least one candidate angle to obtain a new template image. The position coordinates of the target object in the new template image remain unchanged, and the rotation angle of the object to be detected is a candidate angle. For example, if the position coordinates of the target object in the template image are (x, y), and the rotation angle of the target object relative to the object to be detected is 100 degrees, the new template image includes pose information of (x, y, 100 degrees), (x, y, 160 degrees), (x, y, 40 degrees), (x, y, 220 degrees), (x, y, -20 degrees), (x, y, 280 degrees), and (x, y, -80 degrees). The above scheme, by generating reference information regarding the target angle and the pose information of the target object, can retain as many distinguishable features as possible that can be searched by the second-level sub-images of the image pyramid, based on the symmetry characteristics of the object to be detected. Therefore, it can improve the accuracy of target images containing symmetrical objects in template matching while maximizing matching efficiency.

[0040] In one implementation scenario, based on the target angle and the pose information of the target object, the search range for matching the target object in the second-level sub-image of the image pyramid is determined. The search range represents the set of position coordinates of the object to be detected in the sub-image and the template image containing the target object. This scheme, by determining the search range for matching the target object in the second-level sub-image of the image pyramid based on the target angle and the pose information of the target object, can improve the accuracy of template matching for target images containing symmetrical objects while controlling the search range to maximize matching efficiency.

[0041] In a specific implementation scenario, the resolution ratio between the second-layer sub-image and the first-layer sub-image in the image pyramid is obtained, and a preset magnification ratio is determined based on the target angle. The preset magnification ratio represents the expansion step of the position search range, and the preset magnification ratio is negatively correlated with the target angle. That is, the smaller the target angle, the richer the symmetric features representing the object to be detected. When matching the object to be detected based on the first-layer sub-image of the image pyramid, the probability of a false match is greater. Therefore, a larger preset magnification ratio can be determined to search a larger range of template images. Conversely, the larger the target angle, the poorer the symmetric features representing the object to be detected. When matching the object to be detected based on the first-layer sub-image of the image pyramid, the probability of a false match is smaller. Therefore, a smaller preset magnification ratio can be determined to search a smaller range of template images. Based on the position coordinates of the target object in the template image, the resolution ratio, and the preset magnification ratio, the position search range is determined. For example, the resolution of the first sub-image of the image pyramid is 64×64, the resolution of the second sub-image of the image pyramid is 128×128, the resolution ratio between the second sub-image and the first sub-image in the image pyramid is 2, the preset magnification ratio is determined to be 2 based on the target angle, and the position coordinates of the target object in the template image are (x, y). Therefore, the position search range is a square area with (x, y) as the upper left vertex and an area of ​​8×8.

[0042] It should be noted that the method for determining the preset magnification ratio and the value of the preset magnification ratio are not limited in this application.

[0043] In one implementation scenario, based on the target angle and the pose information of the target object, the angle search range for matching the target object in the second-level sub-image of the image pyramid is determined. Here, the angle search range represents the set of rotation angles within the sub-image for matching the object to be detected with a template image containing the target object. This scheme, by determining the angle search range for matching the target object in the second-level sub-image of the image pyramid based on the target angle and the pose information of the target object, can improve the accuracy of template matching for target images containing symmetrical objects while maximizing matching efficiency by controlling the angle search range.

[0044] In a specific implementation scenario, the angle step size for matching the first-level sub-images in the image pyramid with the template images of each candidate object is obtained. The angle step size represents the step size of the angle during rotation matching. A preset multiple is determined based on the target angle, which represents the expansion step size of the angle step size. The preset multiple is negatively correlated with the target angle. That is, the smaller the target angle, the richer the symmetry features of the object to be detected. When matching the object to be detected based on the first-level sub-images of the image pyramid, the probability of a false match is greater. Therefore, a larger preset multiple can be determined to search a larger range of template images. Conversely, the larger the target angle, the poorer the symmetry features of the object to be detected. When matching the object to be detected based on the first-level sub-images of the image pyramid, the probability of a false match is smaller. Therefore, a smaller preset multiple can be determined to search a smaller range of template images. The angle search range is determined based on the rotation angle of the target object relative to the object to be detected, the angle step size, and the preset multiple. For example, if the angle step is angleStep, the rotation angle of the target object relative to the object to be detected is angle, and the preset multiplier is n, then the search range of the angle is (angle-n×angleStep) to (angle+n×angleStep).

[0045] It should be noted that the method for determining the preset multiple and the value of the preset multiple are not limited in this application.

[0046] In one implementation scenario, when the matching result includes the maximum similarity between the edge features of the object to be detected at each position coordinate and the edge features of the candidate object in the template image, as well as the rotation angle corresponding to the maximum similarity at each position coordinate, after determining the target object based on the maximum value between the maximum similarities, at least one preset angle is determined based on the target angle and the rotation angle corresponding to the maximum value between each maximum similarity to filter the rotation angle corresponding to the maximum similarity at each position coordinate. For example, if the target angle is 90 degrees and the rotation angle corresponding to the maximum value between each maximum similarity is angle, then the preset angle is angle±90. It can be understood that, for example, if a square is symmetrical about 90 degrees and 180 degrees, then the preset angles are angle±90 and angle±180. Based on the position coordinates of the rotation angles corresponding to the maximum similarity that are consistent with the preset angle, a new template image is obtained as reference information. For example, the position coordinates corresponding to the maximum value among the maximum similarity values ​​are (x, y), meaning the pose information of the target object is (x, y, angle). Based on a preset angle of angle ±90, the rotation angle corresponding to the maximum similarity among the selected position coordinates exists at angle ±90, and the corresponding position coordinates are (m, n). Therefore, the pose information of the target object in the new target image is (m, n, angle ±90). This scheme, while maximizing matching efficiency, improves the accuracy of template matching for target images containing symmetrical objects.

[0047] In a specific implementation scenario, the preset angle can represent an angle range, that is, the search within the rotation angle has a deviation threshold. For example, if the target angle is 90 degrees, the deviation threshold is 5 degrees, and the rotation angle corresponding to the maximum value between each maximum similarity is 'angle', then the preset angle is [angle ± (90 ± 5)]. It should be noted that the method for determining the deviation threshold and the value of the deviation threshold are not limited in this application.

[0048] In a specific implementation scenario, when there are at least two matching results between the same preset angle and the rotation angle corresponding to the maximum similarity in each position coordinate, the maximum similarity corresponding to the preset angle is obtained, and the maximum similarity is compared numerically. The position coordinate corresponding to the position with the greater similarity is selected as the pose information of the new template image.

[0049] Step S40: Based on the reference information, perform matching on the second-level sub-image in the image pyramid, and perform template matching on the target image layer by layer to obtain the template matching result on the target image.

[0050] In one implementation scenario, when the outer edge of the object to be detected is rotationally symmetrical about the target angle, after generating the target object based on the matching results of the first-layer sub-image in the image pyramid with the template images of each candidate object, reference information about the target angle and the pose of the target object is generated. Therefore, the reference information can retain as many distinguishable features as possible that can be searched by the second-layer sub-image of the image pyramid as possible based on the symmetry characteristics of the object to be detected. Thus, it can improve the accuracy of the target image containing symmetrical objects in template matching while maximizing the matching efficiency.

[0051] In a specific implementation scenario, when the reference information includes at least one new template image generated from the template image of the target object, the matching results of the second-level sub-images in the image pyramid with the target objects in each of the new template images are obtained. Based on the matching results, the target object in the new template image is selected as the object to be matched in the third-level sub-images in the image pyramid.

[0052] The above scheme, based on the target image of the object to be detected, obtains an image pyramid, where the outer edge of the object to be detected is rotationally symmetrical about the target angle. The image pyramid contains several sub-images obtained by sampling the target image at different scales, and the resolution of these sub-images is arranged in ascending order. Based on the matching results of the first sub-image in the image pyramid with the template images of each candidate object, the candidate object in the template image is selected as the target object. Based on the target angle and at least the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected, reference information is determined. Matching is performed on the second sub-image in the image pyramid based on the reference information, and template matching is performed layer by layer with respect to the target image to obtain the template matching result for the target image. Therefore, when the outer edge of the object to be detected is rotationally symmetrical about the target angle, after generating the target object based on the matching results of the first sub-image in the image pyramid with the template images of each candidate object, reference information about the target angle and the target object's pose is generated. Thus, the reference information can retain as many distinguishable features as possible that can be searched by the second sub-image of the image pyramid based on the symmetry characteristics of the object to be detected, thereby improving the accuracy of template matching for target images containing symmetrical objects.

[0053] Please see Figure 2 , Figure 2 This is a schematic diagram of the framework of an embodiment of the image template matching device 20 of this application. Figure 2As shown, the image template matching device 20 includes an acquisition module 21, a selection module 22, a determination module 23, and a matching module 24. The acquisition module 21 is used to acquire an image pyramid based on the target image of the object to be detected. The outer edge of the object to be detected is rotationally symmetrical about the target angle. The image pyramid contains several sub-images obtained by sampling the target image at different scales, and the resolution of the sub-images is arranged in ascending order. The selection module 22 is used to select the candidate object in the template image as the target object based on the matching results of the first sub-image in the image pyramid with the template images of each candidate object. The determination module 23 is used to determine reference information based on the target angle and the pose information of the target object. The pose information includes at least the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected. The matching module 24 is used to perform matching in the second sub-image in the image pyramid based on the reference information, and perform template matching about the target image layer by layer to obtain the template matching result about the target image.

[0054] In the above scheme, the image template matching device 20 acquires an image pyramid based on the target image of the object to be detected, and the outer edge of the object to be detected is rotationally symmetrical about the target angle. The image pyramid contains several sub-images obtained by sampling the target image at different scales, and the resolution of the sub-images is arranged in order from low to high. Based on the matching results of the first sub-image in the image pyramid with the template images of each candidate object, the candidate object in the template image is selected as the target object. Based on the target angle and at least the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected, reference information is determined. Based on the reference information, matching is performed on the second sub-image in the image pyramid, and template matching is performed layer by layer with respect to the target image to obtain the template matching result for the target image. Therefore, when the outer edge of the object to be detected is rotationally symmetrical about the target angle, after generating the target object based on the matching results of the first layer sub-image in the image pyramid with the template images of each candidate object, reference information about the target angle and the pose of the target object is generated. Thus, the reference information can retain as many distinguishable features as possible that can be searched by the second layer sub-image of the image pyramid based on the symmetry characteristics of the object to be detected. Therefore, it can improve the accuracy of the target image containing symmetrical objects in template matching while maximizing the matching efficiency.

[0055] In some disclosed embodiments, the reference information includes at least one new template image generated from the template image of the target object, and the determining module 23 further includes a first template generation module (not shown) for determining at least one candidate angle based on the rotation angle and the target angle; adjusting the template image of the target object based on the at least one candidate angle to obtain a new template image; wherein the position coordinates of the target object in the new template image remain unchanged, and the rotation angle of the object to be detected is a candidate angle.

[0056] In some disclosed embodiments, the matching module 24 further includes a matching submodule (not shown) for obtaining matching results between the second-layer sub-images in the image pyramid and the target objects in each of the new template images in response to reference information including at least one new template image generated from a template image of the target object; and selecting the target object in the new template image as the object to be matched in the third-layer sub-images in the image pyramid based on the matching results.

[0057] In some disclosed embodiments, the determining module 23 further includes a search range determining module (not shown), used to determine the position search range for matching the target object in the second-layer sub-image of the image pyramid based on the target angle and the pose information of the target object; wherein, the position search range represents the set of position coordinates of the object to be detected in the sub-image and the template image containing the target object for matching; and / or, based on the target angle and the pose information of the target object, determine the angle search range for matching the target object in the second-layer sub-image of the image pyramid; wherein, the angle search range represents the set of rotation angles for matching the object to be detected in the sub-image and the template image containing the target object.

[0058] In some disclosed embodiments, the search range determination module (not shown) further includes a position search range determination submodule (not shown), used to obtain the resolution ratio between the second-layer sub-image and the first-layer sub-image in the image pyramid, and to determine a preset magnification ratio based on the target angle; wherein, the preset magnification ratio represents the magnification step of the position search range, and the preset magnification ratio is negatively correlated with the target angle; the position search range is determined based on the position coordinates of the target object in the template image, the resolution ratio, and the preset magnification ratio.

[0059] In some disclosed embodiments, the search range determination module (not shown) further includes an angle search range determination submodule (not shown), used to obtain the angle step size of the first layer sub-image in the image pyramid that matches the template image of each candidate object, and to determine a preset multiple based on the target angle; wherein, the preset multiple represents the expansion step size of the angle step size, and the preset multiple is negatively correlated with the target angle; the angle search range is determined based on the rotation angle of the target object relative to the object to be detected, the angle step size, and the preset multiple.

[0060] In some disclosed embodiments, the selection module 22 further includes a score matching module (not shown), which is used to obtain the maximum similarity between the edge features of the object to be detected at each position coordinate and the edge features of the candidate objects in the template image based on the matching results of the first layer sub-image in the image pyramid and the template image of each candidate object, and to obtain the rotation angle corresponding to the maximum similarity at each position coordinate; and to determine the target object based on the position coordinates corresponding to the maximum value between each maximum similarity and the rotation angle corresponding to the position coordinates.

[0061] In some disclosed embodiments, the matching result includes the maximum similarity between the edge features of the object to be detected at each position coordinate and the edge features of the candidate object in the template image, as well as the rotation angle corresponding to the maximum similarity at each position coordinate. After determining the target object based on the maximum value between the maximum similarities, the determining module 23 further includes a second template generation module (not shown), which is used to determine at least one preset angle for filtering the rotation angle corresponding to the maximum similarity at each position coordinate based on the target angle and the rotation angle corresponding to the maximum value between the maximum similarities. Based on the position coordinates of the rotation angles corresponding to the maximum similarity that are consistent with the preset angle, a new template image is obtained as reference information.

[0062] Please see Figure 3 , Figure 3 This is a schematic diagram of the framework of an embodiment of the electronic device 30 of this application. Figure 3As shown, the electronic device 30 includes a memory 31 and a processor 32 coupled to each other. The memory 31 stores program instructions, and the processor 32 executes the program instructions to implement the steps in any of the above-described image template matching method embodiments. Specifically, the electronic device 30 may include, but is not limited to, servers, desktop computers, laptops, tablets, smartphones, etc., and is not limited thereto. Specifically, the processor 32 is used to control itself and the memory 31 to implement the steps in any of the above-described image template matching method embodiments. The processor 32 may also be called a CPU (Central Processing Unit). The processor 32 may be an integrated circuit chip with signal processing capabilities. The processor 32 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor may be a microprocessor or any conventional processor. In addition, the processor 32 may be implemented by integrated circuit chips.

[0063] Therefore, the electronic device 30 acquires an image pyramid based on the target image of the object to be detected, and the outer edge of the object to be detected is rotationally symmetrical about the target angle. The image pyramid contains several sub-images obtained by sampling the target image at different scales, and the resolution of the sub-images is arranged in order from low to high. Based on the matching results of the first sub-image in the image pyramid with the template images of each candidate object, the candidate object in the template image is selected as the target object. Based on the target angle and at least the pose information including the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected, reference information is determined. Based on the reference information, matching is performed on the second sub-image in the image pyramid, and template matching is performed layer by layer with respect to the target image to obtain the template matching result with respect to the target image. Therefore, when the outer edge of the object to be detected is rotationally symmetrical about the target angle, after generating the target object based on the matching results of the first layer sub-image in the image pyramid with the template images of each candidate object, reference information about the target angle and the pose of the target object is generated. Thus, the reference information can retain as many distinguishable features as possible that can be searched by the second layer sub-image of the image pyramid based on the symmetry characteristics of the object to be detected. Therefore, it can improve the accuracy of the target image containing symmetrical objects in template matching while maximizing the matching efficiency.

[0064] Please see Figure 4 , Figure 4 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium 40 of this application. The computer-readable storage medium 40 stores program instructions 41 that can be executed by a processor. The program instructions 41 are used to implement the steps in any of the above-described embodiments of the image template matching method.

[0065] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0066] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0067] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0068] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0069] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0070] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0071] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.

Claims

1. An image template matching method, It is characterized in that include: Based on a target image of the object to be detected, an image pyramid is obtained; wherein the outer edge of the object to be detected is rotationally symmetric about the target angle, and the image pyramid includes a plurality of layers of sub-images obtained by sampling the target image at different scales, and the resolutions of the plurality of layers of sub-images are arranged in order from low to high; Based on the matching results between the sub-images in the first layer of the image pyramid and the template images of the candidate objects, the candidate objects in the template image are selected as target objects; Determine reference information based on the target angle and the posture information of the target object; wherein the posture information at least includes the position coordinates of the target object in the template image and the rotation angle of the target object relative to the object to be detected; The sub-images at the second level in the image pyramid are matched based on the reference information, and template matching on the target image is performed layer by layer to obtain a template matching result on the target image.

2. The method according to claim 1, It is characterized in that The reference information includes at least one new template image generated from the template image of the target object, and the determining of the reference information based on the target angle and the posture information includes: Determining at least one candidate angle based on the rotation angle and the target angle; The template image of the target object is adjusted based on the at least one candidate angle to obtain a new template image; wherein the position coordinates of the target object in the new template image remain unchanged, and the rotation angle of the object to be detected is the candidate angle.

3. The method according to any one of claims 1 or 2, It is characterized in that The matching of the sub-images at the second level in the image pyramid based on the reference information includes: In response to the reference information including at least one new template image generated from the template image of the target object, obtaining matching results between the sub-images at the second layer in the image pyramid and the target objects in each of the new template images; Based on the matching result, a target object in the new template image is selected as an object to be matched with the sub-image at the third level in the image pyramid.

4. The method according to any one of claims 1 or 2, It is characterized in that The determining of reference information based on the target angle and the posture information of the target object includes: Based on the target angle and the posture information of the target object, determine a position search range for matching the sub-image of the second layer of the target object in the image pyramid; wherein the position search range represents a set of position coordinates for matching the object to be detected in the sub-image with the template image containing the target object; And / or, based on the target angle and the posture information of the target object, determine the angle search range for matching the target object with the sub-image in the second layer of the image pyramid; wherein the angle search range represents a set of rotation angles for matching the object to be detected in the sub-image with the template image containing the target object.

5. The method according to claim 4, It is characterized in that The determining, based on the posture information of the target object, a position search range for matching the sub-image of the second layer of the target object in the image pyramid includes: Acquire a resolution ratio between the sub-image of the second layer and the sub-image of the first layer in the image pyramid, and determine a preset magnification ratio based on the target angle; wherein the preset magnification ratio represents an enlargement step of the position search range, and the preset magnification ratio is negatively correlated with the target angle; The position search range is determined based on the position coordinates of the target object in the template image, the resolution ratio, and the preset magnification.

6. The method according to claim 4, It is characterized in that The determining, based on the posture information of the target object, an angle search range for matching the sub-image of the target object in the second layer of the image pyramid comprises: Obtaining the angle step lengths of the sub-images at the first layer in the image pyramid that are matched with the template images of the candidate objects, and determining a preset multiple based on the target angle; wherein the preset multiple represents the enlarged step length of the angle step length, and the preset multiple is negatively correlated with the target angle; The angle search range is determined based on the rotation angle of the target object relative to the object to be detected, the angle step, and the preset multiple.

7. The method according to claim 1, It is characterized in that The selecting the candidate object in the template image as the target object based on the matching results between the sub-images in the first layer of the image pyramid and the template images of the candidate objects respectively includes: Based on the matching results of the sub-images in the first layer of the image pyramid and the template images of the candidate objects, the maximum similarity between the edge features of the object to be detected and the edge features of the candidate objects in the template image at each position coordinate is obtained, and the rotation angle corresponding to the maximum similarity in each position coordinate is obtained; The target object is determined based on the position coordinates corresponding to the maximum values ​​between the maximum similarities and the rotation angle corresponding to the position coordinates.

8. The method according to claim 1, It is characterized in that The matching result includes the maximum similarity between the edge feature of the object to be detected at each position coordinate and the edge feature of the candidate object in the template image, and the rotation angle corresponding to the maximum similarity in each position coordinate. After determining the target object based on the maximum value between the maximum similarities, determining the reference information based on the target angle and the posture information of the target object includes: Based on the rotation angle corresponding to the maximum value between the target angle and each of the maximum similarities, determining at least one preset angle for screening the rotation angle corresponding to the maximum similarity in each position coordinate; Based on the position coordinates of the rotation angle corresponding to the maximum similarity that are consistent with the preset angle, a new template image is obtained as the reference information.

9. An electronic device, It is characterized in that It comprises a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement the image template matching method according to any one of claims 1 to 8.

10. A computer-readable storage medium having program instructions stored thereon, It is characterized in that When the program instructions are executed by a processor, the image template matching method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Image matching method, electronic equipment and storage medium

    CN121437921A

  • Control identification method, electronic equipment and computer readable storage medium

    CN121680674A