MLESAC代替RANSAC与OpenCV

时间:2014-05-03 21:05:10

标签: c++ opencv sift

有没有可用的代码使用MLESAC代替RANSAC和OpenCV来查找已知对象?

MLESAC应该比RANSAC强大得多。这里提供了一个使用示例:

http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html

enter image description here

1 个答案:

答案 0 :(得分:3)

您可以使用PCL库中的MLESAC(以及PROSAC等)。 http://docs.pointclouds.org/trunk/a02954.html 我不使用PCL,所以无法举例。

我正在使用Karel Lebeda的{LO-RANSAC http://cmp.felk.cvut.cz/software/LO-RANSAC/index.xhtml

int do_lo = 1; //local optimization
unsigned int tent_size = tentatives.size();
double err_threshold = 2.0; //in pixels
double confidence = 0.99;
int max_samples = 100000;//max trials
int inl_limit = 0;//no limit
if (tent_size >= 5)
{
  double H[3*3];
  unsigned stats[3];
  double *u2Ptr = new double[tent_size*6], *u2; u2=u2Ptr;
  typedef unsigned char uchar;
  unsigned char *inl2 = new uchar[tent_size];

  for( int i = 0; i < tentatives.size(); i++ )
    {
      *u2Ptr =  keypoints_object[ tentatives[i].queryIdx ].pt.x;
      u2Ptr++;

      *u2Ptr =  keypoints_object[ tentatives[i].queryIdx ].pt.y;
      u2Ptr++;
      *u2Ptr =  1.;
      u2Ptr++;

      *u2Ptr =   keypoints_scene[ tentatives[i].trainIdx ].pt.x;
      u2Ptr++;

      *u2Ptr =   keypoints_scene[ tentatives[i].trainIdx ].pt.y;
      u2Ptr++;
      *u2Ptr =  1.;
      u2Ptr++;
    }
  ransacH(u2, tent_size, err_threshold*err_threshold, confidence, max_samples, do_lo, , H, inl2,stats);
  for(i=0; i < tent_size; i++)
    if (inl2[i])
      inliers.push_back(good_matches[i]);

  delete[] u2; delete[] inl2;