I have used this code as a basis to detect my rectangular target in a scene. I use ORB and Flann Matcher. I have been able to draw the bounding box of the detected target in my scene successfully using the findHomography()
and perspectiveTransform()
functions.
The reference image (img_object
in the above code) is a straight view of only the rectangular target. Now the target in my scene image may be tilted forwards or backwards. I want to find out the angle by which it has been tilted. I have read various posts and came to the conclusion that the homography returned by findHomography()
can be decomposed to the rotation matrix and translation vector.
I have used code from https:/gist.github.com/inspirit/740979 recommended by this link translated to C++. This is the Zhang SVD decomposition code got from the camera calibration module of OpenCV. I got the complete explanation of this decomposition code from O'Reilly's Learning OpenCV book.
My questions are :
- Am I correct in assuming that the decomposed rotation matrix I get will tell me the angle at which my target has been tilted?
- Secondly can I use the Homography obtained from
findHomography()
in as input to this decomposition module and expect the correct output? Or is there something I am missing? - Is there any other way I can achieve the same?
Lastly, I am coding on a mobile platform so I am concerned about the performance too. I would be glad if you can point me in the right direction.
Thanks in advance for your time and replies.