关于角点匹配,角点检测后产生描述子后使用KNN匹配时的错误:

    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_

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值