Homography estimation when feature matching fails

asked 2019-10-17 13:43:31 -0500

WillTho gravatar image

Hi all,

I'm pretty new to openCV and CV in general. I want to align images of football pitches to a basic template of the pitch. I've managed to find a reasonable way of processing the full pitch images to leave me with pretty much just the pitch markings and I now have what appears to be a fairly straightforward registration problem.

I can't get it to work. I've tried orb and akaze feature matching but it doesn't work at all. Both pick up good features (mostly the curved portions like the centre circle and the D) but the matching is awful. I was using brute force matching with Hamming distance and then selecting say the top 10% of matches to estimate the homography.

What's the best approach here? I was thinking I could use a hough transform to find the centre circle in each image and match those, but the full centre circle won't always be in the target image.

Here are two example images:

Pitch template:

Reference Image

Processed image to align:

Target Image

edit retag flag offensive close merge delete

Comments

why does it fail ? don't make it so. most 2d features expect gradients and won't work on binary images. (ill-fated preprocessing)

berak gravatar imageberak ( 2019-10-17 13:51:18 -0500 )edit

and I now have what appears to be a fairly straightforward registration problem.

to a naive human, not a machine.

berak gravatar imageberak ( 2019-10-17 13:52:25 -0500 )edit

all feature2d algorithms have to look at the pixel neighbourhood of a keypoint. look at your images -- it's all zero

berak gravatar imageberak ( 2019-10-17 13:55:12 -0500 )edit
1

Thanks for taking a look! No other way using ellipse/line detection? Or a regression approach where I try to minimise the l1 norm between the images or something? Feels like there must be algorithms for registering binary images...

WillTho gravatar imageWillTho ( 2019-10-17 15:08:32 -0500 )edit

you probably could even mark the 4 points for the transformation manually.

berak gravatar imageberak ( 2019-10-17 23:51:19 -0500 )edit

I can, but I need to do this for quite a few frames so I need something automatic really. I wouldn't mind manually selecting points for the first frame and then using a sensible way to update the homography matrix from frame to frame, maybe some sort of small-motion regularisation? I don't know the names of these algorithms or how to do them in opencv, but they must be pretty common right? I just don't want to end up writing my own code to do something I can do more computationally efficiently in 1 or two lines of opencv...

WillTho gravatar imageWillTho ( 2019-10-18 03:54:16 -0500 )edit