Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get an Affine Transform which has a 3x3 matrix?

Tags:

c++

opencv3.0

The default OpenCV command "getAffineTransform" gives a 2x3 matrix. I would like to know how to get a 3x3 matrix.

like image 855
Manu B.N Avatar asked Nov 27 '25 07:11

Manu B.N


1 Answers

Looking at the OpenCV docs, notice that a 3x3 affine transformation matrix is of the form

r00 r01 tx
r10 r11 ty
  0   0  1

So the last row is always [0 0 1]. Here, r is the rotational part and t is the translational part. A usual trick to save space is to represent affine 3x3 matrices as 2x3 matrices by just forgetting the last row, i.e.

r00 r01 tx
r10 r11 ty

So you just have to append a last row of [0 0 1] to it in order to get your 3x3 matrix.

like image 87
rwols Avatar answered Nov 29 '25 20:11

rwols



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!