2014-04-01 18 views
1

我使用openCV FastFeatureDetector從圖像中提取快速關鍵點。
但FastFeatureDetector檢測的數量不是常數。
我想設置最大關鍵點數FastFeatureDetector獲得。
我可以指定使用openCV時獲得的FAST關鍵點編號FastFeatureDetector
如何?我可以指定我使用opencv時獲得的FAST關鍵點數FastFeatureDetector

+0

關鍵點的數量取決於圖像。你不能強迫探測器找到沒有的關鍵點。因此,獲得一個固定數字的唯一方法是指定最大輸出點數量,然後保證每個圖像的數量都不止於此。 – System123

回答

0

我最近遇到了這個問題,經過簡短的搜索,我發現DynamicAdaptedFeatureDetector迭代檢測關鍵點,直到找到所需的數字。

檢查:http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html#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); 
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); 
0

另一解決方案是檢測儘可能多的關鍵點儘可能具有低閾值並應用在此描述paper自適應非最大抑制(ANMS)。你可以指定你需要的點數。此外,免費的,你得到你的觀點均勻分佈在圖像上。代碼可以在here找到。

相關問題