CN113128554A - Target positioning method, system, device and medium based on template matching - Google Patents

Target positioning method, system, device and medium based on template matching Download PDF

Info

Publication number
CN113128554A
CN113128554A CN202110257976.7A CN202110257976A CN113128554A CN 113128554 A CN113128554 A CN 113128554A CN 202110257976 A CN202110257976 A CN 202110257976A CN 113128554 A CN113128554 A CN 113128554A
Authority
CN
China
Prior art keywords
grid
target
determining
template
feature vector
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.)
Granted
Application number
CN202110257976.7A
Other languages
Chinese (zh)
Other versions
CN113128554B (en
Inventor
彭绍湖
朱希诚
胡晓
刘长红
杨兴鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou University
Original Assignee
Guangzhou University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangzhou University filed Critical Guangzhou University
Priority to CN202110257976.7A priority Critical patent/CN113128554B/en
Publication of CN113128554A publication Critical patent/CN113128554A/en
Application granted granted Critical
Publication of CN113128554B publication Critical patent/CN113128554B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/751Comparing pixel values or logical combinations thereof, or feature values having positional relevance, e.g. template matching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/50Extraction of image or video features by performing operations within image blocks; by using histograms, e.g. histogram of oriented gradients [HoG]; by summing image-intensity values; Projection analysis
    • G06V10/507Summing image-intensity values; Histogram projection analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/46Descriptors for shape, contour or point-related descriptors, e.g. scale invariant feature transform [SIFT] or bags of words [BoW]; Salient regional features
    • G06V10/467Encoded features or binary features, e.g. local binary patterns [LBP]

Abstract

The invention discloses a target positioning method, a system, a device and a medium based on template matching, wherein the method comprises the following steps: constructing a template image pyramid and constructing a first grid; selecting a first grid with the average gradient amplitude being greater than or equal to a preset first threshold value as a second grid; determining first gradient amplitude and first gradient direction entropy of all pixel points in a second grid, determining a first local feature point according to the first gradient amplitude and the first gradient direction entropy, and establishing a first LBP histogram feature vector according to the first local feature point; and establishing a second LBP histogram feature vector of the target image pyramid, and determining the position and the rotation angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector. The invention reduces the requirement on system computing power, overcomes the defect of large influence of rotation in the prior art, improves the accuracy of target positioning, and can be widely applied to the technical field of computer vision.

Description

Target positioning method, system, device and medium based on template matching
Technical Field
The invention relates to the technical field of computer vision, in particular to a target positioning method, a target positioning system, a target positioning device and a target positioning medium based on template matching.
Background
Template matching belongs to a classical method in the field of computer vision and image processing, a characteristic vector of an image is extracted by giving a template image and a target image, the similarity of candidate windows in the template image and the target image is calculated, and the candidate window most similar to the template image is a matching result.
The lbp (local Binary patterns) algorithm, since 2002 proposed by Timo Ojala et al, has total 36 sets of Binary patterns for representing the rotation invariance of pixel points by comparing the gray scale values of the pixel points and eight neighborhoods, wherein 9 Binary patterns with uniform ≦ 2 are called equivalent patterns, and the rest Binary patterns are called mixed patterns. The LBP-based variables are continuously innovated, but the core of the LBP-based algorithm is a binary pattern of local pixel points. The MRELBP algorithm proposed by Li Liu et al includes an ELBP _ CI method based on central intensity, an ELBP _ NI method based on neighborhood intensity, an ELBP _ RD method based on radial difference, and an ELBP _ AD method based on angular difference, and on the basis of ELBP, the response of a median filter is used to replace the value of a single pixel, and finally 5 modes with symmetry are selected from a mixed mode and combined with 9 modes of equivalent modes, but the rotation-invariant stability in the mixed mode is not enough, and the influence of rotation is large. The LBP-NMF algorithm proposed by Ioan Buciu et al extracts LBP histogram features of pictures of four parts of eyes, nose and mouth for template matching with respect to facial expressions, and since LBP histogram information of each point in the region needs to be used for calculation, the calculation takes more time, and the accuracy of the result is also related to the position division of the four parts.
Disclosure of Invention
The present invention aims to solve at least to some extent one of the technical problems existing in the prior art.
Therefore, an object of an embodiment of the present invention is to provide a template matching-based target location method, where on one hand, an LBP histogram feature vector is established according to the screened local feature points, and it is not necessary to calculate each pixel point in an image, thereby reducing the requirement on the computational power of the system, and on the other hand, stable pixel points are determined according to the similarity matching of the LBP histogram feature vector, thereby overcoming the defect that the prior art is greatly affected by rotation, and improving the accuracy of target location.
Another object of the embodiments of the present invention is to provide a target positioning system based on template matching.
In order to achieve the technical purpose, the technical scheme adopted by the embodiment of the invention comprises the following steps:
in a first aspect, an embodiment of the present invention provides a target positioning method based on template matching, including the following steps:
acquiring a template image, constructing a template image pyramid according to the template image, and constructing a first grid according to the template image pyramid;
determining the average gradient amplitude of all pixel points in the first grid, and selecting the first grid with the average gradient amplitude being greater than or equal to a preset first threshold value as a second grid;
determining first gradient amplitude and first gradient direction entropy of all pixel points in the second grid, determining a first local feature point according to the first gradient amplitude and the first gradient direction entropy, and establishing a first LBP histogram feature vector according to the first local feature point;
acquiring a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotation angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector.
Further, in an embodiment of the present invention, the step of obtaining a template image, constructing a template image pyramid according to the template image, and constructing a first mesh according to the template image pyramid specifically includes:
acquiring a template image, and expanding the width and the height of the template image to obtain an expanded template image;
downsampling the extended template image to generate a template image pyramid;
extracting a first pyramid image of each layer in the template image pyramid, and constructing a first grid in a self-adaptive manner through quadtree segmentation according to the first pyramid image;
wherein the first pyramid image is covered by a corresponding first grid.
Further, in an embodiment of the present invention, in the step of adaptively constructing the first mesh by quadtree splitting according to the first pyramid image, when the width or height of the first mesh is smaller than a preset sixth threshold, the quadtree splitting is not performed any more, and the sixth threshold satisfies the following condition:
Figure BDA0002968750260000021
wherein, musDenotes a sixth threshold value, WTLWidth, H, of top level image representing template image pyramidTLRepresenting the height of the topmost image of the template image pyramid.
Further, in an embodiment of the present invention, the step of determining an average gradient amplitude of all pixel points in the first grid, and selecting the first grid with the average gradient amplitude being greater than or equal to a preset first threshold as the second grid specifically includes:
calculating the sum of the gradient amplitudes of all the pixel points in the first grid, and determining the average gradient amplitude according to the number of the pixel points in the first grid and the sum of the gradient amplitudes;
and if the average gradient amplitude is determined to be larger than or equal to the first threshold, acquiring the corresponding first grid as a second grid.
Further, in an embodiment of the present invention, the step of determining a first gradient magnitude and a first gradient direction entropy of all pixel points in the second grid, determining a first local feature point according to the first gradient magnitude and the first gradient direction entropy, and establishing a first LBP histogram feature vector according to the first local feature point specifically includes:
determining first gradient amplitude and first gradient direction entropy values of all pixel points in the second grid;
acquiring a preset second threshold and a preset third threshold, and selecting pixel points of which the first gradient amplitude is greater than or equal to the second threshold and the first gradient direction entropy is greater than or equal to the third threshold as first local feature points;
and extracting a first LBP histogram feature vector by taking the first local feature point as a central pixel point.
Further, in an embodiment of the present invention, the step of extracting a first LBP histogram feature vector by using the first local feature point as a central pixel point specifically includes:
and establishing a first local feature point LBP histogram feature vector by taking the first local feature point as a central pixel point and combining nine modes of which the uniform is less than or equal to 2 in the LBP equivalent mode.
Further, in an embodiment of the present invention, the obtaining a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining a position and a rotation angle of a target to be positioned according to similarity matching between the first LBP histogram feature vector and the second LBP histogram feature vector specifically includes:
acquiring a target image, constructing a target image pyramid according to the target image, and constructing a third grid according to the target image pyramid;
determining the average gradient amplitude of all pixel points in the third grid, and selecting the third grid with the average gradient amplitude being greater than or equal to a preset fourth threshold value as a fourth grid;
determining second gradient magnitude and second gradient direction entropy of all pixel points in the fourth grid, determining second local feature points according to the second gradient magnitude and the second gradient direction entropy, and establishing second LBP histogram feature vectors according to the second local feature points;
and calculating the similarity of the first LBP histogram feature vector of each layer in the template image pyramid and the target image pyramid and the second LBP histogram feature vector of the corresponding position, sequentially performing similarity matching from the top layer to the bottom layer, eliminating second local feature points of which the similarity is smaller than a preset fifth threshold value, and screening out second local feature points of which the similarity is larger than or equal to the fifth threshold value from the bottom layer of the target image pyramid, thereby determining the position and the rotation angle of the target to be positioned.
In a second aspect, an embodiment of the present invention provides a target positioning system based on template matching, including:
the grid construction module is used for acquiring a template image, constructing a template image pyramid according to the template image and constructing a first grid according to the template image pyramid;
the grid selection module is used for determining the average gradient amplitude of all pixel points in the first grid and selecting the first grid with the average gradient amplitude being greater than or equal to a preset first threshold value as a second grid;
an LBP histogram feature vector establishing module, configured to determine first gradient magnitudes and first gradient direction entropy values of all pixel points in the second grid, determine a first local feature point according to the first gradient magnitudes and the first gradient direction entropy values, and establish a first LBP histogram feature vector according to the first local feature point;
and the similarity matching module is used for acquiring a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotation angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector.
In a third aspect, an embodiment of the present invention provides a target positioning apparatus based on template matching, including:
at least one processor;
at least one memory for storing at least one program;
the at least one program, when executed by the at least one processor, causes the at least one processor to implement a template matching-based object localization method as described above.
In a fourth aspect, the present invention further provides a computer-readable storage medium, in which a processor-executable program is stored, and the processor-executable program is configured to execute the above-mentioned target location method based on template matching when executed by a processor.
Advantages and benefits of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention:
compared with the prior art, the method and the device have the advantages that on one hand, the LBP histogram feature vector is established according to the screened local feature points, calculation is not needed for each pixel point in the image, the requirement on system calculation force is reduced, on the other hand, the stable pixel points are determined according to the similarity matching of the LBP histogram feature vectors, the defect that the prior art is greatly influenced by rotation is overcome, and the accuracy of target positioning is improved.
Drawings
In order to more clearly illustrate the technical solution in the embodiment of the present invention, the following description is made on the drawings required to be used in the embodiment of the present invention, and it should be understood that the drawings in the following description are only for convenience and clarity of describing some embodiments in the technical solution of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart illustrating steps of a target location method based on template matching according to an embodiment of the present invention;
fig. 2 is a block diagram of a target positioning system based on template matching according to an embodiment of the present invention;
fig. 3 is a block diagram of a target location apparatus based on template matching according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention. The step numbers in the following embodiments are provided only for convenience of illustration, the order between the steps is not limited at all, and the execution order of each step in the embodiments can be adapted according to the understanding of those skilled in the art.
In the description of the present invention, the meaning of a plurality is two or more, if there is a description to the first and the second for the purpose of distinguishing technical features, it is not understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features or implicitly indicating the precedence of the indicated technical features. Furthermore, unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art.
Referring to fig. 1, an embodiment of the present invention provides a target positioning method based on template matching, which specifically includes the following steps:
s101, obtaining a template image, constructing a template image pyramid according to the template image, and constructing a first grid according to the template image pyramid;
specifically, each layer in the template image pyramid has a corresponding pyramid image, the first grid is used for covering the pyramid image, and the first grid contains all pixel points of the pyramid image, so that the subsequent screening and the determination of local feature points belonging to edges and textures are facilitated according to the first grid. Step S101 includes the steps of:
s1011, obtaining a template image, and expanding the width and the height of the template image to obtain an expanded template image;
s1012, downsampling the extended template image to generate a template image pyramid;
s1013, extracting a first pyramid image of each layer in the template image pyramid, and adaptively constructing a first grid through quadtree segmentation according to the first pyramid image;
wherein the first pyramid image is covered by the corresponding first grid.
Specifically, a template image is acquired, and the width and the height of the template image are expanded to the nearest power of 2. And downsampling the expanded image by Gaussian smoothing with a scale factor of 2 to generate a template image pyramid.
The Angle is used for the image of each layer in the pyramid of the template graphjAngle of rotation, AnglejThe angle is calculated by:
Figure BDA0002968750260000051
wherein, AnglesIs the starting Angle of rotation, AngleEIs the end angle of rotation, the reference step size mu of the rotation angleALimited by the number of layers of the template pattern pyramid and the range of the rotation angle, so when the range of the rotation angle is small, muAShould also be reduced, and when the total number of layers of the pyramid is small, muAShould be increased. Rotating angle step length d from each layer of the pyramid top layer to the bottomAiWith a corresponding reduction in the time taken for the calculation, usually mu, while the angle is preciseAIs set to 1.
The smaller the size of the top image of the template graph pyramid is, the shorter the calculation time for matching with the target graph is, but the accuracy of the matching result is also reduced, and when the matching score of the result at the upper layer of the pyramid is not higher than the threshold value at the lower layer, the end of the downsampling matching of the result is meant.
As a further optional implementation, in the step of adaptively constructing the first mesh by quadtree segmentation according to the first pyramid image, when the width or height of the first mesh is smaller than a preset sixth threshold, the quadtree segmentation is not performed, and the sixth threshold satisfies the following condition:
Figure BDA0002968750260000061
wherein, musDenotes a sixth threshold value, WTLWidth, H, of top level image representing template image pyramidTLRepresenting the height of the topmost image of the template image pyramid.
Specifically, all images in the template image pyramid are extracted, including images obtained by rotating each layer of pyramid image at a certain angle, and the first grid is adaptively constructed based on the quadtree principle.
The mesh size may be 3 x 3, while all images need to be completely covered by the respective first mesh being constructed.
Sixth threshold value musThe smaller the grid is, the more grids are screened, the range of extracting the characteristic pixel points is increased, the more characteristic pixel points can improve the matching precision, and the calculation and memory resources can be wasted. Meanwhile, more pixels with insufficient information content are also included in the characteristic pixels, which can lead to unstable matching results. Sixth threshold value musThe larger the grid is, the fewer the grids are screened, the number of the characteristic pixel points is reduced, the time consumption of matching calculation is correspondingly reduced, but the characteristic pixel points used for matching are possibly insufficient, and the matching result is inaccurate. Thus set sixth threshold μsAt least three layers of quadtrees can be built for the pyramid top-level image to be segmented.
S102, determining the average gradient amplitude of all pixel points in the first grid, and selecting the first grid with the average gradient amplitude being larger than or equal to a preset first threshold value as a second grid.
Specifically, the first mesh with the average gradient amplitude being greater than or equal to the first threshold may preliminarily determine local feature points including edges and textures, and the second mesh is screened out through setting of the first threshold for subsequent determination of the local feature points. Step S102 specifically includes the following steps:
s1021, calculating the sum of the gradient amplitudes of all the pixel points in the first grid, and determining the average gradient amplitude according to the number of the pixel points in the first grid and the sum of the gradient amplitudes;
and S1022, if the average gradient amplitude is determined to be larger than or equal to the first threshold, acquiring the corresponding first grid as a second grid.
Specifically, the sum of the gradient amplitudes of all the pixel points in the first grid is calculated, the average gradient amplitude obtained by dividing the sum of the gradient amplitudes by the number of the pixel points in the grid is calculated, and the selected average gradient amplitude of the second grid is equal to or greater than the first threshold.
If the average gradient magnitude is smaller than the first threshold, it is highly likely to be a background or a portion of the image lacking texture and edges, from which a feature point having a sufficient amount of information cannot be extracted.
The embodiment of the invention uses the average gradient amplitude for screening, is equivalent to a global filter of the image, filters grids with smaller average gradient amplitude, is equivalent to not considering the area with less edges and texture or without edges and texture in the image, and reduces the range of extracting strong feature points from the image.
S103, determining first gradient amplitude and first gradient direction entropy of all pixel points in a second grid, determining a first local feature point according to the first gradient amplitude and the first gradient direction entropy, and establishing a first LBP histogram feature vector according to the first local feature point;
specifically, for each screened second grid, the characteristic information quantity of pixel points in the second grid is evaluated based on the gradient amplitude and the gradient direction entropy, local characteristic points belonging to edges and textures in the image are detected, and then an LBP histogram characteristic vector is suggested according to the local characteristic points. Step S103 specifically includes the following steps:
s1031, determining first gradient amplitude and first gradient direction entropy values of all pixel points in a second grid;
s1032, acquiring a preset second threshold and a preset third threshold, and selecting pixel points of which the first gradient amplitude is greater than or equal to the second threshold and the first gradient direction entropy is greater than or equal to the third threshold as first local feature points;
s1033, extracting a first LBP histogram feature vector by taking the first local feature point as a central pixel point.
Specifically, for each screened second mesh, a gradient magnitude and gradient direction entropy-based method is used to detect local feature points belonging to edges and textures in the image. The larger the gradient amplitude of one pixel point is, the richer the gradient information contained in the pixel point is; the larger the gradient direction entropy value of a certain region of an image is, the larger the gradient direction change of pixel points of the region is, the higher the possibility that image corners exist in the region is, and the corners usually mean that the target contour changes, which can provide more characteristic information for template matching.
And calculating the gradient direction entropy of the pixel points, wherein the pixel points are taken as the centers of n × n regions, and n can be set to be 3, namely calculating the gradient direction entropy of 9 pixel points.
And selecting pixel points with gradient amplitude and gradient direction entropy respectively larger than corresponding thresholds from each second grid as local feature points.
As a further optional implementation manner, the step of extracting the first LBP histogram feature vector by using the first local feature point as a central pixel point specifically includes:
and establishing a first local feature point LBP histogram feature vector by taking the first local feature point as a central pixel point and combining nine modes of uniform less than or equal to 2 in the LBP equivalent mode.
Specifically, nine patterns with uniform ≦ 2 in the LBP equivalent pattern were set as the stable rotation patterns, and 9 types were shared. And the rest of the patterns which do not belong to the stable rotation pattern are classified into another type, so that 10 types of binary patterns are used for extracting the histogram feature vector of the central pixel point in the region.
In a 3-by-3 region of the image, the gray value of the central pixel point is compared with 8 surrounding pixel points, if the gray value of the surrounding pixel points is larger than that of the central pixel point, the mark is 1, and if not, the mark is 0. Therefore, the number of the 8 pixels continuously marked as 1 has 9 categories of 0, 1, 2.. 8, which respectively correspond to nine modes of uniform ≦ 2 in the LBP equivalent mode as the stable rotation mode. The rest of the patterns which do not belong to the stable rotation mode are classified into another type, so that 10 types of binary patterns are used for extracting the histogram feature vector of each local feature point.
Similarly, the region of radius R has a size Rr*Rr,r=1,2,3,...,Rr2R +1, then each region of radius R has Rr*RrEach pixel, except the central pixel point, has R in totalr*RrAnd extracting the histogram feature vector of the central pixel point by the 1 pixel point through a 10-class binary pattern.
And detecting local feature points of all images in the template graph pyramid, wherein each local feature point is used as a central pixel point for extracting an LBP feature region, and a first LBP histogram feature vector of the central pixel point is extracted.
The larger the area radius at which the first LBP histogram feature vector is obtained, the more abundant the information contained, but the time required to extract the feature vector increases.
And detecting local feature points of all images in the template map pyramid, and extracting the feature vector of the improved LBP histogram by taking each local feature point as a regional center.
S104, obtaining a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotation angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector.
Specifically, the processing of the target image is similar to the processing of the template image, a target image pyramid is constructed firstly, then a second local feature point is determined, then a second LBP histogram feature vector is suggested, then similarity matching is performed, and the position and the rotation angle of the target to be positioned are determined according to the matching result. Step S104 specifically includes the following steps:
s1041, obtaining a target image, constructing a target image pyramid according to the target image, and constructing a third grid according to the target image pyramid;
s1042, determining the average gradient amplitude of all pixel points in the third grid, and selecting the third grid with the average gradient amplitude larger than or equal to a preset fourth threshold value as a fourth grid;
s1043, determining second gradient amplitudes and second gradient direction entropy values of all pixel points in a fourth grid, determining second local feature points according to the second gradient amplitudes and the second gradient direction entropy values, and establishing a second LBP histogram feature vector according to the second local feature points;
s1044, calculating similarity between the first LBP histogram feature vector of each layer of the template image pyramid and the second LBP histogram feature vector of the corresponding position in the target image pyramid, sequentially performing similarity matching from the top layer to the bottom layer, eliminating second local feature points of which the similarity is smaller than a preset fifth threshold value, and screening out the second local feature points of which the similarity is larger than or equal to the fifth threshold value from the bottom layer of the target image pyramid, so as to determine the position and the rotation angle of the target to be positioned.
It should be appreciated that the process of establishing the second LBP histogram feature vector is substantially similar to the process of establishing the first LBP histogram feature vector, and is not described herein again.
Specifically, after a target image to be positioned is obtained, a target image pyramid with the same pyramid layer number as that of a template image pyramid is constructed, a second LBP histogram feature vector of the target image pyramid is established, a candidate window is slid on the target image from the top layers of the target image pyramid and the template image pyramid, relative position information of all local feature points in the template image is recorded in the candidate window, feature vectors of the local feature points of the candidate window are continuously matched with feature vectors on a corresponding target image, and similarity is calculated through histogram feature vectors of all local feature points of the template image (namely, a first LBP histogram feature vector) and histogram feature vectors of feature points at corresponding positions of the target image (namely, a second LBP histogram feature vector).
And a plurality of results may be obtained in each layer, the result with the similarity lower than the set fifth threshold is discarded, and finally, the local feature point with high and stable similarity is detected after the similarity matching of the pyramid bottom layer is completed, so that the position and the rotation angle of the positioning target are obtained according to the local feature point.
The method steps of the embodiments of the present invention are described above. The embodiment of the invention provides a target positioning method based on template matching, which comprises the following steps of firstly, detecting characteristic points belonging to edges and textures in a target image and a template image based on gradient amplitude and gradient direction; secondly, screening out local feature points with stable rotation from the detected feature points by using an LBP improved algorithm and establishing an LBP histogram feature vector; and finally, screening layer by layer from the top layer to the bottom layer of the pyramid by adopting a search method for narrowing the range based on the detected stable local feature points, and determining the stable local feature points with the similarity higher than a preset threshold value so as to obtain the accurate target position and the accurate rotation angle. According to the embodiment of the invention, the target position and the target rotation angle can be accurately calculated under the conditions of fuzzy, shielding, noise, complex background and angle rotation of the target image.
Compared with the prior art, the method and the device have the advantages that on one hand, the LBP histogram feature vector is established according to the screened local feature points, calculation is not needed for each pixel point in the image, the requirement on system calculation force is reduced, on the other hand, the stable pixel points are determined according to the similarity matching of the LBP histogram feature vectors, the defect that the prior art is greatly influenced by rotation is overcome, and the accuracy of target positioning is improved.
Referring to fig. 2, an embodiment of the present invention provides a target positioning system based on template matching, including:
the grid construction module is used for acquiring a template image, constructing a template image pyramid according to the template image and constructing a first grid according to the template image pyramid;
the grid selection module is used for determining the average gradient amplitude of all pixel points in the first grid and selecting the first grid with the average gradient amplitude being greater than or equal to a preset first threshold value as a second grid;
the LBP histogram feature vector establishing module is used for determining first gradient amplitude and first gradient direction entropy values of all pixel points in the second grid, determining a first local feature point according to the first gradient amplitude and the first gradient direction entropy values, and establishing a first LBP histogram feature vector according to the first local feature point;
and the similarity matching module is used for acquiring a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotating angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector.
The contents in the above method embodiments are all applicable to the present system embodiment, the functions specifically implemented by the present system embodiment are the same as those in the above method embodiment, and the beneficial effects achieved by the present system embodiment are also the same as those achieved by the above method embodiment.
Referring to fig. 3, an embodiment of the present invention provides a target positioning apparatus based on template matching, including:
at least one processor;
at least one memory for storing at least one program;
when the at least one program is executed by the at least one processor, the at least one program causes the at least one processor to implement the above-mentioned target location method based on template matching.
The contents in the above method embodiments are all applicable to the present apparatus embodiment, the functions specifically implemented by the present apparatus embodiment are the same as those in the above method embodiments, and the advantageous effects achieved by the present apparatus embodiment are also the same as those achieved by the above method embodiments.
An embodiment of the present invention further provides a computer-readable storage medium, in which a program executable by a processor is stored, and the program executable by the processor is used for executing the above-mentioned target location method based on template matching.
The computer-readable storage medium of the embodiment of the invention can execute the target positioning method based on template matching provided by the embodiment of the method of the invention, can execute any combination of the implementation steps of the embodiment of the method, and has corresponding functions and beneficial effects of the method.
The embodiment of the invention also discloses a computer program product or a computer program, which comprises computer instructions, and the computer instructions are stored in a computer readable storage medium. The computer instructions may be read by a processor of a computer device from a computer-readable storage medium, and executed by the processor to cause the computer device to perform the method illustrated in fig. 1.
In alternative embodiments, the functions/acts noted in the block diagrams may occur out of the order noted in the operational illustrations. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality/acts involved. Furthermore, the embodiments presented and described in the flow charts of the present invention are provided by way of example in order to provide a more thorough understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and in which sub-operations described as part of larger operations are performed independently.
Furthermore, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the above-described functions and/or features may be integrated in a single physical device and/or software module, or one or more of the functions and/or features may be implemented in a separate physical device or software module. It will also be appreciated that a detailed discussion of the actual implementation of each module is not necessary for an understanding of the present invention. Rather, the actual implementation of the various functional modules in the apparatus disclosed herein will be understood within the ordinary skill of an engineer, given the nature, function, and internal relationship of the modules. Accordingly, those skilled in the art can, using ordinary skill, practice the invention as set forth in the claims without undue experimentation. It is also to be understood that the specific concepts disclosed are merely illustrative of and not intended to limit the scope of the invention, which is defined by the appended claims and their full scope of equivalents.
The above functions, if implemented in the form of software functional units and sold or used as a separate product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the above method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Further, the computer readable medium could even be paper or another suitable medium upon which the above described program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the foregoing description of the specification, reference to the description of "one embodiment/example," "another embodiment/example," or "certain embodiments/examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the present invention have been shown and described, it will be understood by those of ordinary skill in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A target positioning method based on template matching is characterized by comprising the following steps:
acquiring a template image, constructing a template image pyramid according to the template image, and constructing a first grid according to the template image pyramid;
determining the average gradient amplitude of all pixel points in the first grid, and selecting the first grid with the average gradient amplitude being greater than or equal to a preset first threshold value as a second grid;
determining first gradient amplitude and first gradient direction entropy of all pixel points in the second grid, determining a first local feature point according to the first gradient amplitude and the first gradient direction entropy, and establishing a first LBP histogram feature vector according to the first local feature point;
acquiring a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotation angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector.
2. The target positioning method based on template matching according to claim 1, wherein the step of obtaining a template image, constructing a template image pyramid according to the template image, and constructing a first grid according to the template image pyramid specifically comprises:
acquiring a template image, and expanding the width and the height of the template image to obtain an expanded template image;
downsampling the extended template image to generate a template image pyramid;
extracting a first pyramid image of each layer in the template image pyramid, and constructing a first grid in a self-adaptive manner through quadtree segmentation according to the first pyramid image;
wherein the first pyramid image is covered by a corresponding first grid.
3. The template matching-based target positioning method according to claim 2, wherein in the step of adaptively constructing the first mesh from the first pyramid image through quadtree partitioning, when the width or height of the first mesh is smaller than a preset sixth threshold, the quadtree partitioning is not performed, and the sixth threshold satisfies the following condition:
Figure FDA0002968750250000011
wherein, musDenotes a sixth threshold value, WTLWidth, H, of top level image representing template image pyramidTLRepresenting the height of the topmost image of the template image pyramid.
4. The template matching-based target positioning method according to claim 1, wherein the step of determining an average gradient magnitude of all pixel points in the first mesh, and selecting the first mesh having the average gradient magnitude greater than or equal to a preset first threshold as the second mesh specifically includes:
calculating the sum of the gradient amplitudes of all the pixel points in the first grid, and determining the average gradient amplitude according to the number of the pixel points in the first grid and the sum of the gradient amplitudes;
and if the average gradient amplitude is determined to be larger than or equal to the first threshold, acquiring the corresponding first grid as a second grid.
5. The template matching-based target positioning method according to claim 1, wherein the step of determining a first gradient magnitude and a first gradient direction entropy of all pixel points in the second mesh, determining a first local feature point according to the first gradient magnitude and the first gradient direction entropy, and establishing a first LBP histogram feature vector according to the first local feature point specifically comprises:
determining first gradient amplitude and first gradient direction entropy values of all pixel points in the second grid;
acquiring a preset second threshold and a preset third threshold, and selecting pixel points of which the first gradient amplitude is greater than or equal to the second threshold and the first gradient direction entropy is greater than or equal to the third threshold as first local feature points;
and extracting a first LBP histogram feature vector by taking the first local feature point as a central pixel point.
6. The target positioning method based on template matching according to claim 5, wherein the step of extracting the first LBP histogram feature vector by using the first local feature point as a central pixel point specifically comprises:
and establishing a first local feature point LBP histogram feature vector by taking the first local feature point as a central pixel point and combining nine modes of which the uniform is less than or equal to 2 in the LBP equivalent mode.
7. The template matching-based target positioning method according to claim 1, wherein the step of obtaining a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotation angle of the target to be positioned according to the similarity matching between the first LBP histogram feature vector and the second LBP histogram feature vector specifically comprises:
acquiring a target image, constructing a target image pyramid according to the target image, and constructing a third grid according to the target image pyramid;
determining the average gradient amplitude of all pixel points in the third grid, and selecting the third grid with the average gradient amplitude being greater than or equal to a preset fourth threshold value as a fourth grid;
determining second gradient magnitude and second gradient direction entropy of all pixel points in the fourth grid, determining second local feature points according to the second gradient magnitude and the second gradient direction entropy, and establishing second LBP histogram feature vectors according to the second local feature points;
and calculating the similarity of the first LBP histogram feature vector of each layer in the template image pyramid and the target image pyramid and the second LBP histogram feature vector of the corresponding position, sequentially performing similarity matching from the top layer to the bottom layer, eliminating second local feature points of which the similarity is smaller than a preset fifth threshold value, and screening out second local feature points of which the similarity is larger than or equal to the fifth threshold value from the bottom layer of the target image pyramid, thereby determining the position and the rotation angle of the target to be positioned.
8. An object positioning system based on template matching, comprising:
the grid construction module is used for acquiring a template image, constructing a template image pyramid according to the template image and constructing a first grid according to the template image pyramid;
the grid selection module is used for determining the average gradient amplitude of all pixel points in the first grid and selecting the first grid with the average gradient amplitude being greater than or equal to a preset first threshold value as a second grid;
an LBP histogram feature vector establishing module, configured to determine first gradient magnitudes and first gradient direction entropy values of all pixel points in the second grid, determine a first local feature point according to the first gradient magnitudes and the first gradient direction entropy values, and establish a first LBP histogram feature vector according to the first local feature point;
and the similarity matching module is used for acquiring a target image, constructing a target image pyramid according to the target image, determining a second local feature point of the target image pyramid, further establishing a second LBP histogram feature vector according to the second local feature point, and determining the position and the rotation angle of the target to be positioned according to the similarity matching of the first LBP histogram feature vector and the second LBP histogram feature vector.
9. An object positioning device based on template matching, comprising:
at least one processor;
at least one memory for storing at least one program;
when executed by the at least one processor, cause the at least one processor to implement a method of target location based on template matching as claimed in any one of claims 1 to 7.
10. A computer readable storage medium, in which a processor executable program is stored, wherein the processor executable program, when executed by a processor, is adapted to perform a method of template matching based object localization according to any of claims 1 to 7.
CN202110257976.7A 2021-03-10 2021-03-10 Target positioning method, system, device and medium based on template matching Active CN113128554B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110257976.7A CN113128554B (en) 2021-03-10 2021-03-10 Target positioning method, system, device and medium based on template matching

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110257976.7A CN113128554B (en) 2021-03-10 2021-03-10 Target positioning method, system, device and medium based on template matching

Publications (2)

Publication Number Publication Date
CN113128554A true CN113128554A (en) 2021-07-16
CN113128554B CN113128554B (en) 2022-05-24

Family

ID=76772903

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110257976.7A Active CN113128554B (en) 2021-03-10 2021-03-10 Target positioning method, system, device and medium based on template matching

Country Status (1)

Country Link
CN (1) CN113128554B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113658253A (en) * 2021-07-27 2021-11-16 广东省大湾区集成电路与系统应用研究院 Template matching positioning method and device, image acquisition equipment and storage medium
CN114398978A (en) * 2022-01-13 2022-04-26 深圳市腾盛精密装备股份有限公司 Template matching method and device, storage medium and electronic equipment
WO2024066050A1 (en) * 2022-09-27 2024-04-04 深圳先进技术研究院 Facial recognition method and apparatus based on visual template and pyramid strategy

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101510257A (en) * 2009-03-31 2009-08-19 华为技术有限公司 Human face similarity degree matching method and device
CN102136062A (en) * 2011-03-08 2011-07-27 西安交通大学 Human face retrieval method based on multi-resolution LBP (local binary pattern)
US20150363636A1 (en) * 2014-06-12 2015-12-17 Canon Kabushiki Kaisha Image recognition system, image recognition apparatus, image recognition method, and computer program
CN105917353A (en) * 2013-09-16 2016-08-31 眼验股份有限公司 Feature extraction and matching and template update for biometric authentication
CN107671896A (en) * 2017-05-19 2018-02-09 重庆誉鸣科技有限公司 Fast vision localization method and system based on SCARA robots
CN110084269A (en) * 2019-03-20 2019-08-02 合肥名德光电科技股份有限公司 Characteristics of image optimization method based on cloud computing
US20200125823A1 (en) * 2016-12-02 2020-04-23 GEOSAT Aerospace & Technology Methods and systems for automatic object detection from aerial imagery
CN111080683A (en) * 2019-12-09 2020-04-28 Oppo广东移动通信有限公司 Image processing method, image processing device, storage medium and electronic equipment
CN111553425A (en) * 2020-04-29 2020-08-18 广州大学 Template matching LSP algorithm, medium and equipment for visual positioning

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101510257A (en) * 2009-03-31 2009-08-19 华为技术有限公司 Human face similarity degree matching method and device
CN102136062A (en) * 2011-03-08 2011-07-27 西安交通大学 Human face retrieval method based on multi-resolution LBP (local binary pattern)
CN105917353A (en) * 2013-09-16 2016-08-31 眼验股份有限公司 Feature extraction and matching and template update for biometric authentication
US20150363636A1 (en) * 2014-06-12 2015-12-17 Canon Kabushiki Kaisha Image recognition system, image recognition apparatus, image recognition method, and computer program
US20200125823A1 (en) * 2016-12-02 2020-04-23 GEOSAT Aerospace & Technology Methods and systems for automatic object detection from aerial imagery
CN107671896A (en) * 2017-05-19 2018-02-09 重庆誉鸣科技有限公司 Fast vision localization method and system based on SCARA robots
CN110084269A (en) * 2019-03-20 2019-08-02 合肥名德光电科技股份有限公司 Characteristics of image optimization method based on cloud computing
CN111080683A (en) * 2019-12-09 2020-04-28 Oppo广东移动通信有限公司 Image processing method, image processing device, storage medium and electronic equipment
CN111553425A (en) * 2020-04-29 2020-08-18 广州大学 Template matching LSP algorithm, medium and equipment for visual positioning

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
彭绍湖 等: "一种基于线连通的人脸定位法", 《广东工业大学学报》 *
王亮: "高速特征检测算法在工业检测中的应用", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
赵蒙娜: "基于多特征分类的目标检测算法研究", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113658253A (en) * 2021-07-27 2021-11-16 广东省大湾区集成电路与系统应用研究院 Template matching positioning method and device, image acquisition equipment and storage medium
CN114398978A (en) * 2022-01-13 2022-04-26 深圳市腾盛精密装备股份有限公司 Template matching method and device, storage medium and electronic equipment
WO2024066050A1 (en) * 2022-09-27 2024-04-04 深圳先进技术研究院 Facial recognition method and apparatus based on visual template and pyramid strategy

Also Published As

Publication number Publication date
CN113128554B (en) 2022-05-24

Similar Documents

Publication Publication Date Title
CN113128554B (en) Target positioning method, system, device and medium based on template matching
WO2018107939A1 (en) Edge completeness-based optimal identification method for image segmentation
CN108764358B (en) Terahertz image identification method, device and equipment and readable storage medium
CN105184763B (en) Image processing method and device
CN110309687A (en) A kind of bearing calibration of image in 2 D code and means for correcting
CN113610774B (en) Glass scratch defect detection method, system, device and storage medium
CN113205145B (en) Template matching method, system, device and medium based on normalized cross correlation
CN111027546A (en) Character segmentation method and device and computer readable storage medium
US20170178341A1 (en) Single Parameter Segmentation of Images
CN113610773B (en) Gasket hole quality detection method, system, device and storage medium
CN111223083A (en) Method, system, device and medium for constructing surface scratch detection neural network
CN111383216B (en) Method and device for detecting change between images
CN115457017A (en) Wire defect detection method and device, computer equipment and storage medium
CN110309808B (en) Self-adaptive smoke root node detection method in large-scale space
CN114862861A (en) Lung lobe segmentation method and device based on few-sample learning
CN113610772B (en) Method, system, device and storage medium for detecting spraying code defect at bottom of pop can bottle
CN111368865A (en) Method and device for detecting remote sensing image oil storage tank, readable storage medium and equipment
CN112734747A (en) Target detection method and device, electronic equipment and storage medium
CN110516731B (en) Visual odometer feature point detection method and system based on deep learning
CN110211106B (en) Mean shift SAR image coastline detection method based on segmented Sigmoid bandwidth
CN115760695A (en) Image anomaly identification method based on depth vision model
CN111914766B (en) Method for detecting business trip behavior of city management service
CN108492328A (en) Video interframe target matching method, device and realization device
Kleinschmidt et al. Nonlocal texture filtering with efficient tree structures and invariant patch similarity measures
Bai et al. Efficient structure-preserving superpixel segmentation based on minimum spanning tree

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
GR01 Patent grant
GR01 Patent grant