Visual positioning method and device based on local variance and posterior probability classifier
By using local variance and posterior probability classifiers in the template matching method, combining multiple rotations and multi-scale scaling techniques, the error matching problem of existing template matching methods when dealing with scaling, rotation or noise interference is achieved. Fast and accurate visual positioning.
Patent Information
- Application Number
- CN202210435034.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-24
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2042-04-24
AI Technical Summary
Existing template matching methods are prone to incorrect matching results when processing target image scaling, rotation or noise interference, and are computationally large and inefficient.
A fast visual positioning method based on local variance and posterior probability classifier is adopted. By detecting the difference in grayscale values of feature points and random points in the template image, binary numbers are generated and converted into decimal numbers as template features. This method performs multiple rotations and multi-scale scaling on the template image to achieve rotation invariance and improve matching efficiency.
The rapid and accurate positioning of the target image is achieved, the calculation amount is reduced, the matching efficiency is improved, and the problems of excessive calculation amount and low efficiency in the prior art are overcome.
Smart Images

Figure CN114708420B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and in particular, relates to a visual positioning method and device based on local variance and posterior probability classifier. Background Art
[0002] Template matching is a classic method used in the field of computer vision and image processing for target detection and location. It selects a template image, calculates the similarity between the template image and the sliding window in the target image, and the result that reaches the standard of similarity with the template image is the matching result, thereby determining the position of the target corresponding to the template image in the target image.
[0003] Without considering the influence of image rotation, scaling, lighting and other factors, the pixel value of each point in the target area to be matched in the target image should be equal to the pixel value of the corresponding point in the template image. Therefore, in the past, traditional template matching algorithms all used grayscale value-based methods for matching. These methods all calculated the sum of the absolute values of the difference between the pixel values of the sliding window of the target image and the corresponding points of the template image, or the sum of the squares of the pixel value differences. Although this method is simple, when the target image is scaled, rotated or interfered by noise, wrong matching results will occur.
[0004] Among the subsequent improvements to the grayscale-based matching method, the most representative one is the normalized cross-correlation template matching method. This method modifies the original discriminant function based on the concept of grayscale change, but greatly increases the amount of calculation, which leads to a decrease in the speed of template matching. In addition, after considering the interference of multiple scales and multiple angles, although the existing template matching method can obtain results by using sliding windows of different angles and scales, the matching speed is too slow, the amount of calculation is very large, and the efficiency is too low. Summary of the invention
[0005] One purpose of an embodiment of the present invention is to provide a fast visual positioning method based on local variance and posterior probability classifier, which establishes a set of feature points and a set of random points in a certain interval within a template image, and compares the grayscale values of the two sets of points, and then converts the comparison result into a binary number and then converts it into a decimal number, so as to use this decimal number as the feature of the template. In the extraction process, not only the above feature extraction will be performed on the template image, but the method will perform multiple rotation operations on the surrounding area of the template image before extraction. Thereby achieving the rotation invariance of the matching.
[0006] The main idea of the present invention relies on local variance and posterior probability classifier to quickly locate the target, wherein the local variance is realized by the variance classifier, and the posterior probability classifier calculates the posterior probability by the posterior probability classifier to obtain the result, and the subsequent description also uses the posterior probability classifier for explanation.
[0007] Another object of an embodiment of the present invention is to provide a fast visual positioning system based on local variance and posterior probability classifier.
[0008] In order to achieve the above technical objectives, the technical solutions adopted by the embodiments of the present invention include:
[0009] In a first aspect, an embodiment of the present invention provides a fast visual positioning method based on local variance and posterior probability classifier, comprising the following steps:
[0010] The window of the area around the template image is obtained according to the moving step of the sliding window. The obtained template image area window is the positive sample of the posterior probability classifier; the feature points are detected in the maximum inscribed circle area of the template image, which is used as the first group of point pairs of the posterior probability classifier, and random points are used as the second group of point pairs;
[0011] The positive sample window in the above template image area is rotated with the center point of the template image at a certain angle step, and each positive sample obtains hundreds of rotated positive samples, and then uses the posterior probability classifier to extract features;
[0012] In case of multi-scale target images, a sliding window with a moving step length of one-tenth of the shortest side of the window is established based on the template image scale. The multi-scale sliding window is classified according to the scale. In the feature extraction process of the posterior probability classifier, the template image is scaled to multiple scales and then the posterior probability classifier of the corresponding scale is used to extract features of the corresponding scale;
[0013] In target image detection, a sliding window with a large moving step size is first traversed at the initial scale. If the first detection can obtain a result, a second sliding window with a small step size is traversed on the area surrounding the result. Otherwise, a multi-scale sliding window with a large moving step size is used for traversal. After clustering the windows of each scale passing through the classifier, the window with the largest number of clusters is used as the representative window of the current scale. The number of clusters of the representative windows of each scale is counted, and the window with the largest number of clusters is used as the final output result.
[0014] Further, in one embodiment of the present invention, the step of establishing sliding windows of different moving steps and different scales according to the size of the template image specifically includes:
[0015] Get the template image and the target image;
[0016] For the retrieval process, a sliding window with an initial scale and a moving step length of one-tenth of the shortest side of the template image is first generated according to the size of the image where the template is located and the scale of the template image.
[0017] For the definition process, a sliding window of initial scale is generated and moved pixel by pixel according to the size of the image where the template is located.
[0018] In view of the multi-scale situation in the retrieval process, a multi-scale sliding window is generated based on the template size, which is enlarged and reduced ten times. The moving step of the sliding window is one tenth of the shortest side of the scaled template.
[0019] Further, in one embodiment of the present invention, in the preparation of the posterior probability classifier, the step of using a set of feature points and a set of random points for comparison specifically includes:
[0020] In the preparation of the posterior probability classifier in the definition part, feature points and random points are retrieved in a region with the center point of the template image as the circle center and the shortest side of the template image as the diameter;
[0021] First, SIFT feature points are retrieved within the template image range. During the retrieval process, two thresholds in the SIFT algorithm are lowered in order to make the number of feature points meet the standard used by the classifier, and the descriptor establishment process of the feature points is not performed;
[0022] Harris corner feature points are retrieved within the template image range. Quantitative feature point output is used during the retrieval process to ensure that the number of feature points meets the standard used by the classifier.
[0023] Quantitatively generate random points within the template image interval;
[0024] In the preparation of the posterior probability classifier, two sets of quantitative point pairs are generated. The first set of feature points is composed of the results of the SIFT feature point retrieval algorithm. If the number of SIFT feature points is insufficient, Harris corner points are used to fill in.
[0025] The reason for retrieving feature points and random points in the template image with the center of the template as the center and the maximum inscribed circle as the range is to avoid the situation where the coordinate points are out of bounds when the samples in the posterior probability classifier are rotated;
[0026] Further, in one embodiment of the present invention, the step of constructing positive samples of the template image and the area surrounding the template image according to the sliding window moving step size specifically includes:
[0027] In the definition part, the image where the template is located is divided into positive and negative samples according to the overlap between the sliding window and the template;
[0028] The samples with an overlap of more than 0.82 with the template image in the sliding window are positive samples;
[0029] The samples with an overlap of less than 0.6 with the template image in the sliding window are negative samples;
[0030] The overlap threshold setting for dividing positive and negative samples is calculated based on the sliding window moving step size during retrieval;
[0031] Further, in one embodiment of the present invention, the step of training the posterior probability classifier according to the positive and negative samples and the rotated positive samples thereof specifically includes:
[0032] All the generated positive samples are rotated multiple times with a certain angle as the step length, and the features of the posterior probability classifier are extracted after each rotation;
[0033] The generated negative samples are not processed and the features of the posterior probability classifier are directly extracted;
[0034] The template image is scaled to multiple scales, and features are extracted using the posterior probability classifier of the corresponding scale;
[0035] Further, in one embodiment of the present invention, the step of determining whether to perform multi-scale sliding window traversal retrieval according to the detection result of the sliding window with a large moving step length at the initial scale during the retrieval process specifically includes:
[0036] During the retrieval process of the target image, the sliding window with the initial scale and large moving step size generated during the definition process is used for traversal;
[0037] Calculate the variance of the traversed sliding window, and those that meet the conditions pass the variance classifier;
[0038] Use the posterior probability classifier to extract features from the sliding window of the variance classifier and query the posterior probability corresponding to the features;
[0039] The posterior probability that passes the threshold of the posterior probability classifier is the window that passes the posterior probability classifier;
[0040] Perform clustering operations on all sliding windows that pass through the variance classifier and the posterior probability classifier. After clustering, count the number of clusters in each clustering box, and take the window with the most window clusters as the output result of the current step;
[0041] Further, in one embodiment of the present invention, the step of determining whether to perform a second initial scale small step size precise search based on the result of the first initial scale large moving step size search specifically includes:
[0042] When the first search has a result output, the first result and the surrounding area of the result window are intercepted on the target image. The intercepted range is determined by the moving step length of the first sliding window, and the interval extending up, down, left, and right of the first search output result is intercepted.
[0043] Generate sliding windows of initial scale that move one by one within the intercepted image interval;
[0044] Use the newly generated sliding window to traverse the captured image interval;
[0045] Perform feature extraction of the posterior probability classifier on all traversed sliding windows and calculate the posterior probability corresponding to the features;
[0046] The average value of the window passing through the posterior probability classifier is calculated, and the relative coordinates in the intercepted image interval are converted into absolute coordinates based on the target image;
[0047] Further, in one embodiment of the present invention, the step of determining whether to perform a multi-scale large moving step sliding window search based on the result of the first initial scale large moving step search specifically includes:
[0048] When there is no result output in the first retrieval, it is determined that there is no matching target of the initial scale in the target image, and a multi-scale sliding window is used for traversal;
[0049] During the sliding window traversal process of each scale, the variance of each window is calculated, and the windows whose window variance does not meet the standard of the variance classifier are screened out. The features of the posterior probability classifier and the posterior probability calculation are performed on the windows that pass the variance classifier.
[0050] For the results of the sliding window of each scale passing through the two classifiers, the windows of each scale passing through the two classifiers are clustered separately. The window with the largest number of clusters is used as the representative output window of the corresponding scale. The number of clusters of the representative output windows of all scales is counted separately, and the window with the largest number of clusters is selected as the result of multi-scale detection.
[0051] In a second aspect, an embodiment of the present invention proposes a fast visual positioning system based on local variance and posterior probability classifier, including:
[0052] A sliding window generation module generates an initial scale sliding window with a small step size used during definition, an initial scale sliding window with a large step size used during retrieval, and a multi-scale sliding window with a large step size;
[0053] The posterior probability classifier preparation module retrieves feature points and generates random points within the template image interval, and stores the coordinate points as relative coordinates of the initial scale and relative coordinates of multiple scales respectively;
[0054] The positive and negative sample division module uses the defined sliding window generated by the sliding window generation module to divide positive samples and negative samples according to the overlap between the sliding window and the template image;
[0055] The posterior probability classifier training module rotates all positive samples divided by the positive and negative sample division module multiple times with a certain angle step length. Each rotation of each sample extracts and trains the features of the posterior probability classifier. The template image is scaled at multiple scales and then the features of the posterior probability classifier are extracted and trained. Half of the sliding window of the negative sample is used as the training set, and the posterior probability classifier is used for feature extraction and training. Finally, the other half of the sliding window of the negative sample is used as the test set, and the trained posterior probability classifier is used for verification to update the threshold of the posterior probability classifier.
[0056] Initial scale rough detection module, uses the retrieval in the sliding window generation module to traverse the target image with the initial scale large moving step sliding window, calculates the variance of the sliding window, and only the sliding window whose variance meets the variance classifier standard can perform feature extraction for the posterior probability classifier, calculates the posterior probability of the extracted features, and performs window clustering on the sliding windows whose posterior probabilities are greater than the threshold of the posterior probability classifier. After clustering, the number of clusters in each clustering window is counted, and the clustering window with the largest number of clusters is selected as the output result of this module;
[0057] The initial scale fine detection module, on the premise that the initial scale coarse detection module obtains the result, intercepts the result of the initial scale coarse detection module and the surrounding area of the result in the target image, generates a sliding window that slides pixel by pixel in the intercepted target image area, uses the posterior probability classifier to extract the features of the sliding window and calculate the posterior probability, and performs window clustering on the sliding window that passes the posterior probability classifier. After clustering, the result is converted from the relative coordinates of the intercepted image to the absolute coordinates based on the target image, which is the output result of this module;
[0058] The multi-scale coarse detection module, under the premise that the initial scale coarse detection module does not obtain results, uses the sliding window of each scale to traverse the target image separately, calculates the variance of the traversed window, extracts features of the posterior probability classifier and calculates the posterior probability for the window that passes the variance classifier, clusters the sliding windows of each scale whose posterior probability meets the standard, selects the window with the largest number of clusters after clustering the corresponding scale at each scale as the representative window of the current scale, and finally counts the number of clusters of the representative windows of each scale, and selects the window with the largest number of clusters as the output result of the multi-scale coarse detection module.
[0059] In a third aspect, an embodiment of the present invention provides a fast visual positioning device based on local variance and posterior probability classifier, comprising:
[0060] at least one processor;
[0061] at least one memory for storing at least one program;
[0062] When the at least one program is executed by the at least one processor, the at least one processor implements the above-mentioned fast visual positioning method based on local variance and posterior probability classifier.
[0063] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores a program executable by a processor, and the program executable by the processor is used to execute the above-mentioned fast visual positioning method based on local variance and posterior probability classifier when executed by the processor.
[0064] The advantages and beneficial effects of the present invention will be partly given in the following description, partly become apparent from the following description, or be understood through the practice of the present invention:
[0065] The present invention uses two sliding windows with different moving steps in the definition process and the retrieval process, that is, to reduce the amount of calculation in the retrieval process, and also to avoid the sliding window in the retrieval process from making an incorrect judgment on the window due to the excessive moving step when passing through the posterior probability classifier. Compared with the prior art, the present invention example takes into account the sample rotation in the definition part, and does not need to perform rotation matching for each sliding window in the detection process, which reduces the requirements for the system calculation and improves the matching efficiency. On the other hand, the definition part also takes into account the multi-scale situation to generate the multi-scale sliding window, and because the multi-scale sliding window in the retrieval part is performed after the initial scale sliding window is traversed, it avoids wasting too much calculation when the target object has no scale scaling. Compared with the accuracy of template matching, the more sliding windows are used, the more accurate the results may be, but the retrieval time will also be greatly increased, so a second high-precision retrieval is used on the premise that the first retrieval has results. This method further improves the matching efficiency, and at the same time overcomes the shortcomings of excessive calculation and invalid calculation in the matching process of the prior art, and improves the accuracy of template matching. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0067] Figure 1 A flowchart of the definition steps of a fast visual localization method based on local variance and posterior probability classifier provided in this application.
[0068] Figure 2This is a flowchart of the retrieval steps of a fast visual localization method based on local variance and posterior probability classifier in an embodiment of the present application.
[0069] Figure 3 This is a structural block diagram of a fast visual positioning system based on local variance and posterior probability classifier in an embodiment of the present application.
[0070] Figure 4 This is a structural block diagram of a fast visual positioning device based on local variance and posterior probability classifier in an embodiment of the present application. DETAILED DESCRIPTION
[0071] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0072] Reference Figure 1 , Figure 2 The embodiment of the present invention provides a fast visual positioning method based on local variance and posterior probability classifier, and the definition part thereof specifically includes the following steps:
[0073] S101. According to the template image and the size of the image where the template is located, a sliding window with an initial scale for definition and a pixel-by-pixel translation, a sliding window with an initial scale for retrieval and a sliding window with a certain moving step size for retrieval and a multi-scale sliding window with a certain moving step size are constructed.
[0074] Specifically, in the subsequent matching process, the initial scale sliding window with a large moving step is first used for traversal retrieval, and then it is determined whether to perform the initial scale sliding window traversal retrieval with a small moving step and the multi-scale sliding window traversal retrieval according to the result of the first detection. Step S101 includes the following steps:
[0075] S1011, obtaining the image where the template is located and the template image position;
[0076] S1012, using a sliding window of the template image scale to translate the image where the template is located pixel by pixel, and storing the generated sliding window for generating samples;
[0077] S1013, traversing the image where the template is located using a sliding window of the template image scale with the shortest side length of the template image as a step length, and storing the generated sliding window for use in the retrieval part;
[0078] S1014, scaling the template image scale multiple times according to the template image scale, using a sliding window of the scaled template image scale to traverse with a step length of the shortest side of the scaled scale, and storing the generated sliding window for the retrieval part.
[0079] S102, performing low-standard SIFT feature point retrieval and Harris corner point retrieval within a circle with the center of the template image as the center and the shortest side of the template image as the diameter as the first pair of feature points for the posterior probability classifier, and generating random points in the same range as the second pair of random points.
[0080] Specifically, in the subsequent training and testing of the posterior probability classifier, two fixed sets of coordinate point pairs are required to obtain the grayscale size of the coordinate points, one of which is composed of feature points, representing the key information of the template image, and the other is composed of random points, representing the random information of the template image. Step S102 specifically includes the following steps:
[0081] S1021, using the SIFT feature point detection algorithm to obtain the coordinates of the feature points on the template image, the detected feature points do not construct feature point descriptors, and the output feature points are sorted according to the pyramid level where the feature points are located, and the feature points at the front after sorting represent the top of the Gaussian difference pyramid, that is, the coarser features;
[0082] S1022, using the Harris corner detection algorithm to obtain the coordinates of the corner points on the template image, and quantitatively outputting the output feature points during the detection process. The feature points output by the Harris corner detection algorithm are sorted from large to small according to the formula result, and the sorted feature points are outputted with the corner points being outputted first and then the edge points;
[0083] S1023, generating coordinate points at any time within the maximum inscribed circle interval of the template image;
[0084] In the embodiment of the present invention, the number of coordinate point pairs required for training, testing and detection of the posterior probability classifier is 130 pairs, that is, 130 feature points and 130 random points need to be prepared in the posterior probability classifier preparation module, and in order to cope with the subsequent positive sample rotation sampling step, the generation of coordinate points is only performed on the maximum inscribed circle of the template image. The 130 feature points are preferentially used with the results of the SIFT feature point detection algorithm, and if the number of feature points is insufficient, the results of the Harris corner point detection algorithm are used to fill in.
[0085] S103, calculate the variance of the template image, and set the threshold of the variance classifier to a certain proportion of the variance of the template image. Step S103 is as follows:
[0086] S1031, calculating the integral image and the square integral image of the image where the template is located;
[0087] S1032, calculating the variance of the template image through the integral image and the square integral image;
[0088] S1033, multiplying the variance of the template image by a certain ratio as a threshold of the variance classifier;
[0089] In the embodiment of the present invention, the variance classifier plays a role in filtering and screening the sliding window during the detection process, and is used in both the initial scale and multi-scale sliding window traversals.
[0090] S104, calculating the overlap between the defined sliding window and the template image, and dividing the positive and negative samples according to the overlap, performing multiple rotations of a certain angle step length on all positive samples and then sampling using a posterior probability classifier, and also performing sampling on the template image after scaling multiple times, the specific steps are as follows:
[0091] S1041, respectively calculating the overlap between the generated sliding window defined for pixel-by-pixel translation and the window where the template image is located;
[0092] S1042, the overlap is greater than 0.82 for positive sample sliding windows;
[0093] S1043, overlap less than 0.6 is a negative sample sliding window;
[0094] In the embodiment of the present invention, the degree of overlap of the sliding windows for dividing positive and negative samples is a result obtained through scientific calculations and is determined based on the moving step of the sliding window used during retrieval, ensuring that the area covered by the positive sample can include a sliding window with a large moving step starting from any starting point.
[0095] S1044, after rotating all the divided positive sample sliding windows for multiple times with a certain angle step length, feature sampling of the posterior probability classifier is performed for each rotation;
[0096] S1045, after scaling the template image at multiple scales, a posterior probability classifier of a corresponding scale is used to extract features after each scaling;
[0097] In the embodiment of the present invention, for the multi-angle sampling processing of the positive samples, all positive samples are rotated 120 times with a rotation step of 3° around the center of the positive sample as the rotation center, and features are extracted after each rotation.
[0098] S105, half of the negative sample traversal window is used as a training set without processing and trained using the posterior probability classifier, and the other half is used as a test set and the posterior probability is calculated using the trained posterior probability classifier and then the threshold of the classifier is corrected. This step is as follows:
[0099] S1051, using the half of the negative sample sliding window divided as the training set, without processing, and using the posterior probability classifier to extract features;
[0100] S1052. Use the other half of the negative sample sliding window as a test set, and use the trained random forest classifier to calculate the posterior probability to correct the posterior probability threshold of the posterior probability classifier.
[0101] Based on the same inventive concept, the present application embodiment also provides a kind of visual positioning device based on local variance and posterior probability classifier, which can be used to implement the method described in the above-mentioned embodiment, as described in the following embodiment. Since the principle of solving the problem by the visual positioning device based on local variance and posterior probability classifier is similar to the visual positioning method based on local variance and posterior probability classifier, the implementation of the visual positioning device based on local variance and posterior probability classifier can refer to the implementation of the visual positioning method based on local variance and posterior probability classifier, and the repetition will not be repeated. As used below, the term "unit" or "module" can realize the combination of software and / or hardware of the predetermined function. Although the system described in the following embodiment is preferably implemented with software, the implementation of hardware, or the combination of software and hardware is also possible and conceived.
[0102] like Figure 3 As shown, an embodiment of the present invention provides a fast visual positioning system based on local variance and posterior probability classifier, including:
[0103] A sliding window generation module is used to construct an initial scale sliding window that is shifted pixel by pixel for definition, an initial scale sliding window that is shifted by a certain number of pixels for retrieval, and a multi-scale sliding window that is shifted by a certain number of pixels for retrieval according to the size of the image where the template is located and the size of the template image;
[0104] The positive and negative sample division module is used to calculate the overlap between the defined sliding window and the template image, and divide the positive and negative samples according to the overlap. The overlap threshold of the division is calculated based on the moving step length of the sliding window used for retrieval.
[0105] The posterior probability classifier preparation module is used to generate feature point pairs and random point pairs for feature extraction of subsequent random forest classifiers;
[0106] The posterior probability classifier training module is used to rotate all positive samples multiple times with a certain angle step length, use the posterior probability classifier to extract features from the rotated positive sample images, and use the posterior probability classifier of the corresponding scale to extract features after scaling the template image at multiple scales. All negative samples are divided into training sets and test sets without processing, and the posterior probability classifier is used to extract features from the negative samples of the training set, and the posterior probability threshold of the posterior probability classifier is corrected after the posterior probability classifier is trained for the negative samples of the test set.
[0107] The initial scale rough retrieval module is used for the rough retrieval of the target image without scaling for the first time in the detection part. The module uses the initial scale sliding window with a large moving step length constructed by the sliding window generation module to traverse the traversed sliding window, classifies the traversed sliding window with the variance classifier and the posterior probability classifier, and performs window clustering on the classification results.
[0108] The initial scale precise retrieval module is used to intercept the image of the surrounding area of the result of the first retrieval, and perform a sliding window traversal pixel by pixel on the intercepted image, and perform clustering after classifying the traversed sliding window by the posterior probability classifier, so as to obtain the corrected coordinates of the target based on the target image.
[0109] The multi-scale coarse retrieval module is used to determine whether the target has been scaled when the initial scale coarse retrieval module has no output results. It uses sliding windows of different scales to traverse the sliding windows, classifies the traversed sliding windows by variance classifier and posterior probability classifier, and clusters them according to their scales. At each scale, the cluster window with the largest number of clusters is selected as the representative window of the scale. The number of clusters of the representative window of each scale is counted, and the window with the largest number of clusters is selected as the output result of the multi-scale coarse retrieval module.
[0110] The content in the above method embodiment is only applicable to the present system embodiment. The functions specifically implemented by the present system embodiment are in the above functional embodiment system, and the beneficial effects achieved are the same as those achieved by the above method embodiment.
[0111] like Figure 4 As shown, an embodiment of the present invention provides a fast visual positioning device based on local variance and posterior probability classifier, including:
[0112] at least one processor;
[0113] at least one memory for storing at least one program;
[0114] When the at least one program is executed by the at least one processor, the at least one processor implements the fast visual positioning method based on local variance and posterior probability classifier.
[0115] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0116] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0117] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0118] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0119] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0120] The embodiments of the present application also provide a specific implementation of an electronic device capable of implementing all steps of the method in the above embodiments, and the electronic device specifically includes the following contents:
[0121] Processor, memory, communications interface and bus;
[0122] Wherein, the processor, memory, and communication interface communicate with each other via the bus;
[0123] The processor is used to call the computer program in the memory. When the processor executes the computer program, all the steps in the method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0124] S101. According to the template image and the size of the image where the template is located, a sliding window with an initial scale for definition and a pixel-by-pixel translation, a sliding window with an initial scale for retrieval and a sliding window with a certain moving step size for retrieval and a multi-scale sliding window with a certain moving step size are constructed.
[0125] S102, performing low-standard SIFT feature point retrieval and Harris corner point retrieval within a circle with the center of the template image as the center and the shortest side of the template image as the diameter as the first pair of feature points for the posterior probability classifier, and generating random points in the same range as the second pair of random points.
[0126] S103, calculate the variance of the template image, and set the threshold of the variance classifier to a certain proportion of the variance of the template image. Step S103 is as follows:
[0127] S104, calculating the overlap between the defined sliding window and the template image, and dividing the positive and negative samples according to the overlap, performing multiple rotations of all positive samples with a certain angle step length and then sampling using a posterior probability classifier, and also performing sampling after scaling the template image multiple times.
[0128] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the method in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps of the method in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0129] S101. According to the template image and the size of the image where the template is located, a sliding window with an initial scale for definition and a pixel-by-pixel translation, a sliding window with an initial scale for retrieval and a sliding window with a certain moving step size for retrieval and a multi-scale sliding window with a certain moving step size are constructed.
[0130] S102, performing low-standard SIFT feature point retrieval and Harris corner point retrieval within a circle with the center of the template image as the center and the shortest side of the template image as the diameter as the first pair of feature points for the posterior probability classifier, and generating random points in the same range as the second pair of random points.
[0131] S103, calculate the variance of the template image, and set the threshold of the variance classifier to a certain proportion of the variance of the template image. Step S103 is as follows:
[0132] S104, calculating the overlap between the defined sliding window and the template image, and dividing the positive and negative samples according to the overlap, performing multiple rotations of all positive samples with a certain angle step length and then sampling using a posterior probability classifier, and also performing sampling after scaling the template image multiple times.
[0133] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. Although the embodiment of this specification provides the method operation steps described in the embodiment or flow chart, more or less operation steps can be included based on conventional or non-creative means. The order of steps listed in the embodiment is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or device. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or device including the elements. For the convenience of description, the above device is described by dividing it into various modules according to its functions. Of course, when implementing the embodiments of this specification, the functions of each module can be implemented in the same one or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The present invention is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the process and / or box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0134] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may be in the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the embodiments of this specification may be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment. In the description of this specification, the description of the reference term "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of this specification.
[0135] In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradicting each other. The above is only an embodiment of the embodiment of this specification and is not intended to limit the embodiment of this specification. For those skilled in the art, the embodiment of this specification may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiment of this specification shall be included in the scope of the claims of the embodiment of this specification.
Claims
1. A visual localization method based on local variance and posterior probability classifier, characterized in that: include: According to the acquired template image and the size of the image where the template is located, multiple sliding windows are constructed, including: According to the template image and the size of the image where the template is located, the initial scale used for definition is translated pixel by pixel to construct a sliding window, and the generated sliding window is stored for generating samples; The moving step length of the initial scale for retrieval is set to a fixed value to construct a sliding window, and the generated sliding window is stored for the retrieval part; The multi-scale moving step size used for retrieval is set to a fixed value to construct a sliding window, and the generated sliding window is stored for the retrieval part; Acquiring multiple pairs of feature points as point pairs of a posterior probability classifier according to the features of the template image specifically includes: Retrieve feature points within a circle with the center of the template image as the center and the shortest side of the template image as the diameter to obtain feature point pairs; The pair of feature points is used as a first pair of feature points for a posterior probability classifier; Generate random points in the same range as the second pair of feature points; Establishing a local variance classifier by using the variance of the template image and using the local variance classifier to screen the sliding window specifically includes: Calculate the variance of the template image; Setting a threshold of a variance classifier to a certain proportion of the variance of the template image, wherein the variance classifier is used in both the initial scale and the multi-scale sliding window traversal; The image where the template is located is divided into positive and negative samples by the overlap between the sliding window and the template, and the posterior probability classifier is trained after performing multiple operations on the positive samples, including: Calculate the overlap between the defined sliding window and the template image, and divide the positive and negative samples according to the overlap; After all positive samples are rotated multiple times with a certain angle step, each rotation is sampled using the posterior probability classifier; After scaling the template image multiple times, the posterior probability classifier is used for sampling each time; Use negative samples to train the posterior probability classifier and modify the threshold to obtain the final posterior probability classifier; Use the final posterior probability classifier for visual localization.
2. The visual positioning method based on local variance and posterior probability classifier according to claim 1, characterized in that: The method of using negative samples to train a posterior probability classifier and modify the threshold value includes: Use negative samples to traverse half of the sliding window as the training set and do not process it. Use the posterior probability classifier for training. The remaining half of the sliding window is used as a test set to calculate the posterior probability using the trained posterior probability classifier and then the threshold of the posterior probability classifier is corrected.
3. A visual positioning device based on local variance and posterior probability classifier, characterized in that: include: The sliding window construction unit is used to construct a variety of sliding windows according to the acquired template image and the size of the image where the template is located, specifically for: A sliding window module is defined, which is used to translate the initial scale used for definition pixel by pixel to construct a sliding window according to the template image and the size of the image where the template is located, and store the generated sliding window for generating samples; The retrieval initial scale sliding window module is used to set the moving step length of the retrieval initial scale to a fixed value to construct a sliding window, and store the generated sliding window for the retrieval part; A multi-scale sliding window module for retrieval is used to set the multi-scale moving step size for retrieval to a fixed value to construct a sliding window, and store the generated sliding window for the retrieval part; A point pair acquisition unit is used to acquire multiple pairs of feature points as point pairs of a posterior probability classifier according to the features of the template image, specifically for: Retrieve feature points within a circle with the center of the template image as the center and the shortest side of the template image as the diameter to obtain feature point pairs; The pair of feature points is used as a first pair of feature points for a posterior probability classifier; Generate random points in the same range as the second pair of feature points; A screening unit is used to establish a local variance classifier according to the variance of the template image and use the local variance classifier to screen the sliding window, specifically for: Calculate the variance of the template image; Setting a threshold of a variance classifier to a certain proportion of the variance of the template image, wherein the variance classifier is used in both the initial scale and the multi-scale sliding window traversal; The positive and negative sample division unit is used to divide the image where the template is located into positive and negative samples by the overlap between the sliding window and the template, and to perform multiple operations on the positive samples and then use the posterior probability classifier for training. Specifically, it is used for: Calculate the overlap between the defined sliding window and the template image, and divide the positive and negative samples according to the overlap; After all positive samples are rotated multiple times with a certain angle step, each rotation is sampled using the posterior probability classifier; After scaling the template image multiple times, the posterior probability classifier is used for sampling each time; A training unit, used for using negative samples to train the posterior probability classifier and perform threshold correction to obtain a final posterior probability classifier; Visual localization unit, used for visual localization using the final posterior probability classifier.
4. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the visual positioning method based on local variance and posterior probability classifier according to any one of claims 1 to 2 are implemented.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the visual positioning method based on local variance and posterior probability classifier described in any one of claims 1 to 2 are implemented.
Citation Information
Patent Citations
Method for evaluating quality of full reference color image based on quaternion
CN106683082A
Object detection device of using sampling and posterior probability, and the method thereof
KR101477649B1