How to Invert 3x2 Transformation Matrix

asked 2014-08-13 03:35:28 -0600

pkohout gravatar image

Hi, i am having trouble inveting an 3x2 Transformation Matrix. If my original transformation is rotation with +5°, i want the inverse, which rotation is -5°. Then i want to transform some point with the new inverse Matrix. If I use

    cv::Mat inverse;
    inverse = H.inv(cv::DECOMP_SVD);

I get back a matrxi, but it is 2x3 instead of 3x2, and then i cannt use cv::transform anymore because it gets a SIGABRT.

What am i doing wrong ?

regard Peter

edit retag flag offensive close merge delete

Comments

1

It might be a good idea to add your code with cv::transform also and add the complete error or code line where it occurs in debugging. A SIGABRT is usually called from an abort() function which in code means basically some of the input data is not correctly...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-13 03:40:33 -0600 )edit
1

Also it seems that you can only call the inverse function on squared matrices, see the wikipedia docs here.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-13 03:43:09 -0600 )edit
1

I think you are looking for the function invert, instead of inv. Is that possible? But the behaviour is the MxN becomes NxM ... which is normal for inverting a matrix.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-13 03:44:52 -0600 )edit

So basically I don't think you can simply call an inversion on a matrix to get a inverse transformation matrix.... The solution to your problem after some looking is here, read more about the warpAffine function and the inverse flag. I think this is what you want right?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-13 03:47:06 -0600 )edit
2

@pkohout: Do you really have a 3x2 or actually a 2x3 transformation matrix? A 2x3 matrix you can easily invert using the invertAffineTransform function (http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#invertaffinetransform).

Guanta gravatar imageGuanta ( 2014-08-13 17:06:52 -0600 )edit