Ask Your Question
0

Compute Dense SIFT features in OpenCV 3.0

asked 2015-10-14 04:10:47 -0500

Khue gravatar image

Since version 3.0, DenseFeatureDetector is no longer available. Could anybody please show me how to compute Dense SIFT features in OpenCV 3.0? I couldn't find it in the documentation.

I have opencv_contrib installed.

Thank you very much in advance!

edit retag flag offensive close merge delete

Comments

have you tried including xfeatures2d.hpp (as is said here)? docs

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-10-14 06:45:37 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
4

answered 2015-10-14 07:36:38 -0500

berak gravatar image

yes, the DenseFeatureDetector is gone in 3.0. but it's no biggie to create your own grid of KeyPoints:

int step = 10; // 10 pixels spacing between kp's

vector<KeyPoint> kps;
for (int i=step; i<img.rows-step; i+=step)
{
    for (int j=step; j<img.cols-step; j+=step)
    {
        // x,y,radius
        kps.push_back(KeyPoint(float(j), float(i), float(step)));
    }
}

Ptr<xfeatures2d::SIFT> sift = xfeatures2d::SIFT::create();
sift->compute(img,kps,features);
edit flag offensive delete link more

Comments

where you have define the "features" variable in statement...sift->compute(img,kps,features);

msiraj83 gravatar imagemsiraj83 ( 2016-01-20 20:35:57 -0500 )edit

it is just a cv::Mat.

berak gravatar imageberak ( 2016-01-20 23:52:09 -0500 )edit

Thanks a lot...

msiraj83 gravatar imagemsiraj83 ( 2016-01-21 00:52:33 -0500 )edit

@berak Why are you using KeyPoint(float(j), float(i), float(step))? Shouldn't be KeyPoint(float(i), float(j), float(step)) (inverting i and j)?

lovaj gravatar imagelovaj ( 2017-03-06 09:42:03 -0500 )edit

it's KeyPoint(x,y,radius,...) , no ? why do you think, it needs inversion ?

berak gravatar imageberak ( 2017-03-06 09:51:39 -0500 )edit

Oh geez, I'm so dumb. Could you please give a look at this?

lovaj gravatar imagelovaj ( 2017-03-06 16:27:41 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-10-14 04:10:47 -0500

Seen: 2,910 times

Last updated: Oct 14 '15