How can I detect the rotation angle from a perspective matrix?
I wrote this code ,but the resulted angle doesn’t exceed 40 …
Mat mmat;
mmat.create(3,3,CV_32FC1);
mmat=getPerspectiveTransform(templPoints,imgPoints);
cout<< mmat<<endl<<endl;
float angle=acos(mmat.at<double>(0,0));
angle=(angle*180)/3.14;
cout<<"angle is"<<angle<<endl;
getPerspectiveTransform returns an homography matrix which can be decomposed like this:
[R11,R12,T1]
[R21,R22,T2]
[ P , P , 1]
R represents a rotation matrix, T represents a translation, and P represents a perspective warp.
More info on what rotation matrix represents:
http://en.wikipedia.org/wiki/Rotation_matrix
http://mathworld.wolfram.com/RotationMatrix.html