Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why KeyPointsFilter::retainBest does keep the size of the vector?

I have written the following code:

cv::Ptr< cv::FeatureDetector > detector = cv::FeatureDetector::create("PyramidGFTT");
std::vector< cv::KeyPoint > keypoints;
detector->detect(img, keypoints);
std::cout << "detected: " << keypoints.size() << std::endl;

cv::Mat img2;
cv::drawKeypoints(img, keypoints, img2);
cv::imshow("detection", img2);

cv::KeyPointsFilter::retainBest(keypoints, 20);
std::cout << "retained: " << keypoints.size() << std::endl;
cv::Mat img3;
cv::drawKeypoints(img, keypoints, img3);
cv::imshow("best", img3);

And there is no difference after the KeyPointsFilter::retainBest. It always show all the points, and more the size of the vector is not changed. Is this correct? Am I doing something wrong? Is it just keeping on the first N positions the best keypoints?