4

I need to do an object recognition in real time (with image coming from videocamera usb)

Is there anyway to tell

SurfFeatureDetector.detect(); 

to extract less keypoint ?

dynamic
  • 46,985
  • 55
  • 154
  • 231

2 Answers2

4

By modifying the threshold you can control somehow the number of keypoints. Anyway this is not controlling directly the maximum number of keypoints.

If you want it to stop at a maximum you will have to go into the algorithm in the .cpp (which is not debugable) and set a condition in a loop. I did this with some algortihms in OpenCV to gain computanional efficiency. The problem is that you will need to copy the code and paste in your own class to be able to modify and it gives some linking problems until you get everything right.d

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
2

Here is the constructor for SurfFeatureDetector. With the constructor, you can decrease the number of keypoints with the 3 basic arguments:

  • hessianThreshold: increase this
  • octaves: decrease this
  • octavelayers: decrease this

I don't know the details of SURF implementation, but this SO answer points to documentation which explains the whole algorithm so you can choose how to change those.

As an alternative to studying the implementation directly, I have found Find-Object to be very useful for experimenting with many of the feature detection algorithm settings.

Community
  • 1
  • 1
KobeJohn
  • 7,390
  • 6
  • 41
  • 62