1

我想使用 LSH 来加快搜索速度,我在 opencv 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::Exception' what() 实例后调用:/home/vampire/ opencv-2.4.8/modules/flann/src/miniflann.cpp:315:错误:(-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));

我也尝试转换为其他类型,没有人工作,有人知道怎么做吗?在我得到结果后,我怎么知道它是否匹配?

4

1 回答 1

0

试一下。我想我有同样的错误,我的工作有一个额外的参数:

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

在 cvflann 中还有其他类似的cvflann::FLANN_DIST_EUCLIDEAN

于 2014-05-02T13:06:21.330 回答