Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Fast algorithm FAST for Corner Detection in openCV

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use corner detection fast algorithm FAST in openCV", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "how to use corner detection fast algorithm FAST in openCV" this article.

Principle

We have seen several characteristic detectors, many of which are very good. But from the perspective of real-time applications, they are not fast enough. A good example: for example, there will be problems with the application of SLAM technology (even positioning and mapping technology) to mobile robots with limited computing resources. One solution is to use FAST algorithm. The basic summary of the algorithm is as follows.

Use FAST to detect features

Select the pixel p in the image as the point of interest or not as the point of interest. Let its strength I p.

Select the appropriate threshold t.

Consider a circle of 16 pixels around the pixels in the test (as shown in the following figure)

Then pixel p is a corner, if there is a set of adjacent n pixels in the circle (n of 16 pixels), their brightness is greater than Ip+t, or darker than Ip − t. The white dotted line is shown in the picture above. N is 12.

A high-speed test method is proposed to eliminate a large number of non-turning angles. This test only examines the 4 pixels at 1 and 9 (first test the pixels at 1 and 9 to see if they are too bright or dark, and then check 5 and 13 if so). If p is an angle, then at least three of the points must be brighter than Ip+t or darker than Ip-t. If it is neither, then p cannot be an angle. Then, through the detection of all the pixels in the circle, the full-segment test criterion is applied to the candidate object. The detector itself shows high performance, but has several weaknesses:

The algorithm will not reject a large number of n

< 12 的候选点. 像素的选择不是最优的,因为它的效率取决于问题的排序和角的分布。 快速测试的结果可能被丢弃。 多个特征相邻检测。 前3点是用机器学习方法解决的。最后一个是使用非最大抑制。 机器学习角检测器 选择一组用于培训的图像 (最好来自检测目标范围的图像) 对每一张图像运用 FAST 算法找到特点. 对于每个特征点,将其周围的16个像素存储为一个向量。对所有的图像都这样做,得到特征向量P。 这16个像素中的每个像素(比如x)都可以有以下三种状态之一:

5. According to these states, the feature vector P is subdivided into three subsets, Pd, Ps, Pb.

6. Define a new Boolean variable Kp, which is true if p is an angle, or false otherwise.

7. The ID3 algorithm (decision tree classifier) is used to query each subset, and the variable Kp is used to query the true class. It chooses x, which produces the most information, as a candidate for angle, which can be measured by calculating the entropy of Kp.

8. Apply recursively to all subsets until its entropy is zero.

9. The established decision tree is used for fast detection of other images.

Non-maximum suppression

Detecting multiple points of interest in adjacent locations is another problem. The non-maximum suppression method is used to solve the problem.

Calculate a fraction function, where V represents all detected feature points. V is the sum of the absolute difference between p and the surrounding 16 pixels.

Consider two adjacent keys and calculate their V values.

Discard t discards the one with the lower V value.

Summary

It is several times faster than other existing angle detectors.

However, it is not good for the image with high noise, which depends on the threshold setting.

Application of FAST in OpenCV

Like other feature detectors. If you want, you can specify a threshold, whether the non-maximum suppression is used or not, the neighborhood is turned on. The neighborhood defines three tags, cv.FAST_FEATURE_DETECTOR_TYPE_5_8, cv.FAST_FEATURE_DETECTOR_TYPE_7_12 and cv.FAST_FEATURE_DETECTOR_TYPE_9_16. The following simple lines of code show how to use the FAST function to detect and draw feature points.

Import numpy as npimport cv2 as cvfrom matplotlib import pyplot as pltimg = cv.imread ('simple.jpg',0) # Initiate FAST object with default valuesfast = cv.FastFeatureDetector_create () # find and draw the keypointskp = fast.detect (img,None) img2 = cv.drawKeypoints (img, kp, None, color= ) # Print all default paramsprint ("Threshold: {}" .format (fast.getThreshold ()) print ("nonmaxSuppression: {}" .format (fast.getNonmaxSuppression () print ("neighborhood: {}" .format (fast.getType () print ("Total Keypoints with nonmaxSuppression: {}" .format (len (kp) cv.imwrite ('fast_true.png',img2) # Disable nonmaxSuppressionfast.setNonmaxSuppression (0) kp = fast.detect (img) None) print ("Total Keypoints without nonmaxSuppression: {}" .format (len (kp)) img3 = cv.drawKeypoints (img, kp, None, color=) cv.imwrite ('fast_false.png',img3)

Looking at the results, the left and right show the effects of non-maximum suppression on and off, respectively:

These are all the contents of this article entitled "how to use the Fast algorithm FAST for Corner Detection in openCV". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report