Ask Your Question

How to use the dense sampling detector to image with OpenCV3_python?

asked 2016-09-16 03:41:49 -0500

gelgel gravatar image

I am using python2.7, OpenCV3 with opencv-contrib to image processing.
So I can use SIFT and get features as follows,

sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(gray,None)
des = sift.compute(gray,kp)

This is good.
Now "kp" is the keypoint that result computed by SIFT's feature detector.
But I want to change this detector to dense(grid) sampling detector like this.
and I want to compute descriptors with "sift.compute(gray,kp)"
please help me.
Note: previously, it seems this is available "dense = cv2.FeatureDetector_create("Dense")"

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-09-16 04:04:12 -0500

berak gravatar image

the "Dense", "Pyramid", "Adaptive" detector variants were all removed in opencv3. (though you can still iterate over a grid, and add your own keypoints)

also, you should rather use sift.detectAndCompute() for efficiency (else you're throwing away half of the computation)

edit flag offensive delete link more


Thank you for answering. "the Dense was removed..." It is sad. I understand I have to create my own detector. But I don't know how add the keypoints properties to my own detector like a list, list = [(5,5),(10,10),...] Please tell me how. Or, I have to create in xfeatures2d.hpp before make files?

gelgel gravatar imagegelgel ( 2016-09-16 04:41:11 -0500 )edit

Fixed my code to "sift.detectAndCompute()",thank you!

gelgel gravatar imagegelgel ( 2016-09-16 04:47:37 -0500 )edit

if you want to use your own keypoints, the list should look like:


(then, ofc, use sift.compute() with that ! :)

berak gravatar imageberak ( 2016-09-16 05:16:17 -0500 )edit

The problem was solved with your help. I'm so glad!
Thank you very much!

gelgel gravatar imagegelgel ( 2016-09-16 05:29:36 -0500 )edit

Question Tools

1 follower


Asked: 2016-09-16 03:41:49 -0500

Seen: 1,424 times

Last updated: Sep 16 '16