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 :
findHomography()
in as input to this decomposition module and expect the correct output? Or is there something I am missing? 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.
Zhang's calibration procedure will produce a rotation matrix. That's representable as 3 (Euler) angles, not one. Or, equivalently (via Rodriguez's formula), as one unit vector and an angle of rotation about that vector - ie three numbers again.
Unless your camera and target are very carefully positioned with respect to each other, there is no reason to expect that there be just one non-zero angle of rotation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.