Fast target detection method and system based on local stable feature points
By constructing a grid to filter local stable feature points and using candidate window grayscale comparison, combined with the posterior probability classification module, the problems of large computational complexity and high cost of deep learning in traditional methods are solved, and fast and accurate target detection and rotation angle judgment are achieved.
Patent Information
- Application Number
- CN202310121964.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2043-02-15
AI Technical Summary
In the existing technology of target detection on industrial assembly lines, traditional methods have large computational complexity and a single way to deal with interference, while deep learning methods are costly and difficult to efficiently detect target rotation in fixed scenes and a small number of target types.
By constructing a grid to divide the image, screening local stable feature points, using candidate windows for grayscale comparison, reducing the amount of calculation, and achieving rotation invariance of target detection, the feature points are trained in combination with the posterior probability classification module to quickly detect the target rotation angle.
It achieves fast and accurate target detection on industrial assembly lines, reduces computational complexity and cost, and has detection speed and results that are better than existing algorithms when adapting to target rotation.
Smart Images

Figure CN116129187B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image processing and target positioning, and in particular relates to a fast target detection method and system based on local stable feature points. Background Art
[0002] Object detection is a basic application in computer vision. It pre-processes the target to be detected and then finds the location of the target on the image to be searched. This type of algorithm is mainly divided into traditional object detection algorithms and deep learning-based object detection algorithms.
[0003] Traditional target detection algorithms rely on features such as the target image's grayscale, shape, edges, and gradients to locate the target on the search image, often requiring manual feature extraction based on the target type. These methods require fewer preprocessing prerequisites and are computationally inexpensive, making them widely used for target positioning on industrial assembly lines. However, current industrial applications are relatively fixed, and the algorithms cope with relatively limited interference, primarily addressing the rotation of the target. However, most current algorithms exponentially increase their computational complexity when considering target rotation, resulting in slow positioning.
[0004] Deep learning-based object detection algorithms offer significant advantages in both application scenarios and matching speed. However, their preprocessing requires a large number of training sets and sufficient computing power to train the algorithm. In industrial applications, target positioning often involves relatively fixed scenarios and a small number of target types. Therefore, the time required to collect and label training sets and train model parameters is prohibitively expensive. Consequently, deep learning is often not a preferred technical prerequisite for object detection on industrial production lines. Summary of the Invention
[0005] The present invention aims to provide a rapid target detection method and system based on locally stable feature points. This method constructs a grid within the target image, divides it into high-gradient and low-gradient grids based on the gradient size within the image grid, and selects locally stable feature points in each grid. These feature points are then used for grayscale comparison to obtain binary coded features representing candidate windows and determine the rotation angle of the target within the window. This method reduces the computational complexity of detection by using widely spaced candidate windows. Preprocessing the target image to extract coded features for training is then performed to achieve rotational invariance in the target detection algorithm.
[0006] In order to achieve the above object, the present invention provides the following technical solution in one aspect: a fast target detection method based on local stable feature points, comprising the following steps:
[0007] S1, obtaining an original image and a template image containing a target object;
[0008] S2. Calculate the candidate window size based on the template image size, and construct two candidate windows with different interval sizes on the original image. The candidate window with a small interval is used for preprocessing training, and the candidate window with a large interval is used for detection;
[0009] S3. Divide the positive and negative samples according to the overlap between the small interval candidate window and the template window, and calculate the maximum variance and minimum variance of the images in all positive sample windows as the variance threshold range;
[0010] S4. Divide the template image into regions according to the gradient, and then select two pairs of local stable feature points in each region. The feature point pairs are converted into relative coordinates based on the candidate window. Then, based on the local stable feature points of the candidate window, the grayscale values of the image in the window are compared to obtain digital coding features.
[0011] S5. Extract positive and negative sample features using local stable feature points based on the images in the positive and negative sample windows. Rotate the image in the positive sample window on the original image multiple times. After each rotation, extract the window digital code features based on the local stable feature point pairs. Train the posterior probability classification module on the extracted positive sample features and the negative sample features extracted from the image in the negative sample window. Count the probability of each digital code feature belonging to a positive sample.
[0012] S6. Rotate the local stable feature point pair multiple times around the window center, and store the coordinate points after each rotation for use in detection.
[0013] S7. Obtain the image to be searched, perform target detection, and use the candidate window with the largest interval to traverse. First, calculate the variance of the image in the window, and retain the window whose variance value is within the variance threshold range;
[0014] S8. Calculate the probability corresponding to the feature in the posterior probability classification module. If the probability is greater than the threshold, it is determined that the target exists in the window;
[0015] S9. Perform an angle judgment within the window for the window that passes the posterior probability classification module, use the stable feature points rotated at each angle to perform grayscale matching within the window to count the number of feature points with the same grayscale at each angle, and scale the candidate window to the original template size according to the angle size.
[0016] Furthermore, the S2 is specifically:
[0017] Obtain the image where the detection target is located and the target image;
[0018] According to the target image size, calculate the diagonal length of the image and use this length as the width and height of the candidate window;
[0019] Use the candidate window size to construct candidate windows with multiple pixel intervals on the target image;
[0020] According to the calculated candidate window size, a candidate window is constructed by traversing each pixel on the target image, and a new target image is constructed with the target position as the center point and the candidate window size as the size.
[0021] Furthermore, the positive and negative samples are divided according to the overlap between the small interval candidate window and the template window, specifically:
[0022] The template image is divided into positive and negative samples according to the overlap between the candidate window with a single pixel interval and the window where the target image is located;
[0023] The overlap threshold for dividing the positive and negative sample windows is determined based on the size of the candidate windows with multiple pixels as intervals used in the detection process. The larger the candidate window interval used in the detection process, the smaller the overlap threshold for dividing the positive and negative samples in the preprocessing process, and the more positive sample windows are obtained by the division;
[0024] A positive sample is one in which the overlap between the candidate window and the target window is greater than the overlap threshold;
[0025] A negative sample is one in which the overlap between the candidate window and the target window is less than the overlap threshold.
[0026] Furthermore, the step S4 is specifically as follows:
[0027] During the preprocessing process, a grid is constructed on the target image that has not been expanded to the size of the candidate window, with the width and height of the grid being one tenth of the shortest side of the image.
[0028] After the grid is constructed, the gradient of each grid in the target image is calculated, and the average value of the image gradient in all grids is calculated. Based on the average value, the grids with gradients greater than the average value are classified as high-gradient areas, and the grids with gradients less than the average value are classified as low-gradient areas.
[0029] The first pair of feature points are screened in the low gradient area. A fixed number of random points are screened in each grid in the low gradient area. The number of random coordinate points screened is determined by the scale of digital coding features required by the posterior probability classification module.
[0030] After the first pair of feature points are screened in the low gradient area, the second pair of feature points are screened in the high gradient area. The same number of feature points are screened for each grid in the high gradient area. The screening criteria are the feature points with the largest grayscale difference with the first pair of feature points and the smallest gradient around the coordinate point.
[0031] After completing the screening of two pairs of local stable feature points with the same number, the coordinates of these two pairs of feature points based on the target image size are converted into relative coordinates based on the candidate window size;
[0032] In the process of extracting digital coding features of the image in the window, two pairs of local stable feature points based on the candidate window are used to compare the grayscale of their coordinates. If the grayscale of the first pair of feature points is greater than that of the second pair of feature points, it is judged as a binary number 1, otherwise it is 0. Similarly, the grayscale comparison of all feature points is completed to obtain the binary coding features;
[0033] The binary coded features obtained from each window are split into multiple binary numbers according to the grouping and then converted into decimal codes. These multiple decimal codes are the features of the image in the window. The number of groups split into each window and the number of bits of each digital code are determined by the digital coding feature scale required by the posterior probability separation module.
[0034] Furthermore, the positive and negative sample features are extracted using local stable feature points based on the images in the positive and negative sample windows, specifically:
[0035] The positive sample feature extraction of the initial angle is obtained by comparing the grayscale size of the divided positive sample window based on the local stable feature points on the target image;
[0036] The negative sample features are obtained by comparing the grayscale size of the divided negative sample window based on the local stable feature points on the target image. The variance within the window is calculated before the window feature extraction. The windows whose variance values are no longer within the variance range of the target image are removed to avoid interfering with the training of the posterior probability classification module.
[0037] Furthermore, the image in the positive sample window on the original image is rotated multiple times, and after each rotation, a window digital code feature extraction based on a local stable feature point pair is performed, specifically:
[0038] On the target image, each image in the divided positive sample window is rotated multiple times with a fixed angle as the step size. After each rotation, the grayscale contrast of the local stable feature points is used to extract the digital coding features required by the posterior probability classification module.
[0039] The posterior probability classification module trained with the rotated positive sample features can also detect the target even when the target is rotated within the window.
[0040] Furthermore, the extracted positive sample features and the negative sample features extracted from the image in the negative sample window are used to train the posterior probability classification module, and the probability of each digital coding feature corresponding to the positive sample is statistically calculated, specifically:
[0041] During the preprocessing process, the positive sample features and negative sample features are first shuffled in order, and then each feature is trained one by one. If the feature is a positive sample feature, the cumulative number of positive samples of the digital code corresponding to the feature is increased by one. Otherwise, if the feature is a negative sample feature, a posterior probability calculation of the digital code corresponding to the current feature is performed first to determine whether the calculated posterior probability is greater than the current posterior probability module threshold. If it is greater than the threshold, the cumulative number of negative samples of the digital code corresponding to the feature is increased by one. The initial threshold of the posterior probability classification module is set to 0.5.
[0042] After the initial training of the posterior probability classification module, a test is performed. Half of the positive and negative sample features are extracted as test sets, and the posterior probability is calculated in the order of negative sample test set first and then positive sample test set. The maximum posterior probability value calculated by the posterior probability module for the negative sample test set in this part will be used as the latest threshold of the module. The positive sample test set will be repeatedly trained until the posterior probability values calculated by all positive sample test set features are greater than this threshold.
[0043] Furthermore, the specific steps of S6 are:
[0044] During the preprocessing process, two pairs of local stable feature points based on the candidate window are rotated multiple times and the coordinates of the rotated feature points are stored. The image of the window where the target is located is also rotated and stored in the same way.
[0045] During the detection process, the window that passes the posterior probability classification module uses the target image at each angle and the local stable feature points in turn to match the grayscale of the feature point coordinates. The feature points with the largest number of identical grayscales are considered to be the rotation angle of the detected target in the window.
[0046] Furthermore, the traversal using the candidate window with the largest interval is specifically as follows:
[0047] During the detection process of the image to be searched, if the size of the image to be searched is the same as the size of the target image used in preprocessing, the larger interval candidate window generated in the preprocessing process is used to traverse the image;
[0048] The image variance within each candidate window is calculated for all candidate windows, and the candidate windows whose variance meets the target variance range obtained by preprocessing enter the next module;
[0049] For candidate windows whose image variance within the window meets the target variance range, grayscale comparison is performed using local stable feature points. This is combined with the window feature extraction from the preprocessing process. The binary coded features obtained from the grayscale comparison are converted into decimal coded features. The probability of the coded features belonging to positive samples in the trained posterior probability classification module is queried. If the probability is greater than the threshold, it is determined that the target exists in the candidate window.
[0050] The candidate window that passes the posterior probability classification module is used to determine the target rotation angle within a window. Local stable feature points rotated at multiple angles are used to perform grayscale matching within the window. The angle with the largest number of feature points with the same grayscale in each candidate window is the target rotation angle. The candidate window is scaled to the size of the initial target image and rotated by the corresponding angle to obtain the detection result.
[0051] If there are multiple detection results, the overlap between the candidate windows is used to determine whether they are the same target. If they are the same target, the detection results are clustered to obtain the final detection result.
[0052] Another aspect of the present invention provides a rapid target positioning system based on local stable feature points, the system comprising:
[0053] The candidate window construction module calculates the candidate window size according to the target image size, and generates candidate windows with pixel-by-pixel moving steps used in preprocessing and candidate windows with multiple pixels as intervals used in the detection process;
[0054] The local stable feature point screening module constructs a grid area on the target image and divides the image into high-gradient areas and low-gradient areas according to the image gradient within the grid. A fixed number of local stable feature points are screened in each area, and the feature points are stored as relative coordinates based on the candidate window.
[0055] The positive and negative sample division module calculates the overlap between the candidate window generated by the candidate window construction module and the target window on the target image, divides the positive and negative samples according to the overlap, and calculates the variance of the images in all positive sample windows. The maximum and minimum variance values are statistically obtained as the subsequent variance range;
[0056] A posterior probability classification training module, wherein the features trained by the posterior probability classification training module are mainly divided into positive sample features, rotated positive sample features and negative sample features. The positive sample features are extracted by directly using local stable feature points on the target image to perform grayscale contrast on the image in the positive sample window to extract coding features. The rotated positive sample features will perform multiple rotation operations on the image in the window before grayscale contrast, and feature extraction will be performed after each rotation. The negative sample features will perform a variance calculation on the image in the negative sample window before extraction. If the calculated variance is not within the variance range, feature extraction will not be performed. After obtaining the positive and negative sample features, they are shuffled and then trained in sequence for the posterior probability classification module;
[0057] The posterior probability classification correction module randomly extracts half of the positive and negative sample features as the test set. In the posterior probability classification module, local stable feature points are used for feature extraction. The maximum posterior probability obtained in the negative sample test set is used as the threshold of the module. The positive sample training set is repeatedly trained until the posterior probability of all positive sample features is greater than the threshold.
[0058] The angle judgment preparation module rotates the two pairs of local stable feature points based on the candidate window obtained in the local stable feature point screening module multiple times around the window center and stores the coordinates of the feature points after each rotation. The window where the target is located is also rotated and stored in the same way.
[0059] The variance detection module in the candidate window creates an integral image and a square integral image for the search image, and then calculates the variance value of the image in the candidate window. If the variance value is not within the target variance range, it is determined that there is no detection target in the window;
[0060] The posterior probability classification detection module performs grayscale comparison based on local stable feature points on candidate windows whose image variance values within the window meet the variance range to obtain the digital coding features representing the window, and queries the posterior probability cumulative value corresponding to the feature in the posterior probability classification module. If the cumulative value is greater than the module threshold, it is determined that the target object exists in the window;
[0061] The target rotation angle judgment module can judge that the candidate window with a variance within the variance range and passing the posterior probability classification module has met the requirements of image contrast and grayscale distribution. For each candidate window with a target object, the local stable feature points at each angle are used to perform grayscale matching with the target image in turn. The number of feature points with grayscale matching at each angle is counted, and the one with the largest number is taken as the rotation angle of the target in the window. The candidate window is then re-corrected based on this angle.
[0062] Compared with the prior art, the present invention has the following beneficial effects:
[0063] (1) The present invention uses the traditional target positioning idea in the general idea of target detection, which is to achieve target detection by constructing a candidate window and then calculating the correlation of the image within the candidate window. This method specifically uses three calculations on the candidate window, including variance calculation within the window, posterior probability classification calculation based on local stable feature points, and target rotation angle statistics based on local stable feature points. Multiple modules based on local stable feature points enable this target detection system to use as little computation as possible during the detection process to achieve the positioning of the detected target and the judgment of the rotation angle.
[0064] (2) The present invention expands the candidate window according to the size of the target image so that any rotation of the target can be within the candidate window range. Subsequently, the target window size is restored according to the angle judgment module based on stable feature points. In dealing with the case of target rotation, the detection speed and the window drawing of the detection results are better than the existing algorithms. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The present invention is further described with reference to the accompanying drawings. However, the embodiments in the accompanying drawings do not constitute any limitation to the present invention. A person skilled in the art can obtain other drawings based on the following drawings without creative effort.
[0066] Figure 1 This is a flow chart of a method for rapid target detection based on local stable feature points of the present invention.
[0067] Figure 2 A flowchart of the preprocessing steps of a fast target detection method based on local stable feature points provided by an embodiment of the present invention;
[0068] Figure 3 A flow chart of the detection steps of a fast target detection method based on local stable feature points provided by an embodiment of the present invention;
[0069] Figure 4 A structural block diagram of a fast target detection system based on local stable feature points provided by an embodiment of the present invention;
[0070] Figure 5 This is a structural block diagram of a fast target detection device based on local stable feature points provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0071] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention. Specific implementation method:
[0073] Reference Figure 1 The embodiment of the present invention provides a fast target detection method based on local stable feature points, including a preprocessing part and a detection part, referring to Figure 2 , the pre-processing part specifically includes the following steps:
[0074] S101. Calculate the candidate window size according to the target image size, and construct two types of candidate windows with intervals on the initial image. One is a candidate window with intervals of a single pixel used in the preprocessing process, and the other is a candidate window with intervals of multiple pixels used in the detection process.
[0075] Specifically, the size of the candidate window is calculated based on the target image size. The candidate window with a single pixel interval is mainly used for training operations during the preprocessing process, and the candidate window with multiple pixels intervals is mainly used to traverse the input image during the detection process. Step S101 includes the following steps:
[0076] S1011. Acquire the initial image and target image where the target is located; S1012. Calculate the diagonal length of the image based on the size of the target image, and use the diagonal length as the width and height of the candidate window. Then, based on the candidate window, construct two candidate windows with different pixel spacings on the initial image where the target is located; S1013. Based on the candidate window, create a new target image based on the size of the candidate window with the center of the target as the window center on the initial image where the target is located;
[0077] S102. Screening local stable feature point pairs on the target image. First, construct a grid on the target image, divide the image into high-gradient and low-gradient regions according to the image gradient within the grid, and screen out local stable feature point pairs in the two gradient regions according to the gradient size of the coordinate points.
[0078] Specifically, the digital coding features required by the posterior probability classification module need to be obtained by grayscale comparison of two pairs of coordinate points within the candidate window. Therefore, two pairs of feature points that can be evenly distributed in various areas of the target image and are as unaffected as possible by coordinate offset are required. Step S102 specifically includes the following steps:
[0079] S1021. First, it is necessary to construct a grid area on the target image, and divide it into high-gradient areas and low-gradient areas according to the gradient size of the image in the grid. The division standard is the average value of the image gradient in each area. Subsequently, a fixed number of feature points will be screened in each grid; S1022. The first pair of feature points is constructed in the low-gradient grid area. The gradient of the image in the low-gradient grid area is small and the grayscale is relatively stable. Therefore, feature points are randomly screened in each grid area. Even if the coordinates of these feature points are offset, there is a high probability that there will be no grayscale change; S1023. The second pair of feature points is constructed in the high-gradient grid area. The image in the high-gradient grid area has a higher gradient, that is, a more drastic grayscale change. Like the first pair of feature points, a fixed number of feature points are screened in each grid area. The screening standard is the coordinate points with a larger grayscale difference from the first pair of feature points and a smaller gradient around the coordinate points. These feature points have a lower probability of affecting the grayscale after the coordinate offset occurs;
[0080] S1022: The first pair of feature points is constructed in a low-gradient grid area. The image gradient in the low-gradient grid area is small and the grayscale is relatively stable. Therefore, feature points are randomly selected in each grid area. Even if the coordinates of these feature points shift, there is a high probability that the grayscale will not change.
[0081] S1023. The second pair of feature points is constructed in a high-gradient grid area. The image in the high-gradient grid area has a higher gradient, that is, a more drastic grayscale change. As with the first pair of feature points, a fixed number of feature points are selected in each grid area. The selection criteria are coordinate points with a large grayscale difference from the first pair of feature points and a small gradient around the coordinate points. These feature points are less likely to have their grayscale affected after a coordinate shift occurs.
[0082] S1024: Convert the two pairs of local stable feature points into relative coordinates based on the candidate window and store them.
[0083] In an embodiment of the present invention, considering the type of target detection task and the scale of the posterior probability classification module, the number of feature coordinate point pairs screened is 100 pairs, that is, two pairs of feature point sets of 100 coordinate points need to be prepared for the screening of local stable feature points.
[0084] S103, on the initial image, calculate the overlap between the candidate window with a single pixel interval and the window where the target is located, divide it into positive and negative sample windows according to the overlap, and calculate the variance range of the image in the positive sample window as the target variance range. Step S103 is as follows:
[0085] S1031, using the constructed candidate windows with single pixel intervals to calculate overlap with the window where the target is located;
[0086] S1032, determining an overlap threshold for dividing positive and negative samples according to the interval size of candidate windows separated by multiple pixels;
[0087] S1033. The candidate windows whose overlap is greater than the threshold are positive sample windows, otherwise they are negative sample windows.
[0088] In an embodiment of the present invention, the positive sample window calculates the image variance within a window and counts the maximum and minimum variances as the target variance range. Then, the negative sample window calculates the image variance within a window and determines whether the variance is within the variance range. If it is not within the variance range, it is filtered out.
[0089] S104. Feature extraction of the image in the candidate window is mainly divided into positive sample features, rotated positive sample features and negative sample features. Specifically, digital coding features are obtained by comparing the grayscale sizes of local stable feature points of the image in the window. The rotated positive and negative sample features are obtained by rotating the window image multiple times and then extracting the digital coding features.
[0090] The specific steps are as follows: S1041, the feature of the initial angle of the positive sample is to use the local stable feature points to sequentially compare the grayscale size of the image in the positive sample window, and the comparison result is converted into a binary coded feature and then into a decimal coded feature;
[0091] S1042, negative sample features are obtained by performing grayscale comparison on the image in the negative sample window within the variance range using local stable feature points, and the comparison results are converted into decimal coded features in the same way as the positive sample feature extraction method;
[0092] S1043, the rotated positive sample features are similar to the positive sample feature extraction process, but before feature extraction, the image in the positive sample window will be rotated multiple times, and feature extraction will be performed after each rotation;
[0093] In the embodiment of the present invention, the rotation invariance of the algorithm is achieved by extracting features after rotating the image in the positive sample window multiple times. After the posterior probability classification module is subsequently trained with these features, it can pass the candidate window after the target rotation.
[0094] S105: Perform preliminary training of the posterior probability module on the positive and negative sample features. After the feature order is disrupted, the probability of each digital code corresponding to the positive sample category is counted in sequence. Then, half of the positive and negative sample features are extracted to perform module parameter correction and threshold determination. This step is specifically as follows:
[0095] S1051. First, the extracted positive and negative sample features are shuffled in order;
[0096] S1052. Counting the number of positive samples and the number of negative samples corresponding to the digital codes of the positive and negative sample features, and obtaining the probability that each digital code belongs to a positive sample is the training of the posterior probability module.
[0097] S1053. Extract half of the positive and negative sample features as the test set;
[0098] S1054. First, calculate the posterior probability using the negative sample test set, and use the largest posterior probability result as the threshold of the module;
[0099] S1055. Use the positive sample test set to calculate the posterior probability of the threshold. If the posterior probability is less than the threshold, the digital encoding of the positive sample feature is repeatedly trained until the result is greater than the threshold.
[0100] S106: Rotate the local stable feature points based on the candidate window around the center of the window multiple times and store them. The target image is also rotated and stored in the same manner. This step is specifically as follows:
[0101] S1061, first, the local stable feature point is rotated around the center of the window, and the coordinate point pairs after each rotation are stored separately;
[0102] S1062: Rotate the target image of the candidate window size by the same angle and step size, and store it;
[0103] In an embodiment of the present invention, during the detection process, the candidate window obtained will use the local stable feature points of each angle and the target image of the corresponding angle to compare the grayscale values, and the angle with the largest number of feature points with the same grayscale will be counted, which is the rotation angle of the target in the window.
[0104] The embodiment of the present invention provides a fast target detection method based on local stable feature points. Figure 3 , the detection part specifically includes the following steps:
[0105] Obtain the image to be detected;
[0106] Determine whether the size of the image to be detected is the same as the size of the template image used in preprocessing. If the sizes are the same, directly use the candidate window with multiple pixels as the interval constructed by preprocessing to traverse the image to be detected. Otherwise, construct a candidate window with multiple pixels as the interval in the image to be detected.
[0107] First, construct the integral image and square integral image of the image to be detected;
[0108] The integral image and square integral image of the image to be detected are used to quickly calculate the variance value within the candidate window. The variance value of the image within the candidate window is determined to be within the variance threshold range obtained by preprocessing. Candidate windows with variance values outside the range are judged to have no detection target. The variance value represents the contrast intensity of the image. If the variance of the image within the candidate window is too large or too small, it indicates that the contrast does not meet the detection target.
[0109] The correlation calculation for the posterior probability classification module is performed on the candidate windows that pass the variance test. This part uses the local stable feature point pairs obtained in preprocessing to extract image features within the candidate window. The corresponding probabilities of the extracted digital coding features in the posterior probability classification module are then queried. The posterior probabilities corresponding to all digital coding features are accumulated to obtain the window correlation. This part of the posterior probability classification module is completed during the preprocessing process using images within the positive and negative sample windows.
[0110] The candidate windows that pass the posterior probability classification module are used to determine the rotation angle of the target within the window. The local stable feature points of various angles obtained by multiple rotations during the preprocessing process are used. Each candidate window uses the local stable feature points of each angle to perform feature point grayscale matching. The number of feature points with the same grayscale at each angle is counted. The angle with the largest number of matching feature points is the rotation angle of the target within the window.
[0111] According to the obtained rotation angle of the target in the window, the candidate window originally recalculated is restored, the candidate window is changed back to the initial target image size, and the candidate window is rotated according to the statistically obtained rotation angle.
[0112] The remaining candidate window is the detection result.
[0113] Reference Figure 4 , an embodiment of the present invention provides a fast target detection system based on local stable feature points, comprising:
[0114] The candidate window construction module is used to construct a candidate window that can contain the target at any rotation angle based on the target image size. It then constructs a candidate window with a single pixel interval and a candidate window with multiple pixels interval in the initial image where the target is located. The former is used in the preprocessing process, and the latter is used in the detection process.
[0115] The local stable feature point screening module divides the target image into various gradient regions. It selects the same number of random feature points in the low-gradient region, and then selects feature points with a large grayscale difference from the random feature points and a small gradient around the coordinate point in the high-gradient region. The two pairs of local stable feature points are converted into feature point pairs based on the candidate window.
[0116] The positive and negative sample classification module calculates the overlap between the candidate window with a single pixel interval constructed by the candidate window construction module and the candidate window where the target is located, and determines the overlap threshold for classifying positive and negative samples based on the interval size of the candidate window with multiple pixels as the interval;
[0117] The posterior probability classification training module trains positive samples, rotated negative positive samples, and negative sample features. First, it uses local stable feature points to perform grayscale contrast within the sample window to obtain digital coding features. Then, it calculates the probability of each digital coding feature belonging to a positive sample.
[0118] The posterior probability classification correction module randomly selects half of the extracted positive and negative sample features as the test set. The negative sample test set is first used to obtain the threshold of the posterior probability classification module, and then the positive sample features are used to correct the module parameters.
[0119] Angle judgment preparation module rotates the local stable feature point pairs based on the candidate window and the target object multiple times, and stores the results of each rotation;
[0120] The variance detection module in the candidate window uses the candidate windows with multiple pixel intervals established in the preprocessing process to traverse the input image one by one. First, the integral image and square integral image of the input image are calculated, and the variance of the image in all candidate windows is calculated. The windows with variances within the target variance range are retained and entered into the next module.
[0121] The posterior probability classification detection module uses local stable feature points to compare the grayscale size of the image in the candidate window that passes the variance detection module to extract digital coding features. The probability of the feature code corresponding to the query module belonging to the positive sample is calculated. If the probability is greater than the module threshold, the module passes the detection;
[0122] The target rotation angle judgment module performs grayscale matching of local stable feature points at each angle for the candidate windows detected by variance detection and posterior probability classification, uses the target image with the corresponding rotation angle for matching, counts the angle with the largest number of feature points with the same grayscale, and restores the candidate window to the target image size based on the angle.
[0123] Reference Figure 5 , an embodiment of the present invention provides a fast target detection device based on local stable feature points, comprising:
[0124] at least one processor;
[0125] at least one memory for storing at least one program;
[0126] When the at least one program is executed by the at least one processor, the at least one processor implements the fast target detection method based on local stable feature points.
[0127] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0128] An embodiment of the present invention further provides a computer-readable storage medium storing a program executable by a processor. When the program is executed by the processor, it is used to perform the above-mentioned method for rapid target detection based on local stable feature points.
[0129] A computer-readable storage medium according to an embodiment of the present invention can execute a fast target detection method based on local stable feature points provided by an embodiment of the method of the present invention, can execute any combination of implementation steps of the embodiment of the method, and has the corresponding functions and beneficial effects of the method.
[0130] The embodiment of the present invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs Figure 1 The method shown.
[0131] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the claims and their equivalents.
Claims
1. A fast target positioning system based on local stable feature points, characterized in that: The system comprises: The candidate window construction module calculates the candidate window size according to the target image size, and generates candidate windows with pixel-by-pixel moving steps used in preprocessing and candidate windows with multiple pixels as intervals used in the detection process; The local stable feature point screening module constructs a grid area on the target image and divides the image into high-gradient areas and low-gradient areas according to the image gradient within the grid. A fixed number of local stable feature points are screened in each area, and the feature points are stored as relative coordinates based on the candidate window. The positive and negative sample division module calculates the overlap between the candidate window generated by the candidate window construction module and the target window on the target image, divides the positive and negative samples according to the overlap, and calculates the variance of the images in all positive sample windows. The maximum and minimum variance values are statistically obtained as the subsequent variance range; A posterior probability classification training module, wherein the features trained by the posterior probability classification training module are mainly divided into positive sample features, rotated positive sample features and negative sample features. The positive sample features are extracted by directly using local stable feature points on the target image to perform grayscale contrast on the image in the positive sample window to extract coding features. The rotated positive sample features will perform multiple rotation operations on the image in the window before grayscale contrast, and feature extraction will be performed after each rotation. The negative sample features will perform a variance calculation on the image in the negative sample window before extraction. If the calculated variance is not within the variance range, feature extraction will not be performed. After obtaining the positive and negative sample features, they are shuffled and then trained in sequence for the posterior probability classification module; The posterior probability classification correction module randomly extracts half of the positive and negative sample features as the test set. In the posterior probability classification module, local stable feature points are used for feature extraction. The maximum posterior probability obtained in the negative sample test set is used as the threshold of the module. The positive sample training set is repeatedly trained until the posterior probability of all positive sample features is greater than the threshold. The angle judgment preparation module rotates the two pairs of local stable feature points based on the candidate window obtained in the local stable feature point screening module multiple times around the window center and stores the coordinates of the feature points after each rotation. The window where the target is located is also rotated and stored in the same way. The variance detection module in the candidate window creates an integral image and a square integral image for the search image, and then calculates the variance value of the image in the candidate window. If the variance value is not within the target variance range, it is determined that there is no detection target in the window; The posterior probability classification detection module performs grayscale comparison based on local stable feature points on candidate windows whose image variance values within the window meet the variance range to obtain the digital coding features representing the window, and queries the posterior probability cumulative value corresponding to the feature in the posterior probability classification module. If the cumulative value is greater than the module threshold, it is determined that the target object exists in the window; The target rotation angle judgment module can judge that the candidate window with a variance within the variance range and passing the posterior probability classification module has met the requirements of image contrast and grayscale distribution. For each candidate window with a target object, the local stable feature points at each angle are used to perform grayscale matching with the target image in turn. The number of feature points with grayscale matching at each angle is counted, and the one with the largest number is taken as the rotation angle of the target in the window. The candidate window is then re-corrected based on this angle.
2. A fast target positioning system based on local stable feature points according to claim 1, characterized in that: The steps include: S1, obtaining an original image and a template image containing a target object; S2. Calculate the candidate window size based on the template image size, and construct two candidate windows with different interval sizes on the original image. The candidate window with a small interval is used for preprocessing training, and the candidate window with a large interval is used for detection; S3. Divide the positive and negative samples according to the overlap between the small interval candidate window and the template window, and calculate the maximum variance and minimum variance of the images in all positive sample windows as the variance threshold range; S4. Divide the template image into regions according to the gradient, and then select two pairs of local stable feature points in each region. The feature point pairs are converted into relative coordinates based on the candidate window. Then, based on the local stable feature points of the candidate window, the grayscale values of the image in the window are compared to obtain digital coding features. S5. Extract positive and negative sample features using local stable feature points based on the images in the positive and negative sample windows. Rotate the image in the positive sample window on the original image multiple times. After each rotation, extract the window digital code features based on the local stable feature point pairs. Train the posterior probability classification module on the extracted positive sample features and the negative sample features extracted from the image in the negative sample window. Count the probability of each digital code feature belonging to a positive sample. S6. Rotate the local stable feature point pairs around the window center multiple times, and store the coordinate points after each rotation for use in detection. S7. Obtain the image to be searched, perform target detection, and use the candidate window with the largest interval to traverse. First, calculate the variance of the image in the window, and retain the window whose variance value is within the variance threshold range; S8. Calculate the probability corresponding to the feature in the posterior probability classification module. If the probability is greater than the threshold, it is determined that the target exists in the window; S9. Perform an angle judgment within the window for the window that passes the posterior probability classification module, use the stable feature points rotated at each angle to perform grayscale matching within the window to count the number of feature points with the same grayscale at each angle, and scale the candidate window to the original template size according to the angle size.
3. The fast target detection method based on local stable feature points according to claim 2, characterized in that: The S2 is specifically: Obtain the image where the detection target is located and the target image; According to the target image size, calculate the diagonal length of the image and use this length as the width and height of the candidate window; Use the candidate window size to construct candidate windows with multiple pixel intervals on the target image; According to the calculated candidate window size, a candidate window is constructed by traversing each pixel on the target image, and a new target image is constructed with the target position as the center point and the candidate window size as the size.
4. The fast target detection method based on local stable feature points according to claim 2, characterized in that: The positive and negative samples are divided according to the overlap between the small interval candidate window and the template window, specifically: The template image is divided into positive and negative samples according to the overlap between the candidate window with a single pixel interval and the window where the target image is located; The overlap threshold for dividing the positive and negative sample windows is determined based on the size of the candidate windows with multiple pixels as intervals used in the detection process. The larger the candidate window interval used in the detection process, the smaller the overlap threshold for dividing the positive and negative samples in the preprocessing process, and the more positive sample windows are obtained by the division; A positive sample is one in which the overlap between the candidate window and the target window is greater than the overlap threshold; A negative sample is one in which the overlap between the candidate window and the target window is less than the overlap threshold.
5. The fast target detection method based on local stable feature points according to claim 2, characterized in that: The step S4 is specifically as follows: During the preprocessing process, a grid is constructed on the target image that has not been expanded to the size of the candidate window, with the width and height of the grid being one tenth of the shortest side of the image. After the grid is constructed, the gradient of each grid in the target image is calculated, and the average value of the image gradient in all grids is calculated. Based on the average value, the grids with gradients greater than the average value are classified as high-gradient areas, and the grids with gradients less than the average value are classified as low-gradient areas. The first pair of feature points are screened in the low gradient area. A fixed number of random points are screened in each grid in the low gradient area. The number of random coordinate points screened is determined by the scale of digital coding features required by the posterior probability classification module. After the first pair of feature points are screened in the low gradient area, the second pair of feature points are screened in the high gradient area. The same number of feature points are screened for each grid in the high gradient area. The screening criteria are the feature points with the largest grayscale difference with the first pair of feature points and the smallest gradient around the coordinate point. After completing the screening of two pairs of local stable feature points with the same number, the coordinates of these two pairs of feature points based on the target image size are converted into relative coordinates based on the candidate window size; In the process of extracting digital coding features of the image in the window, two pairs of local stable feature points based on the candidate window are used to compare the grayscale of their coordinates. If the grayscale of the first pair of feature points is greater than that of the second pair of feature points, it is judged as a binary number 1, otherwise it is 0. Similarly, the grayscale comparison of all feature points is completed to obtain the binary coding features; The binary coded features obtained from each window are split into multiple binary numbers according to the grouping and then converted into decimal codes. These multiple decimal codes are the features of the image in the window. The number of groups split into each window and the number of bits of each digital code are determined by the digital coding feature scale required by the posterior probability separation module.
6. The fast target detection method based on local stable feature points according to claim 2, characterized in that: The positive and negative sample feature extraction is performed using local stable feature points based on the images in the positive and negative sample windows, specifically: The positive sample feature extraction of the initial angle is obtained by comparing the grayscale size of the divided positive sample window based on the local stable feature points on the target image; The negative sample features are obtained by comparing the grayscale size of the divided negative sample window based on the local stable feature points on the target image. The variance within the window is calculated before the window feature extraction. The windows whose variance values are no longer within the variance range of the target image are removed to avoid interfering with the training of the posterior probability classification module.
7. The fast target detection method based on local stable feature points according to claim 6, characterized in that: The image in the positive sample window on the original image is rotated multiple times, and after each rotation, a window digital code feature extraction based on a local stable feature point pair is performed, specifically: On the target image, each image in the divided positive sample window is rotated multiple times with a fixed angle as the step size. After each rotation, the grayscale contrast of the local stable feature points is used to extract the digital coding features required by the posterior probability classification module. The posterior probability classification module trained with the rotated positive sample features can also detect the target even when the target in the window is rotated.
8. The fast target detection method based on local stable feature points according to claim 7, characterized in that: The extracted positive sample features and the negative sample features extracted from the image in the negative sample window are used to train the posterior probability classification module, and the probability of each digital coding feature belonging to a positive sample is counted, specifically: During the preprocessing process, the positive sample features and negative sample features are first shuffled in order, and then each feature is trained one by one. If the feature is a positive sample feature, the cumulative number of positive samples of the digital code corresponding to the feature is increased by one. Otherwise, if the feature is a negative sample feature, a posterior probability calculation of the digital code corresponding to the current feature is performed first to determine whether the calculated posterior probability is greater than the current posterior probability module threshold. If it is greater than the threshold, the cumulative number of negative samples of the digital code corresponding to the feature is increased by one. The initial threshold of the posterior probability classification module is set to 0.
5. After the initial training of the posterior probability classification module, a test is performed. Half of the positive and negative sample features are extracted as test sets, and the posterior probability is calculated in the order of negative sample test set first and then positive sample test set. The maximum posterior probability value calculated by the posterior probability module for the negative sample test set in this part will be used as the latest threshold of the module. The positive sample test set will be repeatedly trained until the posterior probability values calculated by all positive sample test set features are greater than this threshold.
9. The fast target detection method based on local stable feature points according to claim 2, characterized in that: The specific steps of S6 are: During the preprocessing process, two pairs of local stable feature points based on the candidate window are rotated multiple times and the coordinates of the rotated feature points are stored. The image of the window where the target is located is also rotated and stored in the same way. During the detection process, the window that passes the posterior probability classification module uses the target image at each angle and the local stable feature points in turn to match the grayscale of the feature point coordinates. The feature points with the largest number of identical grayscales are considered to be the rotation angle of the detected target in the window.
10. The fast target detection method based on local stable feature points according to claim 2, characterized in that: The traversal using the candidate window with the largest interval is specifically as follows: During the detection process of the image to be searched, if the size of the image to be searched is the same as the size of the target image used in preprocessing, the larger interval candidate window generated in the preprocessing process is used to traverse the image; The image variance within each candidate window is calculated for all candidate windows, and the candidate windows whose variance meets the target variance range obtained by preprocessing enter the next module; For candidate windows whose image variance within the window meets the target variance range, grayscale comparison is performed using local stable feature points. This is combined with the window feature extraction from the preprocessing process. The binary coded features obtained from the grayscale comparison are converted into decimal coded features. The probability of the coded features belonging to positive samples in the trained posterior probability classification module is queried. If the probability is greater than the threshold, it is determined that the target exists in the candidate window. The candidate window that passes the posterior probability classification module is used to determine the target rotation angle within a window. Local stable feature points rotated at multiple angles are used to perform grayscale matching within the window. The angle with the largest number of feature points with the same grayscale in each candidate window is the target rotation angle. The candidate window is scaled to the size of the initial target image and rotated by the corresponding angle to obtain the detection result. If there are multiple detection results, the overlap between the candidate windows is used to determine whether they are the same target. If they are the same target, the detection results are clustered to obtain the final detection result.
Citation Information
Patent Citations
Template matching LSP algorithm for visual positioning, medium and equipment
CN111553425A
Representing Object Shapes Using Radial Basis Function Support Vector Machine Classification
US20120207384A1