2014-04-08 54 views
0

我想在C++中使用OpenCV庫實現BOW。我已提取的圖像的關鍵點與SIFT方法是這樣的(對於每個圖像):OpenCV弓 - 太高的直方圖值

featureDetector->detect(image, keypoints); 
descriptorExtractor->compute(image, keypoints, descriptors); 
bowTrainer.add(descriptors); 

然後詞彙訓練用bowTrainer.cluster()並存儲到BOWImgDescriptorExtractor bowDE。在存儲詞彙後,我希望看到至少一張圖像。這是實現這樣

featureDetector->detect(image, keypoints); 
bowDE->compute(image, keypoints, histogram); 
for (int i = 0; i < histogram.cols; i++) 
    cout << histogram.at<unsigned>(0, i) << ","; 

而結果有1一行k列(k從k均值)值要麼0或周圍980000000 ......我不認爲這是正確的,請告訴我,我是什麼做錯了。當我想要顯示圖時,這看起來非常糟糕。

回答

0

差點忘了......解決方案非常簡單。行:

cout << histogram.at<unsigned>(0, i) << ","; 

了,因爲產生的直方圖是標準化直方圖改爲

cout << histogram.at<float>(0, i) << ","; 

。更詳細的答案見OpenCV forum answer