Image similarity matching method based on template

By calculating multiple rotation angles, sliding window matching and iterative calculations, the problem of reduced matching accuracy when images are rotated is solved, and high-accuracy similar matching under rotation is achieved, which is suitable for machine vision inspection systems.

CN114139620BActive Publication Date: 2024-10-15XIAMEN HUALIAN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111416863.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-25
Publication Date
2024-10-15
Estimated Expiration
2041-11-25

AI Technical Summary

Technical Problem

In the existing technology, the matching accuracy decreases when the image is rotated, making it difficult to effectively perform similar matching.

Method used

By acquiring the observation image and calculating multiple rotation angles according to the preset rotation parameters, the template image is rotated, a sliding window is used for similarity matching, the rough deflection angle is determined, and the precise deflection angle is calculated iteratively to improve the matching accuracy.

Benefits of technology

Achieve effective similarity matching when rotating images, improve matching accuracy, and are suitable for machine vision inspection systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114139620B_ABST
    Figure CN114139620B_ABST
Patent Text Reader

Abstract

The present invention discloses a template-based image similarity matching method, wherein the method comprises: acquiring an observed image, and calculating a plurality of corresponding rotation angles according to preset rotation parameters, and rotating a template image corresponding to the observed image according to the rotation angles; performing similarity matching between the template image after each rotation and the observed image in a sliding window manner to obtain the similarity corresponding to each window, and taking the rotation angle corresponding to the window with the highest similarity as a rough deflection angle; performing iterative calculation according to the rough deflection angle to determine a precise deflection angle, and calculating the position coordinates corresponding to the window under the precise deflection angle and the similarity between the observed image and the template image under the window; and being able to perform effective similarity matching on the image when the image is rotated, thereby improving the matching accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a template-based image similarity matching method. Background Art

[0002] In daily life and production, we often encounter situations where we need to find similar parts based on specified images.

[0003] In the related art, when similarity matching is performed based on a template, if the observed image is rotated, the matching confidence will drop sharply. In other words, this matching method is only effective when the image is not rotated or the rotation angle is slight. When the rotation angle is large, the matching result will be inaccurate. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems in the above-mentioned technology to a certain extent. To this end, one object of the present invention is to provide a template-based image similarity matching method, which can effectively perform similarity matching on images when the images are rotated and improve the matching accuracy.

[0005] To achieve the above-mentioned purpose, the first aspect of the present invention proposes a template-based image similarity matching method, including the following steps: acquiring an observed image, and calculating a corresponding plurality of rotation angles according to preset rotation parameters, and rotating the template image corresponding to the observed image according to the rotation angles; performing similarity matching between the template image after each rotation and the observed image in a sliding window manner to obtain the similarity corresponding to each window, and taking the rotation angle corresponding to the window with the highest similarity as a rough deflection angle; performing iterative calculation according to the rough deflection angle to determine the precise deflection angle, and calculating the position coordinates corresponding to the window at the precise deflection angle and the similarity between the observed image and the template image under the window.

[0006] According to the template-based image similarity matching method of the embodiment of the present invention, first, an observed image is acquired, and a corresponding plurality of rotation angles are calculated according to preset rotation parameters, and a template image corresponding to the observed image is rotated according to the rotation angles; then, the template image after each rotation is similarly matched with the observed image in a sliding window manner to obtain the similarity corresponding to each window, and the rotation angle corresponding to the window with the highest similarity is taken as a rough deflection angle; then, an iterative calculation is performed according to the rough deflection angle to determine the precise deflection angle, and the position coordinates corresponding to the window under the precise deflection angle and the similarity between the observed image and the template image under the window are calculated; this enables effective similarity matching of images when the images are rotated, thereby improving the matching accuracy.

[0007] In addition, the template-based image similarity matching method proposed in the above embodiment of the present invention may also have the following additional technical features:

[0008] Optionally, after acquiring the observed image, the method further includes: acquiring mask information, and masking corresponding areas of the observed image and the template image according to the mask information.

[0009] Optionally, before performing similarity matching between the template image and the observed image after each rotation in a sliding window manner, the method further includes: acquiring a scaling parameter, and scaling the observed image and the template image according to the scaling parameter.

[0010] Optionally, before performing iterative calculation according to the rough deflection angle, the method further includes: restoring the scaled image; the image restoration is performed according to the following formula:

[0011] Point coarse (x,y)={(Point′.X+0.5)*zF, (Point′.Y+0.5)*zF}

[0012] Among them, Point coarse (x, y) represents the pixel coordinate information after restoration, Point′.X represents the X-axis value of the pixel coordinate before restoration, Point′.Y represents the Y-axis value of the pixel coordinate before restoration, and zF represents the scaling parameter.

[0013] Optionally, similarity matching is performed according to the following formula:

[0014]

[0015] Among them, R represents the similarity, I T ′ represents the template image after rotation and mask processing, I′ O-cur Represents the current window of the observed image after mask processing.

[0016] Optionally, iterative calculation is performed according to the rough deflection angle, including: S1, taking the rough deflection angle as the current iteration center; S2, obtaining the current iteration number and interval parameter, and determining the current search area according to the current iteration number, the interval parameter and the coordinate information corresponding to the current iteration center; S3, calculating the first deflection boundary angle and the second deflection boundary angle according to the rotation parameter and the current iteration center; S4, respectively calculating the similarity between the image observed under the window and the template image when the current iteration center is the deflection angle, the similarity between the image observed under the window and the template image when the first deflection boundary angle is the deflection angle, and the similarity between the image observed under the window and the template image when the second deflection boundary angle is the deflection angle, and updating the current iteration center according to the highest similarity value; S5, updating the first deflection boundary angle and the second deflection boundary angle according to the current iteration center and the current iteration number, and returning to step S2; S6, iteratively executing steps S2 to S5 until the number of iterations reaches a preset threshold.

[0017] Optionally, after acquiring the observed image, the method further includes:

[0018] Calculate thread parameters according to the observed image, so as to perform image similarity matching using a multi-thread mode according to the thread parameters, wherein the thread parameters are calculated according to the following formula:

[0019] tC=min(CPUCC-1,cSC,bC)

[0020] Among them, tC represents the number of threads opened in the multi-threaded mode, CPUCC represents the number of computer cores, cSC represents the rotation parameter, and bC represents the control parameter;

[0021]

[0022] Among them, Ceiling() means rounding up, w O Indicates the width of the observed image, h O The height of the observed image, zF represents the scaling parameter, and c represents a constant;

[0023]

[0024]

[0025] Among them, mSTC represents the maximum matching times of sub-threads, and tC' represents the number of thread executions.

[0026] The above template-based image similarity matching method can be applied in the image processing process of the machine vision detection system.

[0027] The present invention proposes a machine vision inspection system, which applies the above-mentioned template-based image similarity matching method, wherein the system includes: an input module, the input module is composed of a camera, a light source and a lens, the input module is used to take a picture of the object to be inspected to obtain image data corresponding to the object to be inspected, and the image data includes the observed image; a configuration module, the configuration module includes a human-machine interface, so as to obtain user input information through the human-machine interface, and generate configuration parameters according to the user input information, the configuration parameters include preset rotation parameters, a template image and optional mask information; the mask information is used to cover the corresponding areas of the observed image and the template image; a processing module, the processing module processes the image data sent by the input module, the configuration parameters sent by the configuration module and the data stored in the storage module, and the processing process includes the rough calculation and iterative calculation in the template-based image similarity matching method; the rough calculation includes calculating according to the preset rotation parameters to obtain multiple rotation angles, rotating the template image corresponding to the observed image according to the rotation angles, and rotating the template image with a sliding window. The template image after each rotation is matched with the observed image in a similarity manner to obtain the similarity corresponding to each sliding window, and the rotation angle corresponding to the sliding window with the highest similarity is used as the rough deflection angle; the iterative calculation includes iterative calculation according to the rough deflection angle to determine the precise deflection angle, and calculates the position coordinates corresponding to the sliding window under the precise deflection angle and the similarity between the observed image and the template image under the sliding window; a storage module, the storage module is used to store the configuration parameters of the configuration module, the detection process data of the processing module and the detection and discrimination result data, including the preset rotation parameters, the template image and the optional mask information, and also includes the precise position coordinates and deflection angle obtained by the processing module through rough calculation and iterative calculation; an output module, the output module transmits the detection process data and the detection and discrimination result data of the processing module to the field device and the storage device in a specific form and interface requirements, and the output content of the output module includes the precise position coordinates and deflection angle obtained by the rough calculation and the iterative calculation; the field device, the field device is used to perform corresponding operations according to the position coordinates and deflection angle output by the output module.

[0028] According to the machine vision inspection system of the embodiment of the present invention, an input module is set to be composed of a camera, a light source and a lens, the input module is used to take a picture of the object to be inspected to obtain image data corresponding to the object to be inspected, and the image data includes the observed image; the configuration module includes a human-machine interface to obtain user input information through the human-machine interface, and generate configuration parameters according to the user input information, the configuration parameters include preset rotation parameters, a template image and optional mask information; the mask information is used to cover the corresponding areas of the observed image and the template image; the processing module processes the image data sent by the input module, the configuration parameters sent by the configuration module and the data stored in the storage module, and the processing process includes the rough calculation and iterative calculation in the template-based image similarity matching method; the rough calculation includes calculating according to the preset rotation parameters to obtain multiple rotation angles, rotating the template image corresponding to the observed image according to the rotation angles, and performing similarity matching between the template image after each rotation and the observed image in a sliding window manner to obtain the similarity corresponding to each sliding window, so as to obtain the similarity corresponding to each sliding window. and taking the rotation angle corresponding to the sliding window with the highest similarity as the rough deflection angle; the iterative calculation includes iterative calculation according to the rough deflection angle to determine the precise deflection angle, and calculating the position coordinates corresponding to the sliding window under the precise deflection angle and the similarity between the observed image and the template image under the sliding window; the storage module is used to store the configuration parameters of the configuration module, the detection process data of the processing module and the detection and discrimination result data, including the preset rotation parameters, the template image and the optional mask information, and also includes the precise position coordinates and deflection angle obtained by the processing module through rough calculation and iterative calculation; the output module transmits the detection process data and the detection and discrimination result data of the processing module to the field equipment and the storage device according to the specific form and interface requirements, and the output content of the output module includes the precise position coordinates and deflection angle obtained by the rough calculation and the iterative calculation; the field equipment is used to perform corresponding operations according to the position coordinates and deflection angle output by the output module; the image of the system applies the above-mentioned template-based image similarity matching method, which can realize effective similarity matching of the image when the image is rotated, thereby improving the matching accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of a process of a template-based image similarity matching method according to an embodiment of the present invention;

[0030] Figure 2 A schematic diagram of a mask information processing flow according to an embodiment of the present invention;

[0031] Figure 3 A schematic diagram of an iterative calculation process according to an embodiment of the present invention;

[0032] Figure 44 is a block diagram of a machine vision inspection system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.

[0034] In the related art, the matching method is only effective when the image has not been rotated or the rotation angle is very small. When the rotation angle is large, the matching result will be inaccurate. According to the template-based image similarity matching method of an embodiment of the present invention, first, the observed image is obtained, and the corresponding multiple rotation angles are calculated according to the preset rotation parameters, and the template image corresponding to the observed image is rotated according to the rotation angle; then, the template image after each rotation is matched with the observed image in a sliding window manner to obtain the similarity corresponding to each window, and the rotation angle corresponding to the window with the highest similarity is used as the rough deflection angle; then, iterative calculation is performed according to the rough deflection angle to determine the precise deflection angle, and the position coordinates corresponding to the window under the precise deflection angle and the similarity between the observed image and the template image under the window are calculated; it can achieve effective similarity matching of the image when the image is rotated, thereby improving the matching accuracy.

[0035] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0036] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0037] Figure 1 FIG. 1 is a flow chart of a template-based image similarity matching method according to an embodiment of the present invention. Figure 1 As shown, the template-based image similarity matching method includes the following steps:

[0038] S101, acquiring an observed image, calculating a plurality of corresponding rotation angles according to preset rotation parameters, and rotating a template image corresponding to the observed image according to the rotation angles.

[0039] That is to say, before obtaining the observed image, first, a corresponding template image is prepared, and when similarity matching is required, the observed image is obtained (the observed image can be read from the local storage of the computer, or acquired in real time through a device such as a camera); then, the corresponding multiple rotation angles are calculated according to the preset rotation parameters, and the template image corresponding to the observed image is rotated accordingly according to the rotation angles.

[0040] As an example, the rotation parameter is cSC. When cSC=20, it means that the rotation angle of the template image starts from 0 degrees, and each increase in angle is Δα=360 / 20, and a total of 20 rotations are made.

[0041] In some embodiments, in order to further improve the accuracy of similarity matching, after acquiring the observed image, the method further includes: acquiring mask information, and masking corresponding areas of the observed image and the template image according to the mask information.

[0042] It is understandable that in the scenario of similarity matching, there are often changing areas within the matching area; Figure 2 As shown, in the template image, the product parameters and QR codes will vary greatly with different products. If the similarity matching is performed on the entire image, the accuracy of the final similarity will be affected. Therefore, by setting a mask to cover the changed areas of the observed image and the corresponding template image, the accuracy of the final similarity calculation can be effectively improved.

[0043] As an example, after obtaining the observed image, mask information input by the user is further obtained, and the corresponding area is masked according to the mask information; specifically, after adding masks to the observed image and the template image, when the observed image or the template image is scaled, the mask is also scaled proportionally; when the template image is rotated, the mask is also rotated at the same angle; the rotated mask is dot-multiplied with the current window of the rotated template image or the observed image, respectively, to complete the masking of the corresponding area.

[0044] In some embodiments, before performing similarity matching between the template image and the observed image after each rotation in a sliding window manner, the method further includes: obtaining a scaling parameter, and scaling the observed image and the template image according to the scaling parameter.

[0045] S102, performing similarity matching between the template image after each rotation and the observed image in a sliding window manner to obtain the similarity corresponding to each window, and taking the rotation angle corresponding to the window with the highest similarity as the rough deflection angle.

[0046] That is, after each rotation, the rotated template image and the observed image are matched for similarity in a sliding window manner (for example, when cSC=20, the template image will be rotated 20 times, and the number of similarity matches will be correspondingly 20 times; in each similarity matching process, the similarity between the observed image and the template image under each sliding window will be calculated); thus, the similarity corresponding to each window can be obtained, and then, the rotation angle corresponding to the window with the highest similarity is used as the rough deflection angle.

[0047] In some embodiments, similarity matching is performed according to the following formula:

[0048]

[0049] Among them, R represents the similarity, I T ′ represents the template image after rotation and mask processing, I′ O-cur Represents the current window of the observed image after mask processing.

[0050] S103, performing iterative calculation according to the rough deflection angle to determine the precise deflection angle, and calculating the position coordinates corresponding to the window at the precise deflection angle and the similarity between the observed image under the window and the template image.

[0051] That is to say, Figure 3 As shown, after the rough deflection angle is calculated, further iterative calculation is performed to improve the accuracy of the deflection angle to obtain a precise deflection angle, and then the position coordinates corresponding to the sliding window under the precise deflection angle and the similarity between the observed image and the template image under the sliding window are output to complete the similarity matching.

[0052] In some embodiments, iterative calculation is performed based on the rough deflection angle, including:

[0053] S1, takes the rough deflection angle as the current iteration center;

[0054] S2, obtaining the current iteration number and interval parameter, and determining the current search area according to the current iteration number, interval parameter and coordinate information corresponding to the center of the previous iteration;

[0055] S3, calculating a first deflection boundary angle and a second deflection boundary angle according to the rotation parameter and the current iteration center;

[0056] S4, respectively calculating the similarity between the image observed under the window and the template image when the current iteration center is the deflection angle, the similarity between the image observed under the window and the template image when the first deflection boundary angle is the deflection angle, and the similarity between the image observed under the window and the template image when the second deflection boundary angle is the deflection angle, and updating the current iteration center according to the highest similarity value;

[0057] S5, updating the first deflection boundary angle and the second deflection boundary angle according to the current iteration center and the current iteration number, and returning to step S2;

[0058] S6, iteratively execute steps S2 to S5 until the number of iterations reaches a preset threshold.

[0059] As an example, Figure 3 As shown in FIG. 1 , assuming that the rough deflection angle is 36 degrees, the 36 degrees is used as the current iteration center. Then, the current iteration number and interval parameters are obtained (for example, the width and height of the template image are used as interval parameters), and then the current search area is determined according to the current iteration number, interval parameters and coordinate information corresponding to the current iteration center. Specifically, first, the boundary value of the expansion area is calculated according to the current iteration number and interval parameters, and is calculated according to the following formula: Among them, rFST1 represents the boundary value of the expansion area, w T Indicates the width of the template image, h T represents the height of the template image; through the above formula, we can determine the expansion range of the current iteration center to the surrounding areas; to determine the current search area. In the subsequent iteration process, let Among them, n represents the current number of iterations; during the iteration process, the search range can be continuously narrowed according to the number of iterations; at the same time, the current search area is updated according to the current iteration center to finally obtain the precise position. Assuming the rotation parameter cSC=20, the first deflection boundary angle and the second deflection boundary angle calculated according to the rotation parameter need to be rotated to both sides by α=360 / cSC / 2 respectively (that is, the first deflection boundary angle is 27 degrees, and the second deflection boundary angle is 45 degrees); then, the similarity between the observed image and the template image under the sliding window is calculated when the deflection angles are 27 degrees, 36 degrees, and 45 degrees respectively, and the sizes of the three similarities are compared, and the current iteration center is updated according to the deflection angle corresponding to the maximum similarity; then, when performing the second iteration, the first deflection boundary angle and the second deflection boundary angle calculated according to the rotation parameter need to be rotated to both sides by α=360 / cSC / 2 / 2 respectively x (wherein x represents the number of iterations); that is, assuming that the similarity is maximum when the similarity comparison result is 45 degrees, then 45 degrees is the current iteration center, the first deflection boundary angle is 40.5 degrees, and the second deflection boundary angle is 49.5 degrees; thus, according to the above method, iterative calculation is performed to continuously narrow the deflection range and continuously improve the accuracy of the deflection angle calculation; preferably, the number of iterations is set to 9, and when the number of iterations reaches 9 times, the deflection angle accuracy will reach 0.1 degrees.

[0060] In some embodiments, in order to improve the matching efficiency of similarity matching and make the similarity matching process applicable to multi-threading, after acquiring the observed image, the following is further included:

[0061] The thread parameters are calculated according to the observed image, so as to perform image similarity matching using a multi-thread mode according to the thread parameters, wherein the thread parameters are calculated according to the following formula:

[0062] tC=min(CPUCC-1,cSC,bC)

[0063] Among them, tC represents the number of threads opened in the multi-threaded mode, CPUCC represents the number of computer cores, cSC represents the rotation parameter, and bC represents the control parameter;

[0064]

[0065] Among them, Ceiling() means rounding up, w O Indicates the width of the observed image, h O The height of the observed image, zF represents the scaling parameter, and c represents a constant;

[0066]

[0067]

[0068] Among them, mSTC represents the maximum matching times of sub-threads, and tC' represents the number of thread executions.

[0069] In some embodiments, when an image is scaled, if the scaled image is directly used for iterative calculation, errors will occur in the final position information. Therefore, in order to avoid this error, before performing iterative calculation according to the rough deflection angle, the method further includes: restoring the scaled image;

[0070] The image restoration is performed according to the following formula:

[0071] Point coarse (x,y)={(Point′.X+0.5)*zF, (Point′.Y+0.5)*zF}

[0072] Among them, Point coarse (x, y) represents the pixel coordinate information after restoration, Point′.X represents the X-axis value of the pixel coordinate before restoration, Point′.Y represents the Y-axis value of the pixel coordinate before restoration, and zF represents the scaling parameter.

[0073] In summary, according to the template-based image similarity matching method of an embodiment of the present invention, first, an observed image is obtained, and a corresponding plurality of rotation angles are calculated according to preset rotation parameters, and the template image corresponding to the observed image is rotated according to the rotation angles; then, the template image after each rotation is similarly matched with the observed image in a sliding window manner to obtain the similarity corresponding to each window, and the rotation angle corresponding to the window with the highest similarity is used as a rough deflection angle; then, an iterative calculation is performed based on the rough deflection angle to determine the precise deflection angle, and the position coordinates corresponding to the window under the precise deflection angle and the similarity between the observed image and the template image under the window are calculated; this enables effective similarity matching of images when the image is rotated, thereby improving the matching accuracy.

[0074] In order to implement the above embodiment, the present invention proposes a machine vision detection system, which applies the above-mentioned template-based image similarity matching method. Figure 4 As shown, the machine vision inspection system includes: an input module 10 , a configuration module 20 , a processing module 30 , a storage module 40 , an output module 50 and a field device 60 .

[0075] The input module 10 is composed of a camera, a light source and a lens. The input module is used to take a picture of the object to be detected to obtain image data corresponding to the object to be detected. The image data includes an observed image.

[0076] The configuration module 20 includes a human-machine interface to obtain user input information through the human-machine interface, and to generate configuration parameters according to the user input information, wherein the configuration parameters include preset rotation parameters, a template image, and optional mask information; the mask information is used to cover corresponding areas of the observation image and the template image;

[0077] The processing module 30 processes the image data sent by the input module, the configuration parameters sent by the configuration module and the data stored in the storage module, and the processing process includes rough calculation and iterative calculation in the template-based image similarity matching method;

[0078] The rough calculation includes calculating according to preset rotation parameters to obtain multiple rotation angles, rotating the template image corresponding to the observed image according to the rotation angles, and matching the template image after each rotation with the observed image in a sliding window manner to obtain the similarity corresponding to each sliding window, and taking the rotation angle corresponding to the sliding window with the highest similarity as the rough deflection angle;

[0079] The iterative calculation includes performing iterative calculation according to the rough deflection angle to determine the precise deflection angle, and calculating the position coordinates corresponding to the sliding window under the precise deflection angle and the similarity between the observed image and the template image under the sliding window;

[0080] The storage module 40 is used to store the configuration parameters of the configuration module, the detection process data of the processing module and the detection and discrimination result data, including the preset rotation parameters, the template image and the optional mask information, and also includes the precise position coordinates and deflection angles obtained by the processing module through rough calculation and iterative calculation;

[0081] The output module 50 transmits the detection process data and the detection and discrimination result data of the processing module to the field device and the storage device according to the specific form and interface requirements. The output content of the output module includes the precise position coordinates and deflection angles obtained by rough calculation and iterative calculation;

[0082] The field device 60 is used to perform corresponding operations according to the position coordinates and deflection angle output by the output module.

[0083] It should be noted that the above Figure 1 The description of the template-based image similarity matching method in is also applicable to this machine vision inspection system and will not be repeated here.

[0084] In summary, according to the machine vision inspection system of the embodiment of the present invention, an input module is set to be composed of a camera, a light source and a lens, the input module is used to take a picture of the object to be inspected to obtain image data corresponding to the object to be inspected, and the image data includes the observed image; the configuration module includes a human-machine interface to obtain user input information through the human-machine interface, and generate configuration parameters according to the user input information, the configuration parameters include preset rotation parameters, a template image and optional mask information; the mask information is used to cover the corresponding areas of the observed image and the template image; the processing module processes the image data sent by the input module, the configuration parameters sent by the configuration module and the data stored in the storage module, and the processing process includes the rough calculation and iterative calculation in the template-based image similarity matching method; the rough calculation includes calculating according to the preset rotation parameters to obtain multiple rotation angles, rotating the template image corresponding to the observed image according to the rotation angles, and performing similarity matching between the template image after each rotation and the observed image in a sliding window manner to obtain the similarity corresponding to each sliding window, and taking the rotation angle corresponding to the sliding window with the highest similarity as the rough deflection angle; the iterative calculation includes iterative calculation according to the rough deflection angle to determine the precise deflection angle, and calculating the position coordinates corresponding to the sliding window under the precise deflection angle and the similarity between the observed image and the template image under the sliding window; the storage module is used to store the configuration parameters of the configuration module, the detection process data of the processing module and the detection and discrimination result data, including the preset rotation parameters, the template image and the optional mask information, the mask information is used to cover the corresponding areas of the observed image and the template image; it also includes the precise position coordinates and deflection angle obtained by the rough calculation and iterative calculation of the processing module; the output module transmits the detection process data and the detection and discrimination result data of the processing module to the field equipment and the storage device according to the specific form and interface requirements, and the output content of the output module includes the precise position coordinates and deflection angle obtained by the rough calculation and the iterative calculation; the field equipment is used to perform corresponding operations according to the position coordinates and deflection angle output by the output module; it can realize effective similarity matching of the image when the image is rotated, and improve the matching accuracy.

[0085] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0086] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0087] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0088] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0089] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claim. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.

[0090] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0091] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

[0092] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0093] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0094] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.

[0095] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" 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 should not be understood as necessarily referring to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0096] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A template-based image similarity matching method, characterized in that: The following steps are involved: Acquire an observed image, calculate a plurality of corresponding rotation angles according to preset rotation parameters, and rotate a template image corresponding to the observed image according to the rotation angles; The template image after each rotation is matched with the observed image in a sliding window manner to obtain the similarity corresponding to each window, and the rotation angle corresponding to the window with the highest similarity is used as the rough deflection angle; Iterative calculation is performed according to the rough deflection angle to determine the precise deflection angle, and the position coordinates corresponding to the window under the precise deflection angle and the similarity between the observed image under the window and the template image are calculated; An iterative calculation is performed according to the rough deflection angle, including: S1, taking the rough deflection angle as the current iteration center; S2, obtaining the current iteration number and interval parameter, and determining the current search area according to the current iteration number, the interval parameter and the coordinate information corresponding to the current iteration center; S3, calculating a first deflection boundary angle and a second deflection boundary angle according to the rotation parameter and the current iteration center; S4, respectively calculating the similarity between the image observed under the window and the template image when the current iteration center is the deflection angle, the similarity between the image observed under the window and the template image when the first deflection boundary angle is the deflection angle, and the similarity between the image observed under the window and the template image when the second deflection boundary angle is the deflection angle, and updating the current iteration center according to the highest similarity value; S5, updating the first deflection boundary angle and the second deflection boundary angle according to the current iteration center and the current iteration number, and returning to step S2; S6, iteratively execute steps S2 to S5 until the number of iterations reaches a preset threshold.

2. The template-based image similarity matching method according to claim 1, characterized in that: After acquiring the observed image, the method further includes: acquiring mask information, and masking corresponding areas of the observed image and the template image according to the mask information.

3. The template-based image similarity matching method according to claim 1, characterized in that: Before the template image after each rotation is matched with the observed image for similarity in a sliding window manner, the following steps are also included: A scaling parameter is obtained, and the observation image and the template image are scaled according to the scaling parameter.

4. The template-based image similarity matching method according to claim 3, characterized in that: Before performing iterative calculation according to the rough deflection angle, the method further includes: restoring the scaled image; The image restoration is performed according to the following formula: Point coarse (x,y)={(Point′.X+0.5)*zF,(Point′.Y+0.5)*zF} Among them, Point coarse (x, y) represents the pixel coordinate information after restoration, Point′.X represents the X-axis value of the pixel coordinate before restoration, Point′.Y represents the Y-axis value of the pixel coordinate before restoration, and zF represents the scaling parameter.

5. The template-based image similarity matching method according to claim 2, characterized in that: Similarity matching is performed according to the following formula: Among them, R represents the similarity, I T ′ represents the template image after rotation and mask processing, I′ O-cur Represents the current window of the observed image after mask processing.

6. The template-based image similarity matching method according to claim 1, characterized in that: After acquiring the observation image, it also includes: Calculate thread parameters according to the observed image, so as to perform image similarity matching using a multi-thread mode according to the thread parameters, wherein the thread parameters are calculated according to the following formula: tC=min(CPUCC-1,cSC,bC) Among them, tC represents the number of threads opened in the multi-threaded mode, CPUCC represents the number of computer cores, cSC represents the rotation parameter, and bC represents the control parameter; Among them, Ceiling() means rounding up, w O Indicates the width of the observed image, h O The height of the observed image, zF represents the scaling parameter, and c represents a constant; Among them, mSTC represents the maximum matching times of sub-threads, and tC' represents the number of thread executions.