Fast rotating template matching method and system and medium

By constructing an image pyramid with the maximum number of layers and increasing the angle step size layer by layer, combined with the candidate matching angle and its 180-degree difference angle, the problem of traditional rotation template matching method taking a long time is solved, and a fast and accurate rotation template is achieved. match.

CN118674953APending Publication Date: 2024-09-20HEFEI I TEK OPTOELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410895897.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

The traditional rotating template matching method takes a long time, which limits its application in industrial scenarios. The existing technology has deficiencies in the number of layers and angle step settings of the image pyramid, resulting in problems with matching speed and accuracy.

Method used

By constructing an image pyramid with the maximum number of layers, the number of layers is determined based on the resolution of the template image, and the angle step is increased layer by layer. A wider angle range is formed by combining the candidate matching angle and its 180-degree difference angle to improve matching speed and accuracy. .

Benefits of technology

It achieves a significant improvement in the speed of rotation template matching while ensuring matching accuracy, reduces the number of rotation matching times and unit time, and enhances the robustness and speed of matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674953A
    Figure CN118674953A
Patent Text Reader

Abstract

The invention discloses a fast rotation template matching method and system and a medium, and the method comprises the steps: constructing an image pyramid of the maximum layer number of a template image, the maximum layer number being the layer number corresponding to the minimum resolution under a preset parameter; rotating and matching the same-layer image of the image pyramid of the to-be-matched image according to the top-layer image of the image pyramid of the template image, and carrying out traversal search to obtain a first candidate matching angle; determining an angle interval set of a neighborhood corresponding to the first candidate matching angle and the 180-degree difference angle of the first candidate matching angle, and obtaining a second candidate matching angle; and searching the image pyramid of the to-be-matched image downwards layer by layer until a target matching angle is obtained. Compared with the prior art, the method has the advantages that a higher image pyramid can be established, the number of rotation matching times is reduced, and a higher matching speed is realized; abnormal changes caused by downsampling can be effectively avoided, the matching accuracy is ensured while the matching speed of the pyramid layer number is increased, and finally robust and rapid rotating template matching is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of template matching, and in particular relates to a fast rotating template matching method, system and medium. Background Art

[0002] Template matching refers to the process of comparing a template image with the image to be matched, finding the part of the image to be matched that is similar to the template image by calculating the similarity between the template image and the target in the image to be matched, and realizing target recognition and positioning. Rotational template matching means that the object in the image to be matched is rotated compared to the template image. In addition to the position of the target, the matching result also includes the rotation angle of the target compared to the template. The traditional rotational template matching method is time-consuming, which limits its application in industrial scenarios.

[0003] Patent document CN110210565B discloses a method for implementing normalized cross-correlation image template matching. Yang Qi et al. proposed to establish an image pyramid by downsampling the template image and the image to be matched. First, a traversal search is performed on the top pyramid image of the image to be matched to obtain all candidate matches whose similarity is greater than a set threshold. The specific process is: according to a preset angle, the top pyramid image of the template image is rotated to obtain a rotated template image, and the similarity between the rotated template image and the image to be matched is calculated. The candidate matches are screened, and the matching result with the highest similarity is retained at each matching position. The screened matching results are mapped to the next layer of the pyramid, and local matching is performed in the neighborhood of the mapped position to obtain new candidate matches with the maximum similarity in each local area and greater than the set threshold; the above operation is repeated until the matching is completed at the bottom of the pyramid to obtain the final matching result. However, when Yang Qi et al. established the image pyramid, they determined the number of layers of the pyramid according to the length, width and pixel value variance of the template image, and the number of layers of the image pyramid established by this method was low; in addition, the angle step size of the template rotation matching at each layer of the pyramid was the same, which limited the matching speed.

[0004] Patent document CN117115487B discloses a template matching method, template matching system and storage medium. Lv Yanjia et al. also used the same method as Yang Qi et al. to establish an image pyramid by downsampling the template image and the image to be matched. After completing the traversal search on the top-level pyramid image of the image to be matched, the second angle step size for local matching on the next-level pyramid image is determined according to the first angle step size of the top level, and the candidate matching on this level of pyramid image is obtained, and the final matching result is obtained by analogy. However, the second angle step size of Lv Yanjia et al. when matching the rotated template at the middle pyramid level is too small, which has limited improvement on the matching speed.

[0005] Patent document CN111738320B discloses a method for identifying occluded artifacts based on template matching. Liu Zhenyu et al. proposed to first search the image to be matched with the original template image. If the calculated similarity is low, the template image is rotated to 360° in increments of 10°, and the similarity between the template image and the image to be matched at each angle is calculated in turn, and the match is determined based on the similarity. However, Liu Zhenyu et al. rotated the template image during the search process, which increased the useless time consumption in the matching process; in addition, since the image pyramid was not used, the matching speed was very slow when the template image and the image to be matched were large; the 10° angle step was too large, making it difficult to ensure matching accuracy.

[0006] Therefore, in order to solve the above problems, the present invention provides a fast rotation template matching method, system and medium, which improve the matching speed while ensuring the matching accuracy. Summary of the invention

[0007] The purpose of the present invention is to overcome the above problems existing in the prior art and to provide a fast rotating template matching method, system and medium.

[0008] In order to achieve the above technical objectives and the above technical effects, the present invention is implemented through the following technical solutions: A fast rotation template matching method, comprising: Construct an image pyramid with a maximum number of layers of the template image, where the maximum number of layers is the number of layers corresponding to the minimum resolution under preset parameters; According to the top layer image of the image pyramid of the template image, the image of the same layer of the image pyramid of the image to be matched is rotated and matched, and a matching angle that meets the similarity threshold and has the highest similarity is selected as the first candidate matching angle; Collect the first candidate matching angle, use the first candidate matching angle and its 180-degree difference angle as the centers of two angle intervals, use four times the corresponding angle step of the second top layer as the span of the two angle intervals, and use the set of the two angle intervals as the second top layer angle interval of the second top layer image of the image pyramid to be matched, so as to search for the second candidate matching angle; Search the image pyramid of the image to be matched layer by layer, take the candidate matching angle of the previous layer as the center of the non-top angle interval of the current layer, and take twice the corresponding angle step of the current layer as the span of the non-top angle interval of the current layer, until the candidate matching angles corresponding to all positions of the bottom image of the image pyramid of the image to be matched are obtained.

[0009] Furthermore, the maximum number of layers determination method includes: obtaining resolution information of the original template image, determining the minimum resolution of each layer of the corresponding image pyramid that can meet preset parameters, and taking the number of layers corresponding to the minimum resolution as the maximum number of layers.

[0010] Furthermore, the rotation matching includes: gradually rotating the top image of the image pyramid of the template image according to a preset angle range and a level-corresponding angle step, and traversing and searching the same-level images of the image pyramid of the image to be matched.

[0011] Furthermore, the method for calculating the angle step corresponding to each level includes: setting the angle step corresponding to the bottom layer of the image pyramid, and increasing the angle step corresponding to each level from the bottom layer of the image pyramid upward layer by layer to obtain the angle step corresponding to each level.

[0012] Furthermore, the angle step corresponding to each level increases layer by layer starting from the bottom layer of the image pyramid. Specifically, the angle step corresponding to the current layer of the pyramid is twice the angle step corresponding to the next layer.

[0013] Furthermore, searching for the second candidate matching angle includes: gradually rotating the image of the image pyramid of the template image according to the angle interval of the second top layer and the corresponding angle step of the second top layer, and searching the image of the same layer of the image pyramid of the image to be matched.

[0014] Furthermore, searching the image pyramid of the image to be matched layer by layer downward includes: gradually rotating the image of the image pyramid of the template image according to the non-top angle interval of the current layer and the corresponding angle step of the current layer, and searching the image of the same layer of the image pyramid of the image to be matched.

[0015] Furthermore, the number of layers of the image pyramid of the image to be matched is the same as that of the image pyramid of the template image.

[0016] The present invention also provides a fast rotation template matching system, comprising: A pyramid construction module, used to construct an image pyramid with a maximum number of layers of the template image, where the maximum number of layers is the number of layers corresponding to the minimum resolution under preset parameters; A first matching module is used to rotate and match the image of the same layer of the image pyramid of the image to be matched according to the top layer image of the image pyramid of the template image, and select a matching angle that meets a similarity threshold and has the highest similarity as a first candidate matching angle; The second matching module is used to collect the first candidate matching angle, respectively use the first candidate matching angle and its 180-degree difference angle as the centers of two angle intervals, use four times the corresponding angle step of the second top layer as the span of the two angle intervals, and use the set of the two angle intervals as the second top layer angle interval of the second top layer image of the image pyramid of the image to be matched, thereby searching for the second candidate matching angle; The third matching module is used to search the image pyramid of the image to be matched layer by layer, taking the candidate matching angle of the previous layer as the center of the non-top angle interval of the current layer, and taking twice the corresponding angle step of the current layer as the span of the non-top angle interval of the current layer, until the candidate matching angles corresponding to all positions of the bottom image of the image pyramid of the image to be matched are obtained.

[0017] The present invention also provides a computer-readable storage medium, comprising a computer program, wherein the computer program implements the above-mentioned matching method when executed by a processor.

[0018] The beneficial effects of the present invention are: (1) The present invention determines the maximum number of pyramid layers by obtaining the resolution information of the original template image. Compared with the prior art, a higher image pyramid can be established. In addition, the higher the number of layers, the larger the angle step of the corresponding layer. As the number of layers increases, the corresponding angle step increases exponentially, which not only effectively reduces the number of rotational matches of the highest layer, but also reduces the sum of the number of rotational matches of all layers of the pyramid. In addition, due to the reduction in the resolution of the high-level images of the pyramid, the unit time of a single rotational match is also reduced, thereby achieving a faster matching speed.

[0019] (2) The present invention can effectively avoid abnormal changes caused by downsampling by obtaining the first candidate matching angle and the second candidate matching angle and combining them with the predetermined difference angle neighborhood, thereby improving the matching speed while ensuring the matching accuracy while increasing the number of pyramid levels, and finally achieving robust and fast rotation template matching.

[0020] (3) In the process of obtaining the second candidate matching angle, the present invention forms the first candidate matching angle neighborhood and the predetermined difference angle neighborhood by combining the first candidate matching angle at the top layer of the pyramid with the corresponding angle step at the top layer, thereby expanding the angle interval range and further ensuring the accuracy of matching. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 is a flow chart of the matching method in the present invention; Figure 2 is a schematic diagram of an image pyramid in the present invention; Figure 3 is a schematic diagram of an image pyramid in the present invention; Figure 4 It is a structural block diagram of the matching system in the present invention. DETAILED DESCRIPTION

[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] like Figure 1 As shown, this embodiment first provides a fast rotation template matching method, and the matching method specifically includes the following steps: Step 1: construct an image pyramid with a maximum number of layers of the template image, where the maximum number of layers is the number of layers corresponding to the minimum resolution under preset parameters.

[0024] An image pyramid is a collection of images consisting of sub-images of different resolutions obtained by continuously downsampling an image. Each downsampling will halve the width and height of the image. The bottom of the pyramid is the original image. The higher the pyramid level, the smaller the image and the lower the resolution. Figure 2 , 3 shown.

[0025] In template matching, the higher the number of image pyramid layers, the smaller the template image and the image to be matched at the top of the pyramid are, and the faster the matching speed is. However, if the number of pyramid layers is too high, the number of pixels of the template image at the top of the pyramid will be too few, and it is impossible to match correctly. It is necessary to increase the number of pyramid layers as much as possible to improve the matching efficiency under the premise of ensuring matching accuracy. In the prior art, when calculating the number of pyramid layers, an empirical parameter is preset, so that the width and height of the template image at the top of the pyramid are both greater than this empirical parameter. However, if the width and height ratio of the template image is large, that is, the template image is a long and narrow rectangle, the number of pyramid layers obtained by this method will be too small, and the number of pixels of the template image at the top of the pyramid will be too many, and the matching efficiency will be limited. Therefore, the present invention determines the number of pyramid layers according to the resolution size of the template image, rather than the direct judgment of the width and height.

[0026] Template matching requires sliding the template image on the image to be matched and calculating the similarity of each position. The time complexity of the algorithm is related to the size of the template image and the size of the image to be matched. Therefore, constructing an image pyramid of the template image and the image to be matched can reduce the resolution and significantly improve the matching speed.

[0027] In order to obtain the maximum number of layers, the specific judgment method includes: obtaining the resolution information of the original template image, judging the minimum resolution of each layer of the corresponding image pyramid that can meet the preset parameters, and taking the number of layers corresponding to the minimum resolution as the maximum number of layers as follows: As can be seen from the above, the image pyramid is a set of images consisting of sub-images of different resolutions obtained by continuous downsampling of an image. Each downsampling will halve the width and height of the image, so the resolution ratio of the upper and lower layers is 4. Therefore, the maximum number of pyramid layers n can be calculated from the width w and height h of the original template image. The specific formula is: (1) Wherein, C represents a preset empirical parameter. When the width-to-height ratio of the template image is large, the number of pyramid layers calculated by the above formula is higher than that of the existing technology, and the matching speed is faster.

[0028] Step 2: Rotate and match the image of the same layer of the image pyramid of the image to be matched according to the top layer image of the image pyramid of the template image, and select the matching angle that meets the similarity threshold and has the highest similarity as the first candidate matching angle.

[0029] On the top pyramid, the template image is rotated according to the specified angle range and angle step, and each rotated template image is used to traverse and search on the image to be matched, so that the matching angle corresponding to the matching result that meets the requirements at all positions of the top image of the image pyramid of the image to be matched is used as the first candidate matching angle. In order to determine the first candidate matching angle corresponding to all positions of the top image of the image pyramid of the image to be matched, all matching results whose matching similarity at all positions of the top image of the image pyramid of the image to be matched is greater than a preset similarity threshold can be screened, and the matching angle with the highest similarity is retained as the first candidate matching angle.

[0030] In order to rotate and match the image in the same layer of the image pyramid of the image to be matched, as a preferred implementation, the top layer image of the image pyramid of the template image can be gradually rotated according to a preset angle range and a corresponding angle step of the level, and the image in the same layer of the image pyramid of the image to be matched is traversed and searched.

[0031] As a preferred implementation, the number of layers of the image pyramid of the image to be matched is the same as that of the image pyramid of the template image.

[0032] For reasonable setting, as a preferred implementation, the method for calculating the angle step corresponding to each level includes: setting the angle step corresponding to the bottom layer of the image pyramid, and increasing the angle step corresponding to each level from the bottom layer of the image pyramid upward layer by layer to obtain the angle step corresponding to each level. When setting specifically, the angle step corresponding to the current layer of the pyramid is twice the angle step corresponding to the next layer, as follows: The smaller the angle step size in the rotation template matching, the higher the matching accuracy of the target angle, but the more times the template needs to be rotated, the slower the matching; the smaller the image, the less sensitive it is to rotation, and the larger the minimum angle that can identify the image rotation. Since the width and height of the template image in the upper pyramid in the image pyramid will be reduced to half of the lower layer, and the size will be reduced to one-fourth, the rotation angle step size of the template image on each layer of the pyramid can also be increased by 2 times accordingly, reducing the number of matches and increasing the matching speed. Assume that the angle step size of the i-th layer pyramid is , the angle step of the n-th pyramid is , then: (2) in, Represents the bottom layer angle step of the pyramid, i.e. the original template image. This value can be set manually. For example, if the bottom layer angle step is set to 1°, it means that the rotation angle step of the original template image at the bottom layer of the pyramid is 1°, the angle step of the second layer of the pyramid is 2°, and so on. The angle step of the fourth layer of the pyramid is 8°.

[0033] Step 3: Collect the first candidate matching angle, take the first candidate matching angle and its 180-degree difference angle as the centers of the two angle intervals, take four times the angle step size corresponding to the second top layer as the span of the two angle intervals, and take the set of the two angle intervals as the second top layer angle interval of the second top layer image of the image pyramid to be matched, so as to search for the second candidate matching angle, that is, the second candidate matching angle corresponding to all positions of the second top layer image of the image pyramid to be matched.

[0034] According to the first candidate matching angle, relevant upper and lower limits are determined as the first candidate matching angle neighborhood, and a predetermined difference angle is calculated according to the first candidate matching angle according to the predetermined difference, so as to determine the relevant upper and lower limits as the predetermined difference angle neighborhood, and then the first candidate matching angle neighborhood and the predetermined difference angle neighborhood are jointly formed into an angle interval set, and the angle interval set is searched, so as to use the matching angle corresponding to the matching result that meets the requirements at all positions of the second top layer image of the image pyramid of the image to be matched as the second candidate matching angle.

[0035] The number of pyramid layers calculated by formula (1) is relatively high. At this time, the template image and the image to be matched at the top of the pyramid have low resolutions, and the image pixel values ​​may change abnormally due to downsampling. At the same time, when the number of pyramid layers is relatively high, the angle step of the top of the pyramid obtained by formula (2) is also too large. For example, when the angle step of the bottom layer is set to 1°, the angle step of the 5th layer of the pyramid is 16°. The excessively large angle step and the low resolution of the template image and the image to be matched result in greater similarity at the wrong matching angle when matching at the top of the pyramid.

[0036] Therefore, in order to select the number of pyramid layers and angle step according to the above formula (1) and formula (2) to improve the matching speed while ensuring the matching accuracy, in addition to selecting the first candidate matching angle neighborhood, it is also necessary to introduce a predetermined difference angle neighborhood, that is, to search other angle intervals and take the angle with the greatest similarity in the search results of multiple angle intervals as the new candidate matching angle. The predetermined difference is usually 180°, especially when the template image is a long and narrow rectangle.

[0037] Therefore, when i=n-1, that is, the second layer from top to bottom of the pyramid is matched, the angle interval of the second top layer includes the neighborhood of the angle with a difference of 180° in addition to the first candidate matching angle, and because the image resolution of the second top layer of the pyramid is relatively low, each angle interval is slightly larger than that of other lower pyramid levels. Assuming that the candidate matching angle is θ, the angle interval of the second top layer is:

[0038] As a specific implementation method for searching for the second candidate matching angle, the second top layer image of the image pyramid of the template image can be gradually rotated according to the second top layer angle interval and the second top layer corresponding angle step, and the image pyramid of the same layer of the image to be matched is searched.

[0039] Step 4: Search the image pyramid of the image to be matched layer by layer, take the candidate matching angle of the previous layer as the center of the non-top angle interval of the current layer, and take twice the corresponding angle step of the current layer as the span of the non-top angle interval of the current layer, until the candidate matching angles corresponding to all positions of the bottom image of the image pyramid of the image to be matched are obtained, that is, the target matching angles.

[0040] According to the candidate matching angles of the previous layer, the relevant upper and lower limits are determined as the non-top angle range of the current layer. Each time, the horizontal and vertical coordinates of the corresponding position of the matching result of the previous layer of the image pyramid of the image to be matched are multiplied by 2 to obtain the corresponding position of the rough matching result of the current layer. Then, a search is performed in the non-top angle range of the corresponding position of the current layer. Finally, the matching angle corresponding to the matching result that meets the requirements at all positions of the bottom image of the image pyramid of the image to be matched is taken as the target matching angle.

[0041] From the above, we can see that if , then it is only necessary to match the non-sub-top angle interval of the current layer, and the non-sub-top angle interval is:

[0042] As a specific implementation method of searching the image pyramid for the image to be matched layer by layer, the image pyramid sub-top layer image of the template image can be gradually rotated according to the non-sub-top layer angle interval of the current layer and the corresponding angle step of the current layer, and the image of the same layer of the image pyramid of the image to be matched is searched.

[0043] The following is an explanation of the number of pyramid layers based on specific cases: Assuming that the size of the initial template image is 240x80, the prior art proposed by Yang Qi et al. in the background technology requires that the width and height of the highest pyramid template image be at least 8 pixels. The present invention can set the above parameter C to 64, that is, the size of the highest pyramid template image is required to be at least 64 pixels. Obviously, the highest pyramid template image that meets the restrictions of the method of Yang Qi et al. also meets the restrictions of the present method. After downsampling the template image, an image pyramid as shown in the following table can be obtained: Table 1 Template image resolution size at different pyramid levels Pyramid levels Corresponding level template image size 5 15x5 4 30x10 3 60x20 2 120x40 1 240x80 As shown in Table 1, the size of the template image of the 5th layer of the pyramid is 15x5, its width is less than 8 pixels, and its area is 75 pixels. Therefore, the method of Yang et al. can only build a 4-layer pyramid, but the method can build a 5-layer pyramid. The higher the number of pyramid layers, the faster the matching speed. Therefore, the matching speed of this method is faster for this template image.

[0044] The following is an explanation of the rotation template matching with a specific case: Assume that there is only one object in the image to be matched, the number of pyramid layers is 4, matching is performed within a 360° angle range, and the angle step is set to 1°. Then the angle step of each layer of the pyramid is 1°, 2°, 4°, and 8° from low to high. The matching steps are as follows: (1) Rotate the template image at the fourth layer of the pyramid within a 360° angle range with an angle step of 8°, and use each rotated template image to calculate the similarity with the image to be matched, and obtain the matching result with the highest similarity. Here, it is assumed that the corresponding first candidate matching angle is 16°.

[0045] (2) At the third level of the pyramid, the angle step is 4°. Since i=n-1, in addition to considering the angle with an angle difference of 180°, the range of the neighborhood interval is a little larger, and the candidate matching angle neighborhood is , after rotating the template image at 10 angles, 8°, 12°, 16°, 20°, 24°, 188°, 192°, 196°, 200°, and 204°, the similarity of the image to be matched is calculated, and the matching result with the highest similarity is obtained. Here, it is assumed that the corresponding second candidate matching angle is 20°.

[0046] (3) At the second layer of the pyramid, the angular step size is 2°. Since i < n - 1, the candidate matching angle neighborhood is [18, 22]. Actually, the template image is rotated at 18°, 20°, and 22° for a total of 3 angles, and then the similarity is calculated for the image to be matched, obtaining the matching result with the highest similarity. Here, it is assumed that the corresponding candidate matching angle is 22°.

[0047] (4) At the first layer of the pyramid, the angular step size is 1°. Since i < n - 1, the candidate matching angle neighborhood is [22, 23]. Actually, the template image is rotated at 21°, 22°, and 23° for a total of 3 angles, and then the similarity is calculated for the image to be matched, obtaining the matching result with the highest similarity. Here, it is assumed that the corresponding candidate matching angle is 23°, and the matching ends. The final target matching angle is 23°.

[0048] The following will compare and explain each existing technology in combination with cases: Assume that there is only one object in the image to be matched, the number of pyramid layers is 4, and the matching is performed within the 360° angular range with an angular step size of 1° set: Taking the existing technology proposed by Yang Li et al. in the background technology as the comparison object, the angular step size of Yang Li et al.'s method is the same at each pyramid level, and the matching is traversed at the top layer of the pyramid. Therefore, 360 angles need to be matched; while in other pyramid layers, the angular neighborhood is fixed at [θ - 4, θ + 4]. Therefore, 9 angles need to be matched. In this method, the angular step size increases at each pyramid level. The angular step size is 8° at the top layer of the pyramid. Therefore, 45 angles need to be matched; at the third layer of the pyramid, because the angular neighborhood range with a candidate matching angle difference of 180° needs to be considered, 10 angles need to be matched at this layer; then only 3 angles need to be matched at each subsequent pyramid level. The specific results are as follows in the table. It can be found that the number of angles that need to be matched by this method to complete the matching is much less than that of Yang Li's method, and the matching speed is faster. In addition, if the aspect ratio of the template image is relatively high, the number of pyramid layers that this method can select may also be higher, and then the matching speed can be further improved.

[0049] Table 2 Comparison of the number of rotation template matching angles with Yang Li's method Pyramid levels The number of rotation matching angles required by Yang Qi's method The number of rotation matching angles required by this method 4 360 45 3 9 10 2 9 3 1 9 3 Taking the prior art proposed by Lv Yanjia et al. in the background technology as a comparison object, since it does not introduce in detail how the angle step of each pyramid level is determined, an example is given in its patent as follows: "For example, assuming that the best matching position of the first-level first down-sampled image is (50, 60), the best matching angle is 40°, and the first angle step is 2°, and the best matching position (50, 60) is mapped to the position of the second-level first down-sampled image (100, 120). The template matching system can further search for the best matching position of the second-level second down-sampled image in the second-level first down-sampled image within a square range with (90, 110) as the upper left corner and (110, 130) as the lower right corner in the second-level first down-sampled image based on a preset position range error (for example, 10 pixels), based on an angle search range of 38°~42° and a second angle step of 0.4°. From the above example, we can find that between two adjacent pyramid levels, the angle step size is reduced from 2° to 0.4°, and the angle neighborhood range is [θ-2,θ+2], and the number of angles that need to be matched is 10. If the same rotation matching strategy is used at each pyramid level, the number of angles that need to be matched by this method is also less than that of Lv Yanjia et al.

[0050] Taking the prior art proposed by Liu Zhenyu et al. in the background technology as a comparison object, since they do not use the image pyramid technology, the matching speed of this method must be much faster than their method.

[0051] like Figure 4 As shown, the second aspect of the present invention also provides a fast rotation template matching system, comprising: The pyramid construction module is used to construct an image pyramid with a maximum number of layers of the template image, where the maximum number of layers is the number of layers corresponding to the minimum resolution under preset parameters. For specific operations, please refer to the relevant matching method in step 1.

[0052] The first matching module is used to rotate and match the image of the same layer of the image pyramid of the image to be matched according to the top layer image of the image pyramid of the template image, and select the matching angle that meets the similarity threshold and has the highest similarity as the first candidate matching angle; the specific operation can refer to the relevant matching method in step 2.

[0053] The second matching module is used to collect the first candidate matching angle, and use the first candidate matching angle and its 180-degree difference angle as the centers of the two angle intervals, four times the corresponding angle step of the second top layer as the span of the two angle intervals, and use the set of the two angle intervals as the second top layer angle interval of the second top layer image of the image pyramid to be matched, thereby searching for the second candidate matching angle; for specific operations, please refer to the relevant matching method in step three.

[0054] The third matching module is used to search the image pyramid of the image to be matched layer by layer, taking the candidate matching angle of the previous layer as the center of the non-top angle interval of the current layer, and taking twice the corresponding angle step of the current layer as the span of the non-top angle interval of the current layer, until the candidate matching angles corresponding to all positions of the bottom image of the image pyramid of the image to be matched are obtained; the specific operation can refer to the relevant matching method in step 4.

[0055] The third aspect of the present invention further provides a computer-readable storage medium, comprising a computer program, wherein the computer program implements the above-mentioned matching method when executed by a processor.

[0056] In practical applications, the computer-readable storage medium may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device.

[0057] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0058] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0059] Computer program code for performing the operation of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0060] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0061] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.

Claims

1. A fast rotation template matching method, characterized in that: include: Construct an image pyramid with a maximum number of layers of the template image, where the maximum number of layers is the number of layers corresponding to the minimum resolution under preset parameters; According to the top layer image of the image pyramid of the template image, the image of the same layer of the image pyramid of the image to be matched is rotated and matched, and a matching angle that meets the similarity threshold and has the highest similarity is selected as the first candidate matching angle; Collect the first candidate matching angle, use the first candidate matching angle and its 180-degree difference angle as the centers of two angle intervals, use four times the corresponding angle step of the second top layer as the span of the two angle intervals, and use the set of the two angle intervals as the second top layer angle interval of the second top layer image of the image pyramid to be matched, so as to search for the second candidate matching angle; Search the image pyramid of the image to be matched layer by layer, take the candidate matching angle of the previous layer as the center of the non-top angle interval of the current layer, and take twice the corresponding angle step of the current layer as the span of the non-top angle interval of the current layer, until the candidate matching angles corresponding to all positions of the bottom image of the image pyramid of the image to be matched are obtained.

2. A fast rotation template matching method according to claim 1, characterized in that: The maximum number of layers determination method includes: obtaining resolution information of the original template image, determining the minimum resolution of each layer of the corresponding image pyramid that can meet the preset parameters, and taking the number of layers corresponding to the minimum resolution as the maximum number of layers.

3. A fast rotation template matching method according to claim 1, characterized in that: The rotation matching includes: gradually rotating the top image of the image pyramid of the template image according to a preset angle range and a corresponding angle step of the level, and traversing and searching the same layer image of the image pyramid of the image to be matched.

4. A fast rotation template matching method according to claim 3, characterized in that: The method for calculating the angle step corresponding to each level includes: setting the angle step corresponding to the bottom layer of the image pyramid, and increasing the angle step corresponding to each level from the bottom layer of the image pyramid upward layer by layer to obtain the angle step corresponding to each level.

5. A fast rotation template matching method according to claim 4, characterized in that: The corresponding angle step of each level increases from the bottom layer of the image pyramid upwards. Specifically, the corresponding angle step of the current layer of the pyramid is twice the corresponding angle step of the next layer.

6. A fast rotation template matching method according to claim 5, characterized in that: The second candidate matching angle is obtained by searching: gradually rotating the image of the image pyramid of the template image according to the angle interval of the second top layer and the angle step corresponding to the second top layer, and searching the image of the same layer of the image pyramid of the image to be matched.

7. A fast rotation template matching method according to any one of claims 1 to 6, characterized in that: Searching the image pyramid of the image to be matched layer by layer includes: gradually rotating the image pyramid sub-top layer image of the template image according to the non-sub-top layer angle interval of the current layer and the corresponding angle step of the current layer, and searching the image pyramid of the same layer of the image to be matched.

8. A fast rotation template matching method according to claim 7, characterized in that: The number of layers of the image pyramid of the image to be matched is the same as that of the image pyramid of the template image.

9. A fast rotating template matching system, characterized in that: include: A pyramid construction module, used to construct an image pyramid with a maximum number of layers of the template image, where the maximum number of layers is the number of layers corresponding to the minimum resolution under preset parameters; A first matching module is used to rotate and match the image of the same layer of the image pyramid of the image to be matched according to the top layer image of the image pyramid of the template image, and select a matching angle that meets a similarity threshold and has the highest similarity as a first candidate matching angle; The second matching module is used to collect the first candidate matching angle, respectively use the first candidate matching angle and its 180-degree difference angle as the centers of two angle intervals, use four times the corresponding angle step of the second top layer as the span of the two angle intervals, and use the set of the two angle intervals as the second top layer angle interval of the second top layer image of the image pyramid of the image to be matched, thereby searching for the second candidate matching angle; The third matching module is used to search the image pyramid of the image to be matched layer by layer, taking the candidate matching angle of the previous layer as the center of the non-top angle interval of the current layer, and taking twice the corresponding angle step of the current layer as the span of the non-top angle interval of the current layer, until the candidate matching angles corresponding to all positions of the bottom image of the image pyramid of the image to be matched are obtained.

10. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program is executed by a processor, the matching method according to any one of claims 1 to 8 is implemented.