Ask Your Question
1

Can you limit the number of Keypoints using sift feature detector?

asked 2017-01-30 17:01:07 -0500

soh gravatar image

updated 2017-02-01 11:21:21 -0500

berak gravatar image

Is it possible to limit the number of key points using SIFT or should I use a different type of detector? FeatureDetector featureDetector = FeatureDetector.create(FeatureDetector.SIFT);

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-02-02 10:42:47 -0500

Alemao gravatar image

You can limit the Keypoints if you use ORB detector.

edit flag offensive delete link more
0

answered 2017-01-30 18:19:26 -0500

LBerger gravatar image

updated 2017-02-01 10:24:32 -0500

You cannot set number of key pointsUse first parameter nfeature of create method

    Mat img=imread("f:/lib/opencv/samples/data/lena.jpg",IMREAD_COLOR);
    for (int i=0;i<5;i++)
    {
        Mat desc;
        vector<KeyPoint> p;
        Ptr<xfeatures2d::SIFT> b= xfeatures2d::SIFT::create(i*100);
        b->detectAndCompute(img,Mat(),p,desc);
        cout<< p.size()<<"\t"<<desc.rows<<"\n";
    }
}

Results :

1111    1111 
100     100 
200     200
300     300 
400     400

but you can try too as suggested in doc to reduce keypoint number:

  1. increase contrastThreshold
  2. increase sigma
  3. decrease edge threshold
edit flag offensive delete link more

Comments

@LBerger, the nfeatures does exactly what you want. It retains the x-best scoring keypoints, so limit that and then you can limit the number of keypoints right?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-01 02:52:25 -0500 )edit

@StevenPuttemans I must check my program because I haven't got this behaviour using nfeatures parameter

LBerger gravatar imageLBerger ( 2017-02-01 03:22:24 -0500 )edit

This that possible with Java ?

soh gravatar imagesoh ( 2017-02-01 11:01:23 -0500 )edit

@soh, sadly, not so. (well, not directly)

what you can try is: save() your Featuredetector to disk (once), then edit the xml file, and load() it back each time you use it. less than ideal, i know ;(

berak gravatar imageberak ( 2017-02-01 11:21:06 -0500 )edit

Would it be possible to take the best 300 key points?

soh gravatar imagesoh ( 2017-02-01 11:30:26 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-30 17:01:07 -0500

Seen: 1,622 times

Last updated: Feb 02 '17