Question

I am using the SURF algorithm for comparing landmarks between objects, and am wondering how to detect the rotation angle between the two pictures. I have already seen the another question very similar. This question was turned down for being a naive way to achieve the results. But the results are still achievable through this method.

So my question remains, how can you detect the difference in angle orientation between two images using OpenCV's SURF algorithm (C++ please).

The code i am using can be found from opencv tutorial pages.

Was it helpful?

Solution

I think, once you get homography matrix H, you can decompose it into its components matrixes: translation, rotation and scale. Here is an example

I suggest you to read this useful tutorial: https://math.stackexchange.com/questions/78137/decomposition-of-a-nonsquare-affine-matrix

OTHER TIPS

This is how I did using EmguCv (.NET wrapper to OpenCV) & C#.

Once you get the homography matrix you can get the rotation angle using RotatedRect object.

System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Point.Empty, modelImage.Size);
PointF[] pts = new PointF[]
{
  new PointF(rect.Left, rect.Bottom),
  new PointF(rect.Right, rect.Bottom),
  new PointF(rect.Right, rect.Top),
  new PointF(rect.Left, rect.Top)
};

pts = CvInvoke.PerspectiveTransform(pts, homography);

RotatedRect IdentifiedImage = CvInvoke.MinAreaRect(pts);
result.RotationAngle = IdentifiedImage.Angle;

You can convert above code in C++.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top