I am playing with the affine transform in OpenCV and I am having trouble getting an intuitive understanding of it workings, and more specifically, just how do I specify the
Here is a mathematical explanation of affine transform: this is a matrix of size 3x3 that applies the foolowing transformations on 2D vector: Scale in X axis, scaleY, rotation, skew, translation in x axis and y. These are 6 transformations and thus you have six elements in your 3x3 matrix. The bottom row is always [0 0 1]. Why? because the bottom row represents the a perspective transformation in axis x and y, and affine transformation does not include perspective transform. (If you want to apply perspective warping use homography: also 3x3 matrix )
What is the relation between 6 values you insert into affine matrix and the 6 transformation it does? Let us look at this 3x3 matrix like
e*Zx*cos(a), -q1*sin(a) , dx,
e*q2*sin(a), Z y*cos(a), dy,
0 , 0 , 1
The above explanation is mathematical. It assumes you multiply the matrix by column vector from the right. As far as I remember, Matlab uses reverse multiplication (row vector from the left) so you will need to transpose this matrix. I am pretty sure that openCV uses regular multiplication but you need to check it. Just enter only translation matrix (x shifted by 10 pixels, y by 1).
1,0,10
0,1,1
0,0,1
If you see a normal shift than everything is OK, but If shit appears than transpose the matrix to:
1,0,0
0,1,0
10,1,1