0

我正在尝试在opencv中使用flann的LSH实现:

const int mySizes[1]={100};
cv::Mat descriptors1 = cv::Mat::zeros(1,mySizes,CV_32F);
cv::Mat descriptors2 = cv::Mat::zeros(1,mySizes,CV_32F);

cv::Ptr<cv::DescriptorMatcher> matcher_;
matcher_ = new cv::FlannBasedMatcher(new cv::flann::LshIndexParams(20,10,2));
std::vector<cv::DMatch> matches;
matcher_->match(descriptors1, descriptors2, matches);

std::cout << matches[0].distance << std::endl;

更准确地说,我想获得descriptors1descriptors2使用之间的 LSH 距离matches[0].distance

但是当我运行这段代码时,我得到:

OpenCV Error: Unsupported format or combination of formats (type=5
) in buildIndex_, file /home/lpuglia/repository/opencv/modules/flann/src/miniflann.cpp, line 315
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/lpuglia/repository/opencv/modules/flann/src/miniflann.cpp:315: error: (-210) type=5
 in function buildIndex_

代码很简单,我做错了什么?

4

1 回答 1

0

使用了错误的描述符类型,解决方案:

cv::UMat descriptors1 = cv::UMat (1, 100, CV_8UC1);
cv::UMat descriptors2 = cv::UMat (1, 100, CV_8UC1);
于 2017-03-02T12:52:55.120 回答