Fixed Size Matrix Conversions

asked 2012-12-05 03:57:34 -0600

Adi gravatar image

updated 2012-12-05 04:01:17 -0600

This does not compile:

   cv::Matx33f M3x3;
   cv::Vec3f   v3x1 = M3x3.col(0); // compile error
   cv::Matx31f m3x1 = M3x3.col(0); // this is ok

with error (on VS2008):

error C2440: 'initializing' : cannot convert from 'cv::Matx<_Tp,m,n>' to 'cv::Vec<_Tp,cn>'
No constructor could take the source type, or constructor overload resolution was ambiguous

That's because although Vec3f derived from Matx31f there is no proper constructor that allows this to happen.
So 2 questions:

  1. What would be the cleanest way to make this assignment.
  2. Why not add such a constructor?
    I guess it would also have to accept this: cv::Vec3f v3x1 = M3x3.row(0);.
edit retag flag offensive close merge delete