官术网_书友最值得收藏!

  • OpenCV 4 with Python Blueprints
  • Dr. Menua Gevorgyan Arsen Mamikonyan Michael Beyeler
  • 341字
  • 2021-06-24 16:50:07

Detecting features in an image with SURF

In the remainder of this chapter, we will make use of the SURF detector. The SURF algorithm can be roughly divided into two distinct steps, which are detecting points of interest and formulating a descriptor.

SURF relies on the Hessian corner detector for interest point detection, which requires the setting of a minimal minhessianThreshold. This threshold determines how large the output from the Hessian filter must be in order for a point to be used as an interesting point. 

When the value is larger, fewer interest points are obtained, but they are theoretically more salient and vice versa. Feel free to experiment with different values.

In this chapter, we will choose a value of 400, as we did earlier in FeatureMatching.__init__, where we created a SURF descriptor with the following code snippet:

self.f_extractor = cv2.xfeatures2d_SURF.create(hessianThreshold=400)

The keypoints in the image can be obtained in a single step, which is given as follows:

key_query = self.f_extractor.detect(img_query)

Here, key_query is a list of instances of cv2.KeyPoint and has the length of the number of detected keypoints. Each KeyPoint contains information about the location (KeyPoint.pt), the size ( KeyPoint.size ), and other useful information about our point of interest. 

We can now easily draw the keypoints using the following function:

img_keypoints = cv2.drawKeypoints(img_query, key_query, None,
(255, 0, 0), 4)
cv2.imshow("keypoints",img_keypoints)

Depending on an image, the number of detected keypoints can be very large and unclear when visualized; we check it with len(keyQuery). If you care only about drawing the keypoints, try setting min_hessian to a large value until the number of returned keypoints provides a good illustration.


Note that SURF is protected by patent laws. Therefore, if you wish to use SURF in a commercial application, you will be required to obtain a license.

In order to complete our feature extraction algorithm, we need to obtain descriptors for our detected keypoints, which we will do in the next section.

主站蜘蛛池模板: 诏安县| 乾安县| 定陶县| 三河市| 焦作市| 景德镇市| 南乐县| 塘沽区| 铜梁县| 东辽县| 保定市| 武平县| 沈丘县| 潞城市| 漳平市| 德州市| 珲春市| 拉孜县| 张掖市| 中宁县| 衢州市| 无极县| 平罗县| 东明县| 南丹县| 湘西| 彰化市| 合川市| 南丰县| 芦山县| 当涂县| 恩施市| 常州市| 北流市| 营山县| 长葛市| 岳阳市| 那坡县| 红安县| 苍南县| 清流县|