1
votes

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 :

  1. Am I correct in assuming that the decomposed rotation matrix I get will tell me the angle at which my target has been tilted?
  2. 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?
  3. 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.

1
why dont you create your own homography with known parameters (scale, translation and rotation and perspective parameters) and try the decomposition on such a matrix? you will see whether the correct parameters will be extracted.Micka
the problem is not with the homography decomposition..am fairly sure that is working properly.what i want to know is in my case,can i give the homography returned by findHomography() after applying the ORB detection to this module?Will the rotation matrix give me the angle at which my target is rotated?user2958957

1 Answers

0
votes

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 - i.e. 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.