I found contours on two images with same object and I want to find displacement and rotation of this object. I've tried with rotated bounding boxes of this contours and then its angles and center points but rotations of bounding boxes don't tell about contour rotation correctly because it's the same for angles a+0, a+90, a+180 etc. degrees. Is it any other good way to find rotation and displacement of contours? Maybe some use of convex hull, convexity defects? I've read in Learning OpenCv about matching contours but it hasn't helped. Could someone give some example?
I want to detect for example pink square, and in the second case pen. Other examples could be squares with some holes, stars etc. As I said I want to make some uniwersal thing. Any suggestions are appreciated because I want to test as many methods as it's possible.