Store entries of vector<Point2d> as columns in eigen3 matrix

asked 2017-06-03 07:56:42 -0600

Hello guys,

I'm fairly new to OpenCV and working with C++ in general, so I'm sorry if this seems trivial. The work I've already done is mostly the stuff covered in this tutorial:

http://docs.opencv.org/2.4/doc/tutori...

Now, I have a vector of Point2d, as generated in the Tutorial

      //-- Localize the object
  std::vector<Point2f> obj;
  std::vector<Point2f> scene;

  for( int i = 0; i < good_matches.size(); i++ )
  {
    //-- Get the keypoints from the good matches
    obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
    scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
  }

Now, what I want to do is store these Points in a matrix given by the eigen3 Package for Bundle Adjustment. So I have initialised two matrices

void BundleAdjustment::feedMatches(const ImagePair& epair)
{
    // 2 x m eigen3 matrices storing P_i, P_j from vector<Point2d> format
    MatrixXd eP_i = MatrixXd(2, epair.P_i.size());
    MatrixXd eP_j = MatrixXd(2, epair.P_j.size());

So now, what I want to do, is take the two points I have in every entry of obj or scene and put them in the columns of the matrices eP_i and eP_j. How would I do that? Since the entries are of the type Point2d and not tupels of numbers, I cant seem to get the compiler to accept it. And I cant seem to recast it to another type either.

Any help would be appreciated!

edit retag flag offensive close merge delete

Comments

may be these lines can solve your problem

What is your platform and compiler?

LBerger gravatar imageLBerger ( 2017-06-03 08:15:36 -0600 )edit