我正在使用openCV FastFeatureDetector从图像中提取快速关键点
但FastFeatureDetector检测的数量不是常数
我想设置最大关键点数FastFeatureDetector得到。
我可以指定使用openCV FastFeatureDetector时获得的FAST关键点数
怎么样?
答案 0 :(得分:0)
我最近遇到了这个问题,经过短暂的搜索后,我发现DynamicAdaptedFeatureDetector迭代检测到关键点,直到找到所需的数字。
代码:
int maxKeypoints, minKeypoints;
Ptr<FastAdjuster> adjust = new FastAdjuster();
Ptr<FeatureDetector> detector = new DynamicAdaptedFeatureDetector(adjust,minKeypoints,maxKeypoints,100);
vector<KeyPoint> keypoints;
detector->detect(image, keypoints);
答案 1 :(得分:0)
我提供代码的主要部分,在这种情况下,您可以将关键点的数量设置为您所期望的。祝你好运。
# define MAX_FEATURE 500 // specify maximum expected feature size
string detectorType = "FAST";
string descriptorType = "SIFT";
detector = FeatureDetector::create(detectorType);
extractor = DescriptorExtractor::create(descriptorType);
Mat descriptors;
vector<KeyPoint> keypoints;
detector->detect(img, keypoints);
if( keypoints.size() > MAX_FEATURE )
{
cout << " [INFO] key-point 1 size: " << keypoints.size() << endl;
KeyPointsFilter::retainBest(keypoints, MAX_FEATURE);
}
cout << " [INFO] key-point 2 size: " << keypoints.size() << endl;
extractor->compute(img, keypoints, descriptors);
答案 2 :(得分:0)