I'm trying to recognize an object in an image from a previously stored contour of the same object.
Having had immense trouble with feature detection (my objects don't seem to have any features, at least not all of them), I've gotten much better results with the matchShapes() function, which apparently uses Hu moments.
When I have found my matching shape, I get its rotation from comparing its major axis with the x axis, according to this answer: Find the orientation of an image
However, this gives only a rotation between -90 and 90 degrees.
I need to know if the object is rotated 180 degrees or not.
I have provided some images to further illustrate my issue:
The above two images show roughly the same angle, when they should be 180 degrees apart. Is there any obvious way of calculating their full rotation? Am I missing something here? I've tried a few hacky methods, but none of them are reliable enough.
Any help or suggestions would be greatly appreciated. Thanks!