CN118038096A - Offset calculation method and system for feature point matching and template matching - Google Patents
Offset calculation method and system for feature point matching and template matching Download PDFInfo
- Publication number
- CN118038096A CN118038096A CN202410180638.1A CN202410180638A CN118038096A CN 118038096 A CN118038096 A CN 118038096A CN 202410180638 A CN202410180638 A CN 202410180638A CN 118038096 A CN118038096 A CN 118038096A
- Authority
- CN
- China
- Prior art keywords
- picture
- matching
- offset
- image1
- image2
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000004364 calculation method Methods 0.000 title claims abstract description 62
- 238000000034 method Methods 0.000 claims abstract description 54
- 239000011159 matrix material Substances 0.000 claims abstract description 36
- 238000007689 inspection Methods 0.000 claims abstract description 31
- 238000000605 extraction Methods 0.000 claims abstract description 12
- 238000005070 sampling Methods 0.000 claims description 6
- 238000004590 computer program Methods 0.000 claims description 5
- 230000009191 jumping Effects 0.000 claims description 5
- 238000012163 sequencing technique Methods 0.000 claims description 3
- 230000000739 chaotic effect Effects 0.000 abstract description 6
- 230000000694 effects Effects 0.000 abstract description 5
- 230000009286 beneficial effect Effects 0.000 abstract description 4
- 238000003745 diagnosis Methods 0.000 abstract description 4
- 239000002609 medium Substances 0.000 description 9
- 230000004048 modification Effects 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 3
- 230000008901 benefit Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 230000007547 defect Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 239000012120 mounting media Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Landscapes
- Image Analysis (AREA)
Abstract
The invention provides a method and a system for calculating offset of feature point matching and template matching, wherein the method comprises the following steps: acquiring a history picture and a patrol picture of a designated point location; cutting out templates from the historical pictures; template matching is carried out on the inspection picture, and the optimal matching position and the standard correlation coefficient V co are obtained; calculating the offset from the historical picture to the inspection picture; carrying out SURF feature point extraction and description on the historical picture and the patrol picture respectively; calculating a homography matrix from the historical picture to the inspection picture; calculating the offset of feature point matching; calculating a correlation coefficient V ' co; the magnitudes of V ' co and V co are compared to determine the offset. The invention combines template matching and special diagnosis point matching, is beneficial to accelerating the extraction efficiency of the feature points, enhances the calculation effect of the offset in chaotic scenes and improves the calculation accuracy; meanwhile, the method does not depend on the number of the specified targets in the image, so that the practicability of the scene is enhanced, and the generalization of the calculation method is improved.
Description
Technical Field
The invention relates to the technical field of robot inspection, in particular to a method and a system for calculating offset of feature point matching and template matching.
Background
In the process of using the robot to execute the inspection task, the track and the holder angles of all inspection points are recorded in advance so as to acquire the image information of the target point for further analysis.
However, due to the introduction of various errors in the actual inspection process, the acquired certain point position picture is offset compared with the pre-acquired image. In order to adjust the angle of the pan-tilt or acquire the overlapping area of the images, the offset between the acquired point location picture and the two pictures of the pre-acquired images needs to be calculated.
The existing method for calculating the offset between the two graphs mainly comprises the following two steps:
The first method is a method of directly adopting feature points (feature points such as SIFT and SURF) to match, namely, firstly, respectively extracting the feature points of two images, then, carrying out matching calculation on the feature points of the two images to obtain a homography matrix (also called as projection transformation), taking the center point of one image to obtain the center point of the other image through the homography matrix, and then, calculating the horizontal offset and the vertical offset between the center points of the two images.
However, the method has the defects of difficult extraction of the characteristic points and poor calculation effect on chaotic scenes, wherein the chaotic scenes often have calculation errors, such as single-device scenes with sky as the background and repeated texture scenes such as meshes.
The second method is to introduce a target detection model by combining the first method, firstly detect a scene specified target, and if the calculation condition is met, take the offset between the detected target centers in the two figures as the image offset; if the calculation condition is not satisfied, the first method is employed.
The second method has the main disadvantages of being unfavorable for the calculation of non-target scenes and multi-target scenes, not being effective in the non-target scenes and part of the multi-target scenes, and having poor generalization depending on the designated target types.
Disclosure of Invention
In view of this, the invention aims to provide a method and a system for calculating the offset of feature point matching and template matching, which combine template matching and special diagnosis point matching, more effectively solve the problems of difficult feature point extraction, poor offset calculation effect of chaotic scenes and the like in the prior art, and improve calculation accuracy; meanwhile, whether the number of the specified targets is more or not in the image is not dependent, so that the practicability of a scene is enhanced, and the generalization of a computing method is improved.
The invention provides a method for calculating offset of feature point matching and template matching, which comprises the following steps:
S1, when a robot moves to a position of a designated point, acquiring a history image1 of the point from a storage device, adjusting a holder through holder angle information recorded by the point, acquiring a patrol image2 through a holder camera, and setting the sizes of the history image1 and the patrol image2 to be consistent;
S2, cutting out a picture image1_roi from a history picture image1 according to a region (x, y, w, h) as a template, wherein the region values x, y, w and h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image 1_roi; template matching is carried out on the inspection picture image2 by adopting a standard correlation coefficient matching method, so as to obtain an optimal matching position (x m,ym) and a standard correlation coefficient V co;
S3, calculating the offset (dx, dy) of the historical picture image1 to the inspection picture image2 based on the best matching position (x m,ym), wherein the calculation formula of the offset (dx, dy) is as follows:
dx=xm-x,dy=ym-y (1)
In the formula (1), d x is a horizontal offset, and d y is a vertical offset;
S4, extracting and describing SURF characteristic points of the historical picture image1 and the patrol picture image2 respectively, obtaining N matching point pairs in a nearest neighbor matching mode, and if N is more than or equal to a threshold th1, jumping to the step S2 to continue execution; if N is less than the threshold th1, N point pairs are used as homography matrix calculation point pairs, and the step S5 is skipped to continue to be executed;
S5, calculating a homography matrix H from a historical picture image1 to a patrol picture image2 according to a random sampling consistency RANSAC method by utilizing the homography matrix calculation point pairs;
According to the homography matrix H, calculating a corresponding point (x t,yt) of a center point (W/2, H/2) of the historical picture image1 on the inspection picture image2, wherein a calculation formula of the corresponding point (x t,yt) is as follows:
S6, calculating an offset (d x',dy ') of feature point matching of the historical picture image1 to the patrol picture image2, wherein a calculation formula of the offset (d x',dy') is as follows:
dx'=xt-W/2,dy'=yt-H/2 (2)
s7, cutting out a picture image2_roi from the patrol picture image2 according to the region (x ', y', w, h), wherein the region value x ', y', w, h is the left upper-corner abscissa, the ordinate, the region width and the region height of the rectangular region of the picture image2_roi, and the calculation formula of x ', y' is as follows:
x’=x+dx',y'=y+dy’ (3)
The calculation formula for calculating the correlation coefficient V' co of the picture image1_roi and the picture image2_roi is as follows:
In formula (4), I '1 (x, y) and I' 2 (x, y) represent pixel values of picture image1_roi and picture image2_roi, respectively;
S8, comparing the sizes of V' co and V co, and if V co>V'co, taking (dx, dy) as the offset of the historical picture image1 to the patrol picture image 2; if V co≤V'co, (dx ', dy') is taken as the offset from the history picture image1 to the patrol picture image 2.
Further, the method for calculating the point pairs by using the N point pairs as the homography matrix in the step S4 includes:
and sequencing the obtained N feature points according to the Euclidean distance of feature description from small to large, and taking the first th1 matching point pairs as homography matrix calculation point pairs.
Further, the values x, y, W, H of the regions in the history image1 in the step S2 are set to W/3, H/3,W/3, and H/3, where W and H are the width and height of the history image 1.
Further, the values x ', y', W, H of the areas in the inspection image2 in the step S7 are set to w=w/3, and h=h/3, where W and H are the width and the height of the inspection image 2.
Further, the threshold th1 of the step S4 is set to th1=200.
The invention also provides a system for calculating the offset of the feature point matching and the template matching, which executes the method for calculating the offset of the feature point matching and the template matching, and comprises the following steps:
the historical picture and inspection picture module is used for obtaining: when the robot moves to the position of the appointed point, acquiring a history image1 of the point from a storage device, adjusting a holder according to holder angle information recorded by the point, acquiring a patrol image2 through a holder camera, and setting the sizes of the history image1 and the patrol image2 to be consistent;
Template matching module: the method comprises the steps of cutting out a picture image1_roi from a historical picture image1 according to a region (x, y, w, h) as a template, wherein the region values x, y, w and h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image 1_roi; template matching is carried out on the inspection picture image2 by adopting a standard correlation coefficient matching method, so as to obtain an optimal matching position (x m,ym) and a standard correlation coefficient V co;
And a calculating offset module: for calculating an offset (dx, dy) of the history picture image1 to the patrol picture image2 based on the best matching position (x m,ym);
The feature point extraction module: the method comprises the steps of carrying out SURF feature point extraction and description on a historical picture image1 and a patrol picture image2 respectively, obtaining N matching point pairs in a nearest neighbor matching mode, and if N is more than or equal to a threshold th1, jumping to the step S2 to continue execution; if N is less than the threshold th1, N point pairs are used as homography matrix calculation point pairs, and the step S5 is skipped to continue to be executed;
And a homography matrix module is calculated: calculating a homography matrix H from a historical picture image1 to a patrol picture image2 according to a random sampling consistency RANSAC method by utilizing the homography matrix calculation point pairs; calculating corresponding points (x t,yt) of center points (W/2, H/2) of the historical picture image1 on the patrol picture image2 according to the homography matrix H;
And a characteristic point matching offset calculating module: calculating an offset (d x',dy') for feature point matching of the history picture image1 to the patrol picture image 2;
And a clipping picture correlation coefficient calculating module: the method comprises the steps of cutting out a picture image2_roi from a patrol picture image2 according to regions (x ', y ', w, h), wherein the region values x ', y ', w, h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image2_roi, and calculating correlation coefficients V ' co of the picture image1_roi and the picture image 2_roi;
And comparing and determining an offset module: comparing the sizes of V' co and V co, and if V co>V'co, (dx, dy) is used as the offset from the history image1 to the inspection image 2; if V co≤V'co, (dx ', dy') is taken as the offset from the history picture image1 to the patrol picture image 2.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the offset amount calculation method of feature point matching and template matching as described above.
The present invention also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the offset calculation method of feature point matching and template matching as described above when executing the program.
Compared with the prior art, the invention has the beneficial effects that:
According to the method and the system for calculating the offset of the feature point matching and the template matching, the template matching and the special diagnosis point matching are combined, so that the extraction efficiency of the feature points is improved, the offset calculation effect in chaotic scenes can be enhanced, and the calculation accuracy is improved; meanwhile, the method does not depend on the number of the specified targets in the image, so that the practicability of the scene is enhanced, and the generalization of the calculation method is improved.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention.
In the drawings:
FIG. 1 is a flowchart illustrating the steps of calculating the offset of feature point matching and template matching according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for calculating the offset of feature point matching and template matching according to the present invention;
Fig. 3 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of systems and products consistent with some aspects of the present disclosure as detailed in the appended claims.
The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and/or" as used herein is and includes any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" depending on the context.
Embodiments of the present invention are described in further detail below.
The embodiment of the invention provides a method for calculating the offset of feature point matching and template matching, which is shown in fig. 2 and comprises the following steps:
S1, when a robot moves to a position of a designated point, acquiring a history image1 of the point from a storage device, adjusting a holder through holder angle information recorded by the point, acquiring a patrol image2 through a holder camera, and setting the sizes of the history image1 and the patrol image2 to be consistent;
S2, cutting out a picture image1_roi from a history picture image1 according to a region (x, y, w, h) as a template, wherein the region values x, y, w and h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image 1_roi; template matching is carried out on the inspection picture image2 by adopting a standard correlation coefficient matching method, so as to obtain an optimal matching position (x m,ym) and a standard correlation coefficient V co;
In this embodiment, the region values x, y, W, H in the history image1 are set to W/3, H/3,W/3, and H/3, where W and H are the width and height of the history image 1.
S3, calculating the offset (dx, dy) of the historical picture image1 to the inspection picture image2 based on the best matching position (x m,ym), wherein the calculation formula of the offset (dx, dy) is as follows:
dx=xm-x,dy=ym-y (1)
In the formula (1), d x is a horizontal offset, and d y is a vertical offset;
S4, SURF feature points are extracted and described for the historical picture image1 and the patrol picture image2 respectively, N matching point pairs are obtained in a nearest neighbor matching mode, and if N is more than or equal to a threshold value th1 (in the embodiment, the threshold value th1 is set to th1=200), the step S2 is skipped to continue to be executed; if N is less than the threshold th1, N point pairs are used as homography matrix calculation point pairs, and the step S5 is skipped to continue to be executed;
In this embodiment, the method for calculating the point pairs by using the N point pairs as the homography matrix includes:
and sequencing the obtained N feature points according to the Euclidean distance of feature description from small to large, and taking the first th1 matching point pairs as homography matrix calculation point pairs.
S5, calculating a homography matrix H from a historical picture image1 to a patrol picture image2 according to a random sampling consistency RANSAC method by utilizing the homography matrix calculation point pairs;
According to the homography matrix H, calculating a corresponding point (x t,yt) of a center point (W/2, H/2) of the historical picture image1 on the inspection picture image2, wherein a calculation formula of the corresponding point (x t,yt) is as follows:
S6, calculating an offset (d x',dy ') of feature point matching of the historical picture image1 to the patrol picture image2, wherein a calculation formula of the offset (d x',dy') is as follows:
dx'=xt-W/2,dy'=yt-H/2 (2)
s7, cutting out a picture image2_roi from the patrol picture image2 according to the region (x ', y', w, h), wherein the region value x ', y', w, h is the left upper-corner abscissa, the ordinate, the region width and the region height of the rectangular region of the picture image2_roi, and the calculation formula of x ', y' is as follows:
x’=x+dx',y'=y+dy’ (3)
In this embodiment, the area values x ', y', W, H in the inspection image2 are set to w=w/3, and h=h/3, where W and H are the width and height of the inspection image 2.
The calculation formula for calculating the correlation coefficient V' co of the picture image1_roi and the picture image2_roi is as follows:
In formula (4), I '1 (x, y) and I' 2 (x, y) represent pixel values of picture image1_roi and picture image2_roi, respectively;
S8, comparing the sizes of V' co and V co, and if V co>V'co, taking (dx, dy) as the offset of the historical picture image1 to the patrol picture image 2; if V co≤V'co, (dx ', dy') is taken as the offset from the history picture image1 to the patrol picture image 2.
Fig. 1 shows a flow of steps of calculating the offset of feature point matching and template matching according to an embodiment of the present invention.
The embodiment of the invention also provides a system for calculating the offset of the feature point matching and the template matching, which executes the method for calculating the offset of the feature point matching and the template matching, and comprises the following steps:
the historical picture and inspection picture module is used for obtaining: when the robot moves to the position of the appointed point, acquiring a history image1 of the point from a storage device, adjusting a holder according to holder angle information recorded by the point, acquiring a patrol image2 through a holder camera, and setting the sizes of the history image1 and the patrol image2 to be consistent;
Template matching module: the method comprises the steps of cutting out a picture image1_roi from a historical picture image1 according to a region (x, y, w, h) as a template, wherein the region values x, y, w and h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image 1_roi; template matching is carried out on the inspection picture image2 by adopting a standard correlation coefficient matching method, so as to obtain an optimal matching position (x m,ym) and a standard correlation coefficient V co;
And a calculating offset module: for calculating an offset (dx, dy) of the history picture image1 to the patrol picture image2 based on the best matching position (x m,ym);
The feature point extraction module: the method comprises the steps of carrying out SURF feature point extraction and description on a historical picture image1 and a patrol picture image2 respectively, obtaining N matching point pairs in a nearest neighbor matching mode, and if N is more than or equal to a threshold th1, jumping to the step S2 to continue execution; if N is less than the threshold th1, N point pairs are used as homography matrix calculation point pairs, and the step S5 is skipped to continue to be executed;
And a homography matrix module is calculated: calculating a homography matrix H from a historical picture image1 to a patrol picture image2 according to a random sampling consistency RANSAC method by utilizing the homography matrix calculation point pairs; calculating corresponding points (x t,yt) of center points (W/2, H/2) of the historical picture image1 on the patrol picture image2 according to the homography matrix H;
And a characteristic point matching offset calculating module: calculating an offset (d x',dy') for feature point matching of the history picture image1 to the patrol picture image 2;
And a clipping picture correlation coefficient calculating module: the method comprises the steps of cutting out a picture image2_roi from a patrol picture image2 according to regions (x ', y ', w, h), wherein the region values x ', y ', w, h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image2_roi, and calculating correlation coefficients V ' co of the picture image1_roi and the picture image 2_roi;
And comparing and determining an offset module: comparing the sizes of V' co and V co, and if V co>V'co, (dx, dy) is used as the offset from the history image1 to the inspection image 2; if V co≤V'co, (dx ', dy') is taken as the offset from the history picture image1 to the patrol picture image 2.
The method and the system for calculating the offset of the feature point matching and the template matching, provided by the embodiment of the invention, are beneficial to accelerating the extraction efficiency of the feature point by combining the template matching and the special diagnosis point matching, can enhance the calculation effect of the offset in chaotic scenes and improve the calculation accuracy; meanwhile, the method does not depend on the number of the specified targets in the image, so that the practicability of the scene is enhanced, and the generalization of the calculation method is improved.
The embodiment of the invention also provides a computer device, and fig. 3 is a schematic structural diagram of the computer device provided by the embodiment of the invention; referring to fig. 3 of the drawings, the computer apparatus includes: an input system 23, an output system 24, a memory 22, and a processor 21; the memory 22 is configured 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 are caused to implement the offset calculation method of feature point matching and template matching as provided in the above-described embodiments; wherein the input system 23, the output system 24, the memory 22 and the processor 21 may be connected by a bus or otherwise, for example in fig. 3.
The memory 22 is used as a readable storage medium of a computing device and can be used for storing a software program and a computer executable program, and the program instructions corresponding to the offset computing methods of feature point matching and template matching according to the embodiment of the invention; the memory 22 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the device, etc.; in addition, memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device; in some examples, memory 22 may further comprise memory located remotely from processor 21, which may be connected to the device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input system 23 is operable to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the device; output system 24 may include a display device such as a display screen.
The processor 21 executes various functional applications of the apparatus and data processing, that is, realizes the above-described offset amount calculation method of feature point matching and template matching by running software programs, instructions, and modules stored in the memory 22.
The computer device provided by the above embodiment can be used for executing the offset calculating method for feature point matching and template matching provided by the above embodiment, and has corresponding functions and beneficial effects.
Embodiments of the present invention also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing the feature point matching and template matching offset calculation methods as provided by the above embodiments, the storage medium being any of various types of memory devices or storage devices, the storage medium comprising: mounting media such as CD-ROM, floppy disk or tape systems; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, lanbas (Rambus) RAM, etc.; nonvolatile memory such as flash memory, magnetic media (e.g., 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 combinations 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 second, different computer system, the second computer system being connected to the first computer system through a network (such as the internet); the second computer system may provide program instructions to the first computer for execution. Storage media includes two or more storage media that may reside in different locations (e.g., in different computer systems connected by a network). The storage medium may store program instructions (e.g., embodied as a computer program) executable by one or more processors.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present invention is not limited to the offset calculation method for feature point matching and template matching described in the above embodiments, and may also perform the related operations in the offset calculation method for feature point matching and template matching provided in any embodiment of the present invention.
Thus far, the technical solution of the present invention has been described in connection with the preferred embodiments shown in the drawings, but it is easily understood by those skilled in the art that the scope of protection of the present invention is not limited to these specific embodiments. Equivalent modifications and substitutions for related technical features may be made by those skilled in the art without departing from the principles of the present invention, and such modifications and substitutions will be within the scope of the present invention.
The foregoing description is only of the preferred embodiments of the invention and is not intended to limit the invention; various modifications and variations of the present invention will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (8)
1. A method for calculating an offset of feature point matching and template matching, comprising:
S1, when a robot moves to a position of a designated point, acquiring a history image1 of the point from a storage device, adjusting a holder through holder angle information recorded by the point, acquiring a patrol image2 through a holder camera, and setting the sizes of the history image1 and the patrol image2 to be consistent;
S2, cutting out a picture image1_roi from a history picture image1 according to a region (x, y, w, h) as a template, wherein the region values x, y, w and h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image 1_roi; template matching is carried out on the inspection picture image2 by adopting a standard correlation coefficient matching method, so as to obtain an optimal matching position (x m,ym) and a standard correlation coefficient V co;
S3, calculating the offset (dx, dy) of the historical picture image1 to the inspection picture image2 based on the best matching position (x m,ym), wherein the calculation formula of the offset (dx, dy) is as follows:
dx=xm-x,dy=ym-y (1)
In the formula (1), d x is a horizontal offset, and d y is a vertical offset;
S4, extracting and describing SURF characteristic points of the historical picture image1 and the patrol picture image2 respectively, obtaining N matching point pairs in a nearest neighbor matching mode, and if N is more than or equal to a threshold th1, jumping to the step S2 to continue execution; if N is less than the threshold th1, N point pairs are used as homography matrix calculation point pairs, and the step S5 is skipped to continue to be executed;
S5, calculating a homography matrix H from a historical picture image1 to a patrol picture image2 according to a random sampling consistency RANSAC method by utilizing the homography matrix calculation point pairs;
According to the homography matrix H, calculating a corresponding point (x t,yt) of a center point (W/2, H/2) of the historical picture image1 on the inspection picture image2, wherein a calculation formula of the corresponding point (x t,yt) is as follows:
S6, calculating an offset (d x',dy ') of feature point matching of the historical picture image1 to the patrol picture image2, wherein a calculation formula of the offset (d x',dy') is as follows:
dx'=xt-W/2,dy'=yt-H/2 (2)
s7, cutting out a picture image2_roi from the patrol picture image2 according to the region (x ', y', w, h), wherein the region value x ', y', w, h is the left upper-corner abscissa, the ordinate, the region width and the region height of the rectangular region of the picture image2_roi, and the calculation formula of x ', y' is as follows:
x’=x+dx',y'=y+dy’ (3)
The calculation formula for calculating the correlation coefficient V' co of the picture image1_roi and the picture image2_roi is as follows:
In formula (4), I '1 (x, y) and I' 2 (x, y) represent pixel values of picture image1_roi and picture image2_roi, respectively;
S8, comparing the sizes of V' co and V co, and if V co>V'co, taking (dx, dy) as the offset of the historical picture image1 to the patrol picture image 2; if V co≤V'co, (dx ', dy') is taken as the offset from the history picture image1 to the patrol picture image 2.
2. The method for calculating the offset amount of the feature point matching and the template matching according to claim 1, wherein the method for calculating the point pairs using the N point pairs as the homography matrix in the step S4 includes:
and sequencing the obtained N feature points according to the Euclidean distance of feature description from small to large, and taking the first th1 matching point pairs as homography matrix calculation point pairs.
3. The method of calculating the offset of feature point matching and template matching according to claim 1, wherein the values x, y, W, H of the regions in the history picture 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 history picture image 1.
4. The method according to claim 1, wherein the values x ', y', W, H of the regions in the inspection image2 in step S7 are set to w=w/3, and h=h/3, where W and H are the width and height of the inspection image 2.
5. The method of calculating the offset amount for feature point matching and template matching according to claim 1, wherein the threshold th1 of the step S4 is set to th1=200.
6. An offset calculation system for feature point matching and template matching, which performs the offset calculation method for feature point matching and template matching according to any one of claims 1 to 5, comprising:
the historical picture and inspection picture module is used for obtaining: when the robot moves to the position of the appointed point, acquiring a history image1 of the point from a storage device, adjusting a holder according to holder angle information recorded by the point, acquiring a patrol image2 through a holder camera, and setting the sizes of the history image1 and the patrol image2 to be consistent;
Template matching module: the method comprises the steps of cutting out a picture image1_roi from a historical picture image1 according to a region (x, y, w, h) as a template, wherein the region values x, y, w and h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image 1_roi; template matching is carried out on the inspection picture image2 by adopting a standard correlation coefficient matching method, so as to obtain an optimal matching position (x m,ym) and a standard correlation coefficient V co;
And a calculating offset module: for calculating an offset (dx, dy) of the history picture image1 to the patrol picture image2 based on the best matching position (x m,ym);
The feature point extraction module: the method comprises the steps of carrying out SURF feature point extraction and description on a historical picture image1 and a patrol picture image2 respectively, obtaining N matching point pairs in a nearest neighbor matching mode, and if N is more than or equal to a threshold th1, jumping to the step S2 to continue execution; if N is less than the threshold th1, N point pairs are used as homography matrix calculation point pairs, and the step S5 is skipped to continue to be executed;
And a homography matrix module is calculated: calculating a homography matrix H from a historical picture image1 to a patrol picture image2 according to a random sampling consistency RANSAC method by utilizing the homography matrix calculation point pairs; calculating corresponding points (x t,yt) of center points (W/2, H/2) of the historical picture image1 on the patrol picture image2 according to the homography matrix H;
And a characteristic point matching offset calculating module: calculating an offset (d x',dy') for feature point matching of the history picture image1 to the patrol picture image 2;
And a clipping picture correlation coefficient calculating module: the method comprises the steps of cutting out a picture image2_roi from a patrol picture image2 according to regions (x ', y ', w, h), wherein the region values x ', y ', w, h are respectively the left upper-corner abscissa, the ordinate, the region width and the region height of a rectangular region of the picture image2_roi, and calculating correlation coefficients V ' co of the picture image1_roi and the picture image 2_roi;
And comparing and determining an offset module: comparing the sizes of V' co and V co, and if V co>V'co, (dx, dy) is used as the offset from the history image1 to the inspection image 2; if V co≤V'co, (dx ', dy') is taken as the offset from the history picture image1 to the patrol picture image 2.
7. A computer-readable storage medium having stored thereon a computer program, characterized in that the program when executed by a processor implements the steps of the characteristic point matching and template matching offset calculation method of any of claims 1-5.
8. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the characteristic point matching and template matching offset calculation method according to any of claims 1-5 when the program is executed by the processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410180638.1A CN118038096A (en) | 2024-02-18 | 2024-02-18 | Offset calculation method and system for feature point matching and template matching |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410180638.1A CN118038096A (en) | 2024-02-18 | 2024-02-18 | Offset calculation method and system for feature point matching and template matching |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118038096A true CN118038096A (en) | 2024-05-14 |
Family
ID=90992791
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410180638.1A Pending CN118038096A (en) | 2024-02-18 | 2024-02-18 | Offset calculation method and system for feature point matching and template matching |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118038096A (en) |
-
2024
- 2024-02-18 CN CN202410180638.1A patent/CN118038096A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109242903B (en) | Three-dimensional data generation method, device, equipment and storage medium | |
CN109543489B (en) | Positioning method and device based on two-dimensional code and storage medium | |
WO2019119328A1 (en) | Vision-based positioning method and aerial vehicle | |
Huang et al. | Efficient image stitching of continuous image sequence with image and seam selections | |
CN110111388B (en) | Three-dimensional object pose parameter estimation method and visual equipment | |
CN109479082B (en) | Image processing method and apparatus | |
CN111091590B (en) | Image processing method, device, storage medium and electronic equipment | |
CN109784250B (en) | Positioning method and device of automatic guide trolley | |
JPH08202879A (en) | Method for change of continuous video images belonging to sequence of mutually interrelated images as well as apparatus and method for replacement of expression of targetdiscriminated by set of object points by matched expression of predetermined and stored pattern of same geometrical shape in continuous tv frames of same sequence | |
WO2019033575A1 (en) | Electronic device, face tracking method and system, and storage medium | |
KR20210116953A (en) | Method and apparatus for tracking target | |
CN110245643B (en) | Target tracking shooting method and device and electronic equipment | |
CN113256683B (en) | Target tracking method and related equipment | |
CN114926514A (en) | Registration method and device of event image and RGB image | |
CN115705651A (en) | Video motion estimation method, device, equipment and computer readable storage medium | |
WO2024022301A1 (en) | Visual angle path acquisition method and apparatus, and electronic device and medium | |
CN112215036B (en) | Cross-mirror tracking method, device, equipment and storage medium | |
CN114095780A (en) | Panoramic video editing method, device, storage medium and equipment | |
CN112101148A (en) | Moving target detection method and device, storage medium and terminal equipment | |
CN118038096A (en) | Offset calculation method and system for feature point matching and template matching | |
CN116051736A (en) | Three-dimensional reconstruction method, device, edge equipment and storage medium | |
CN115514887A (en) | Control method and device for video acquisition, computer equipment and storage medium | |
Gao et al. | A new image mosaics algorithm based on feature points matching | |
CN113033578A (en) | Image calibration method, system, terminal and medium based on multi-scale feature matching | |
CN117333686A (en) | Target positioning method, device, equipment and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |