Search code examples
opencvaffinetransformopencv3.0

how inverse an cv::Affine3d transformation


I use opencv 3.0.

I use a cv::Affine3d declared like this:

cv::Vec3d om = ...;
cv::Vec3d T = ...;
cv::Affine3d aff(om, T);

Then I use aff to transform X into Y like this:

cv::Vec3d X;
cv::Vec3d Y = aff*X;

Now, I would like do the inverse transformation to transform Y into X?


Solution

  • I would assume that

    cv::Affine3d affInverse = aff.inv(); // Calls inv() on the internal matrix
                                         // and returns a new object from that.
    
    cv::Vec3d xPrime = affInverse * Y;
    

    does the trick. See the header you mentioned for more information.

    Also, the documentation should provide some more information about the Matx stored in Affine3d.

    Hope that helps!