A method and system for calculating offset of feature point matching and template matching

By combining template matching and feature point matching, using standard correlation coefficients and SURF feature point extraction, the accuracy problem of image offset calculation in chaotic scenes during robot inspection is solved, and a more efficient and generalized offset is achieved. calculate.

CN118038096BActive Publication Date: 2024-09-27北京鸿鹄元数科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410180638.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-18
Publication Date
2024-09-27
Estimated Expiration
2044-02-18

AI Technical Summary

Technical Problem

In the existing technology, during the robot inspection process, the feature point matching method is difficult to accurately calculate the image offset in a chaotic scene, and the calculation effect is not good in no-target or multi-target scenes.

Method used

Combining template matching and feature point matching, through standard correlation coefficient matching and SURF feature point extraction, the image offset is calculated using the homography matrix and random sampling consistency methods, and the offset is determined by comparing the cropping area and the correlation coefficient.

Benefits of technology

It improves the accuracy of offset calculation in chaotic scenes, does not depend on the number of targets in the image, and enhances the generalization and efficiency of the calculation method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118038096B
    Figure CN118038096B
Patent Text Reader

Abstract

The present invention provides a method and system for calculating the offset of feature point matching and template matching, the method comprising: obtaining a historical picture and an inspection picture of a designated point; cutting out a template from the historical picture; performing template matching on the inspection picture to obtain the best matching position and the standard correlation coefficient V co ; Calculate the offset from the historical image to the inspection image; Extract and describe the SURF feature points of the historical image and the inspection image respectively; Calculate the homography matrix from the historical image to the inspection image; Calculate the offset of the feature point matching; Calculate the correlation coefficient V ’ co ; Compare V ’ co With V co The present invention combines template matching and special diagnosis point matching, which is conducive to accelerating the extraction efficiency of feature points, enhancing the offset calculation effect in cluttered scenes, and improving the calculation accuracy; at the same time, the present invention does not depend on how many specified targets there are in the image, which enhances the practicality of the scene and improves the generalization of the calculation method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of robot inspection technology, and in particular to a method and system for calculating an offset of feature point matching and template matching. Background Art

[0002] When using the robot to perform inspection tasks, the trajectory and the pan / tilt angle of each inspection point will be recorded in advance in order to obtain image information of the target point for further analysis.

[0003] However, in the actual inspection process, due to the introduction of various errors, the acquired point image is offset compared with the pre-collected image. In order to adjust the PTZ angle or obtain the image overlap area, it is necessary to calculate the offset between the acquired point image and the pre-collected image.

[0004] There are two main existing methods for calculating the offset between two images:

[0005] The first method is to directly use the feature point matching method (SIFT, SURF and other feature points), that is, first extract the feature points of the two images respectively, and then match the feature points of the two images to obtain the homography matrix (also called "projection transformation"), take the center point of one of the images and use the homography matrix to get the center point of the other image, then calculate the horizontal offset and vertical offset between the center points of the two images.

[0006] However, the disadvantages of this method are that it is difficult to extract feature points and the calculation effect is poor for cluttered scenes. Cluttered scenes often have calculation errors, for example, a single-device scene with a sky background and a scene with repeated textures such as a mesh.

[0007] The second method is to combine the first method and introduce a target detection model. First, the specified target in the scene is detected. If the calculation conditions are met, the offset between the target centers detected in the two images is used as the image offset. If the calculation conditions are not met, the first method is used.

[0008] The main disadvantage of the second method is that it is not conducive to the calculation of target-free scenes and multi-target scenes. It cannot work in target-free scenes and some multi-target scenes. It also relies on the specified target types and has poor generalization. Summary of the invention

[0009] In view of this, the purpose of the present invention is to propose a method and system for calculating the offset of feature point matching and template matching, which combines template matching with feature point matching to more efficiently solve the problems of difficulty in feature point extraction and poor offset calculation effect in cluttered scenes in the prior art, thereby improving the calculation accuracy; at the same time, it does not depend on how many specified targets are in the image, so as to enhance the practicability of the scene and improve the generalization of the calculation method.

[0010] The present invention provides a method for calculating the offset of feature point matching and template matching, comprising:

[0011] S1. When the robot moves to the position of a specified point, it obtains the historical image image1 of the point from the storage device, adjusts the pan-tilt according to the pan-tilt angle information recorded at the point, obtains the inspection image image2 through the pan-tilt camera, and sets the size of the historical image image1 and the inspection image image2 to be consistent;

[0012] S2. Cut out the image image1_roi from the historical image image1 according to the region (x, y, w, h) as a template. The region values ​​x, y, w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image1_roi respectively. Use the standard correlation coefficient matching method to perform template matching on the inspection image image2 to obtain the best matching position (x m ,y m ) and the standard correlation coefficient V co ;

[0013] S3, based on the best matching position (x m ,y m ), calculate the offset (dx, dy) from the historical image image1 to the inspection image image2. The calculation formula for the offset (dx, dy) is:

[0014] d x =x m -x,d y =y m -y (1)

[0015] In formula (1), d x is the horizontal offset, d y is the vertical offset;

[0016] S4, extract and describe SURF feature points of the historical image image1 and the inspection image image2 respectively, and obtain N matching point pairs by the nearest neighbor matching method. If N ≥ threshold th1, jump to step S2 to continue execution; if N < threshold th1, calculate the point pairs as the homography matrix, and jump to step S5 to continue execution;

[0017] S5, using the homography matrix to calculate the point pairs, and calculating the homography matrix H from the historical image image1 to the inspection image image2 according to the random sampling consistency RANSAC method;

[0018] The corresponding point (x ) of the center point (W / 2, H / 2) of the historical image image 1 on the inspection image image 2 is calculated according to the homography matrix H. t ,y t ), corresponding point (x t ,y t ) is calculated as:

[0019]

[0020] S6. Calculate the offset (d x ',d y '), offset (d x ',d y The calculation formula of ') is:

[0021] d x '=x t -W / 2,d y '=y t -H / 2 (2)

[0022] S7. Cut out the image image2_roi from the inspection image image2 according to the region (x', y', w, h). The region values ​​x', y', w, h are respectively the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image2_roi. The calculation formula of x', y' is:

[0023] x'=x+d x ',y'=y+d y ' (3)

[0024] Calculate the correlation coefficient V' of image1_roi and image2_roi co , correlation coefficient V' co The calculation formula is:

[0025]

[0026]

[0027]

[0028] In formula (4), I′1(x, y) and I′2(x, y) represent the pixel values ​​of image1_roi and image2_roi respectively;

[0029] S8. Compare V' co With V co If V co >V'co , then (dx,dy) is used as the offset from the historical image image1 to the inspection image image2; if V co ≤V' co , then (dx',dy') is used as the offset from the historical image image1 to the inspection image image2.

[0030] Furthermore, the method of calculating point pairs using N point pairs as homography matrices in step S4 includes:

[0031] Sort the obtained N feature points from small to large according to the Euclidean distance of the feature description, and take the first th1 matching point pairs as the point pairs for homography matrix calculation.

[0032] Furthermore, the area values ​​x, y, w, h in the historical image image1 of step S2 are set to W / 3, H / 3, W / 3, H / 3, where W and H are the width and height of the historical image image1.

[0033] Furthermore, the area values ​​x', y', w, h in the inspection image image2 of step S7 are set to w=W / 3, h=H / 3, where W and H are the width and height of the inspection image image2.

[0034] Furthermore, the threshold th1 of step S4 is set to th1=200.

[0035] The present invention also provides a feature point matching and template matching offset calculation system, which executes the feature point matching and template matching offset calculation method as described above, including:

[0036] Obtaining historical images and inspection images module: when the robot moves to a specified point, it obtains the historical image image1 of the point from the storage device, adjusts the PTZ according to the PTZ angle information recorded at the point, obtains the inspection image image2 through the PTZ camera, and sets the size of the historical image image1 and the inspection image image2 to be consistent;

[0037] Template matching module: It is used to crop the image image1_roi from the historical image image1 according to the region (x, y, w, h) as a template. The region values ​​x, y, w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image1_roi. The standard correlation coefficient matching method is used to perform template matching on the inspection image image2 to obtain the best matching position (x m ,y m ) and the standard correlation coefficient V co ;

[0038] Calculate offset module: used to calculate the offset based on the best matching position (x m ,y m ), calculate the offset (dx, dy) from the historical image image1 to the inspection image image2;

[0039] Feature point extraction module: used to extract and describe SURF feature points of historical image image1 and inspection image image2 respectively, and obtain N matching point pairs by nearest neighbor matching. If N≥threshold th1, jump to step S2 to continue execution; if N<threshold th1, take N point pairs as homography matrix to calculate point pairs, and jump to step S5 to continue execution;

[0040] Calculate homography matrix module: use the homography matrix to calculate point pairs, and calculate the homography matrix H from the historical image image1 to the inspection image image2 according to the random sampling consistency RANSAC method; calculate the corresponding point (x t ,y t );

[0041] Calculate feature point matching offset module: used to calculate the offset (d x ',d y ');

[0042] Module for calculating correlation coefficient of cropped images: used to crop image2_roi from inspection image image2 according to region (x', y', w, h). The region values ​​x', y', w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of image2_roi, respectively. Calculate the correlation coefficient V' between image1_roi and image2_roi co ;

[0043] Comparison offset module: used to compare V' co With V co If V co >V' co , then (dx,dy) is used as the offset from the historical image image1 to the inspection image image2; if V co ≤V' co , then (dx',dy') is used as the offset from the historical image image1 to the inspection image image2.

[0044] The present invention also provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the steps of the offset calculation method for feature point matching and template matching as described above are implemented.

[0045] The present invention also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the offset calculation method for feature point matching and template matching as described above are implemented.

[0046] Compared with the prior art, the present invention has the following beneficial effects:

[0047] The offset calculation method and system of feature point matching and template matching of the present invention combine template matching and feature point matching, which is beneficial to accelerate the extraction efficiency of feature points, can enhance the offset calculation effect in cluttered scenes, and improve the calculation accuracy; at the same time, the present invention does not depend on how many specified targets are in the image, thereby enhancing the practicability of the scene and improving the generalization of the calculation method. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the following detailed description of the preferred embodiment.The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting the invention.

[0049] In the attached picture:

[0050] Figure 1 A schematic flow chart of the steps of calculating the offset of feature point matching and template matching in an embodiment of the present invention;

[0051] Figure 2 A flow chart of a method for calculating an offset of feature point matching and template matching according to the present invention;

[0052] Figure 3 The figure is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure. Instead, they are merely examples of systems and products consistent with some aspects of the present disclosure as detailed in the appended claims.

[0054] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein is and includes any or all possible combinations of one or more associated listed items.

[0055] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0056] The embodiments of the present invention are described in further detail below.

[0057] The embodiment of the present invention provides a method for calculating the offset of feature point matching and template matching, see Figure 2 As shown, the following steps are included:

[0058] S1. When the robot moves to the position of a specified point, it obtains the historical image image1 of the point from the storage device, adjusts the pan-tilt according to the pan-tilt angle information recorded at the point, obtains the inspection image image2 through the pan-tilt camera, and sets the size of the historical image image1 and the inspection image image2 to be consistent;

[0059] S2. Cut out the image image1_roi from the historical image image1 according to the region (x, y, w, h) as a template. The region values ​​x, y, w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image1_roi respectively. Use the standard correlation coefficient matching method to perform template matching on the inspection image image2 to obtain the best matching position (x m ,y m ) and the standard correlation coefficient V co ;

[0060] In this embodiment, the area values ​​x, y, w, and h in the historical image image1 are set to W / 3, H / 3, W / 3, H / 3, where W and H are the width and height of the historical image image1.

[0061] S3, based on the best matching position (x m ,y m), calculate the offset (dx, dy) from the historical image image1 to the inspection image image2. The calculation formula for the offset (dx, dy) is:

[0062] d x =x m -x,d y =y m -y (1)

[0063] In formula (1), d x is the horizontal offset, d y is the vertical offset;

[0064] S4, extract and describe SURF feature points of the historical image image1 and the inspection image image2 respectively, and obtain N matching point pairs by the nearest neighbor matching method. If N≥threshold th1 (in this embodiment, threshold th1 is set to th1=200), jump to step S2 to continue execution; if N<threshold th1, calculate point pairs as homography matrix, and jump to step S5 to continue execution;

[0065] In this embodiment, the method of calculating point pairs using N point pairs as homography matrices is:

[0066] Sort the obtained N feature points from small to large according to the Euclidean distance of the feature description, and take the first th1 matching point pairs as the point pairs for homography matrix calculation.

[0067] S5, using the homography matrix to calculate the point pairs, and calculating the homography matrix H from the historical image image1 to the inspection image image2 according to the random sampling consistency RANSAC method;

[0068] The corresponding point (x ) of the center point (W / 2, H / 2) of the historical image image 1 on the inspection image image 2 is calculated according to the homography matrix H. t ,y t ), corresponding point (x t ,y t ) is calculated as:

[0069]

[0070] S6. Calculate the offset (d x ',d y '), offset (d x ',d y The calculation formula of ') is:

[0071] d x '=x t -W / 2,dy '=y t -H / 2 (2)

[0072] S7. Cut out the image image2_roi from the inspection image image2 according to the region (x', y', w, h). The region values ​​x', y', w, h are respectively the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image2_roi. The calculation formula of x', y' is:

[0073] x'=x+d x ',y'=y+d y ' (3)

[0074] In this embodiment, the area values ​​x', y', w, h in the inspection image image2 are set to w=W / 3, h=H / 3, where W and H are the width and height of the inspection image image2.

[0075] Calculate the correlation coefficient V' of image1_roi and image2_roi co , correlation coefficient V' co The calculation formula is:

[0076]

[0077]

[0078]

[0079] In formula (4), I′1(x, y) and I′2(x, y) represent the pixel values ​​of image1_roi and image2_roi respectively;

[0080] S8. Compare V' co With V co If V co >V' co , then (dx,dy) is used as the offset from the historical image image1 to the inspection image image2; if V co ≤V' co , then (dx',dy') is used as the offset from the historical image image1 to the inspection image image2.

[0081] Figure 1 The flowchart of the steps for calculating the offset of feature point matching and template matching in an embodiment of the present invention is shown.

[0082] The embodiment of the present invention further provides a system for calculating the offset of feature point matching and template matching, which executes the method for calculating the offset of feature point matching and template matching as described above, including:

[0083] Obtaining historical images and inspection images module: when the robot moves to a specified point, it obtains the historical image image1 of the point from the storage device, adjusts the PTZ according to the PTZ angle information recorded at the point, obtains the inspection image image2 through the PTZ camera, and sets the size of the historical image image1 and the inspection image image2 to be consistent;

[0084] Template matching module: It is used to crop the image image1_roi from the historical image image1 according to the region (x, y, w, h) as a template. The region values ​​x, y, w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image1_roi. The standard correlation coefficient matching method is used to perform template matching on the inspection image image2 to obtain the best matching position (x m ,y m ) and the standard correlation coefficient V co ;

[0085] Calculate offset module: used to calculate the offset based on the best matching position (x m ,y m ), calculate the offset (dx, dy) from the historical image image1 to the inspection image image2;

[0086] Feature point extraction module: used to extract and describe SURF feature points of historical image image1 and inspection image image2 respectively, and obtain N matching point pairs by nearest neighbor matching. If N≥threshold th1, jump to step S2 to continue execution; if N<threshold th1, take N point pairs as homography matrix to calculate point pairs, and jump to step S5 to continue execution;

[0087] Calculate homography matrix module: use the homography matrix to calculate point pairs, and calculate the homography matrix H from the historical image image1 to the inspection image image2 according to the random sampling consistency RANSAC method; calculate the corresponding point (x t ,y t );

[0088] Calculate feature point matching offset module: used to calculate the offset (d x ',d y ');

[0089] Module for calculating correlation coefficient of cropped images: used to crop image2_roi from inspection image image2 according to region (x', y', w, h). The region values ​​x', y', w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of image2_roi, respectively. Calculate the correlation coefficient V' between image1_roi and image2_roi co ;

[0090] Comparison offset module: used to compare V' co With V co If V co >V' co , then (dx,dy) is used as the offset from the historical image image1 to the inspection image image2; if V co ≤V' co , then (dx',dy') is used as the offset from the historical image image1 to the inspection image image2.

[0091] The offset calculation method and system for feature point matching and template matching provided in the embodiment of the present invention combine template matching and feature point matching, which is beneficial to accelerating the efficiency of feature point extraction, can enhance the offset calculation effect in cluttered scenes, and improves the calculation accuracy; at the same time, the present invention does not depend on how many specified targets are in the image, thereby enhancing the practicability of the scene and improving the generalization of the calculation method.

[0092] An embodiment of the present invention further provides a computer device, Figure 3 is a schematic diagram of the structure of a computer device provided by an embodiment of the present invention; see the accompanying drawings Figure 3 As shown, the computer device includes: an input system 23, an output system 24, a memory 22 and a processor 21; the memory 22 is used to store one or more programs; when the one or more programs are executed by the one or more processors 21, the one or more processors 21 implement the offset calculation method for feature point matching and template matching provided in the above embodiment; wherein the input system 23, the output system 24, the memory 22 and the processor 21 can be connected by a bus or other means, Figure 3 The example of connecting through bus is taken in the following.

[0093] The memory 22 is a readable and writable storage medium of a computing device, which can be used to store software programs, computer executable programs, such as program instructions corresponding to the offset calculation method for feature point matching and template matching described in the embodiment of the present invention; the memory 22 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created according to the use of the device, etc.; in addition, the memory 22 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device; in some instances, the memory 22 can further include a memory remotely arranged relative to the processor 21, and these remote memories can be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0094] The input system 23 may be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the device; the output system 24 may include display devices such as display screens.

[0095] The processor 21 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 22, that is, implements the above-mentioned offset calculation method for feature point matching and template matching.

[0096] The computer device provided above can be used to execute the offset calculation method for feature point matching and template matching provided in the above embodiment, and has corresponding functions and beneficial effects.

[0097] The embodiment of the present invention also provides a storage medium containing computer executable instructions, which are used to perform the offset calculation method for feature point matching and template matching provided in the above embodiment when executed by a computer processor. The storage medium is any of various types of memory devices or storage devices, and the storage medium includes: installation media, such as CD-ROM, floppy disk or tape system; computer system memory or random access memory, such as DRAM, DDRRAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc.; the storage medium may also include other types of memory or a combination thereof; in addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet); the second computer system may provide program instructions to the first computer for execution. The storage medium includes two or more storage media that may reside in different locations (for example, in different computer systems connected via a network). The storage medium may store program instructions (for example, specifically implemented as a computer program) that can be executed by one or more processors.

[0098] Of course, the storage medium containing computer executable instructions provided in an embodiment of the present invention is not limited to the offset calculation method for feature point matching and template matching as described in the above embodiment, and can also execute related operations in the offset calculation method for feature point matching and template matching provided in any embodiment of the present invention.

[0099] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

[0100] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for calculating the offset of feature point matching and template matching, characterized in that: include: S1. When the robot moves to the position of a specified point, it obtains the historical image image1 of the point from the storage device, adjusts the pan-tilt according to the pan-tilt angle information recorded at the point, obtains the inspection image image2 through the pan-tilt camera, and sets the size of the historical image image1 and the inspection image image2 to be consistent; S2, cut out the image image1_roi from the historical image image1 according to the region (x, y, w, h) as a template, where the region values ​​x, y, w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image1_roi respectively; The standard correlation coefficient matching method is used to perform template matching on the inspection image image2 to obtain the best matching position (x m ,y m ) and the standard correlation coefficient V co ; S3, based on the best matching position (x m ,y m ), calculate the offset (dx, dy) from the historical image image1 to the inspection image image2. The calculation formula for the offset (dx, dy) is: d x =x m -x,d y =y m -y (1) In formula (1), d x is the horizontal offset, d y is the vertical offset; S4, extract and describe SURF feature points of the historical image image1 and the inspection image image2 respectively, and obtain N matching point pairs by the nearest neighbor matching method. If N ≥ threshold th1, jump to step S2 to continue execution; If N < threshold th1, the N point pairs are used as the homography matrix to calculate the point pairs, and the process jumps to step S5 to continue the process; S5, using the homography matrix to calculate the point pairs, and according to the random sampling consistency RANSAC method, calculating the homography matrix H1 from the historical image image1 to the inspection image image2; The corresponding point (x 2, H 2) of the center point (W / 2, H / 2) of the historical image image 1 on the inspection image image 2 is calculated according to the homography matrix H1. t ,y t ), corresponding point (x t ,y t ) is calculated as: Where W and H are the width and height of the historical image image1; S6. Calculate the offset (d x ',d y '), offset (d x ',d y ') is calculated as: d x ’=x t -W / 2,d y ’=y t -H / 2 (2) S7. Cut out the image image2_roi from the inspection image image2 according to the region (x', y', w, h). The region values ​​x', y', w, h are respectively the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image2_roi. The calculation formula of x', y' is: x’=x+d x ’,y’=y+d y ’ (3) Calculate the standard correlation coefficient V' of the image1_roi and the image2_roi co , standard correlation coefficient V' co The calculation formula is: In formula (4), I1(x, y) and I2(x, y) represent the pixel values ​​of image1_roi and image2_roi respectively; S8. Compare V' co With V co If V co >V' co , then (dx,dy) is used as the offset from the historical image image1 to the inspection image image2; if V co ≤V' co , then (dx',dy') is used as the offset from the historical image image1 to the inspection image image2; The method of calculating point pairs by using N point pairs as homography matrices in step S4 includes: Sort the obtained N feature points from small to large according to the Euclidean distance of the feature description, and take the first th1 matching point pairs as the point pairs for homography matrix calculation.

2. The offset calculation method for feature point matching and template matching according to claim 1, characterized in that: The area values ​​x, y, w, h in the historical image image1 of step S2 are set to W / 3, H / 3, W / 3, H / 3.

3. The offset calculation method for feature point matching and template matching according to claim 1, characterized in that: The area values ​​x', y', w, h in the inspection image image2 of step S7 are set to w=W / 3, h=H / 3, where W and H are the width and height of the inspection image image2.

4. The method for calculating the offset of feature point matching and template matching according to claim 1, characterized in that: The threshold th1 of step S4 is set to th1=200.

5. A feature point matching and template matching offset calculation system, which executes the feature point matching and template matching offset calculation method according to any one of claims 1 to 4, characterized in that: include: Obtaining historical images and inspection images module: when the robot moves to a specified point, it obtains the historical image image1 of the point from the storage device, adjusts the PTZ according to the PTZ angle information recorded at the point, obtains the inspection image image2 through the PTZ camera, and sets the size of the historical image image1 and the inspection image image2 to be consistent; Template matching module: used to crop the image image1_roi from the historical image image1 according to the region (x, y, w, h) as a template. The region values ​​x, y, w, h are the upper left corner abscissa, ordinate, region width, and region height of the rectangular region of the image image1_roi respectively. The standard correlation coefficient matching method is used to perform template matching on the inspection image image2 to obtain the best matching position (x m ,y m ) and the standard correlation coefficient V co ; Calculate offset module: used to calculate the offset based on the best matching position (x m ,y m ), calculate the offset (dx, dy) from the historical image image1 to the inspection image image2; Feature point extraction module: used to extract and describe SURF feature points of historical image image1 and inspection image image2 respectively, and obtain N matching point pairs by nearest neighbor matching. If N≥threshold th1, jump to step S2 to continue execution; If N < threshold th1, the N point pairs are used as the homography matrix to calculate the point pairs, and the process jumps to step S5 to continue the process; Calculate homography matrix module: use the homography matrix to calculate point pairs, and calculate the homography matrix H1 from the historical image image1 to the inspection image image2 according to the random sampling consistency RANSAC method; calculate the corresponding point (x t ,y t ), where W and H are the width and height of the historical image image1; Calculate feature point matching offset module: used to calculate the offset (d x ',d y '); Module for calculating the standard correlation coefficient of cropped images: used to crop the image image2_roi from the inspection image image2 according to the area (x', y', w, h). The area values ​​x', y', w, h are the upper left corner abscissa, ordinate, area width, and area height of the rectangular area of ​​the image image2_roi, respectively. The standard correlation coefficient V' of the image image1_roi and the image image2_roi is calculated. co ; Comparison offset module: used to compare V' co With V co If V co >V' co , then (dx,dy) is used as the offset from the historical image image1 to the inspection image image2; if V co ≤V' co , then (dx',dy') is used as the offset from the historical image image1 to the inspection image image2.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for calculating the offset of feature point matching and template matching described in any one of claims 1 to 4 are implemented.

7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for calculating the offset of feature point matching and template matching as described in any one of claims 1 to 4 are implemented.