2014-01-13 32 views
0

我想使用LSH來加速搜索,並且我發現在opencv flann中可以通過使用LshIndexParams來做到這一點?問題是我無法獲得正確的格式。我用袋子的話來產生一個 席子輸出並且餵它flann,但我總是得到錯誤。使用LshIndexParams,flann索引需要什麼類型的數據?

OpenCV Error: Unsupported format or combination of formats (type=2 

)在buildIndex_,文件/home/vampire/opencv-2.4.8/modules/flann/src/miniflann.cpp,線315 拋出 'CV ::例外' 的一個實例後終止叫what():/home/vampire/opencv-2.4.8/modules/flann/src/miniflann.cpp:315:error:(-210)type = 2 in function buildIndex_

部分代碼喜歡此內容:

Mat img_BOWdescriptor=BOW_descriptors(path); 
cout<<img_BOWdescriptor<<endl; 
img_BOWdescriptor.convertTo(img_BOWdescriptor,img_BOWdescriptor.rows,img_BOWdescriptor.cols,CV_32F); 
cout<<img_BOWdescriptor<<endl; 
cout<<"done"<<endl; 

cout<<"ini flann index......"<<endl; 
Mat indices = Mat(img_BOWdescriptor.rows, 1, CV_32S); 
Mat dist = Mat(img_BOWdescriptor.rows, 1, CV_32F); 
descriptors_all.convertTo(descriptors_all,descriptors_all.rows,descriptors_all.cols,CV_32F); 

flann::Index* flann_index=new flann::Index(descriptors_all,flann::LshIndexParams(20,10,2)); 
cout<<"done"<<endl; 
double t=(double)getTickCount(); 

cout<<"flann matching......"<<endl; 
flann_index->knnSearch(img_BOWdescriptor, indices, dist, 1,flann::SearchParams(32)); 

我還試圖轉換爲其他類型,沒有人工作,有人知道如何去做嗎? 和我得到結果後,我怎麼知道它是否匹配?

+0

得到同樣的問題,是你的,你有解決辦法?文件/Users/alexandershishkov/Downloads/opencv-2.4.8/modules/flann/src/miniflann.cpp,第315行 – Jing

+0

也許向量必須是二進制的嗎?不支持的格式或格式組合(type = 0 ) – mrgloom

回答

0

試試看。我覺得我有同樣的錯誤,防雷工程同一個額外的參數:

cv::flann::Index kVecinos(descriptors, cv::flann::LshIndexParams(12, 20, 2), cvflann::FLANN_DIST_HAMMING); 

在cvflann也有其他類似cvflann::FLANN_DIST_EUCLIDEAN

相關問題