關於角點匹配,角點檢測後產生描述子後使用KNN匹配時的錯誤:
阿新 • • 發佈:2018-11-24
cout<<"型別1: "<<desc1.type()<<endl; desc1.convertTo(desc1, CV_32F); desc2.convertTo(desc2, CV_32F); cout<<"型別2: "<<desc1.type()<<endl; FlannBasedMatcher matcher; vector< DMatch > matches; vector< vector<DMatch> > m_knnMatches; matches.clear(); const float minRatio=1.f / 1.5f; matcher.knnMatch(desc1,desc2,m_knnMatches,2); for (int i=0; i<m_knnMatches.size(); i++) { const DMatch& bestMatch=m_knnMatches[i][0]; const DMatch& betterMatch=m_knnMatches[i][1]; float distanceRatio=bestMatch.distance/betterMatch.distance; if (distanceRatio<minRatio) { matches.push_back(bestMatch); } }
當使用KNN匹配時,注意它的接受的描述子的型別應該為CV_32F,所以需要轉換到所需的型別上。
錯誤為:OpenCV Error: Unsupported format or combination of formats (type=0 ) in buildIndex_, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/flann/src/miniflann.cpp, line 299 terminate called after throwing an instance of ‘cv::Exception’ what(): /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/flann/src/miniflann.cpp:299: error: (-210) type=0 in function buildIndex_