Search code examples
opencvimage-processingcomputer-visionhomography

How to find homography between two simple shapes?


I have two drawn images of the same relatively simple shape, but those images were drawn slightly different and may also be rotated, scaled, etc.

I want to find the homography I have to apply to image A to get (approximately) image B.

Take these two images as an example:

example pictures

I want to find the homography that warps image A so that it approximately resembles image B. It does not have to be perfect, but as accurate as possible obviously.

I already tried to find the homography in openCV following this tutorial, but this doesn't seem to work really, supposedly because the SURF keypoints are not matching, because there are no really unique points in those images (?).

Could someone point me in the right direction what to look for to solve this problem? I'm not super familiar with computer vision techniques, and while this tutorial worked for real images, it doesn't seem to be appropriate for my use case.

Any help appreciated.


Solution

  • Answering my own question after randomly stumbling about some keywords while further researching.

    Keywords for searching for such problems are shape matching or contour matching.

    For my specific problem I used this implementation with some minor modification for my use case. Other sources to start getting into the problem would be Shape Matching using Hu Moments or OpenCV Shape Distance and Matching.