Ask Your Question
0

"Bounding" possible homography (findHomography)

asked 2014-11-14 09:48:13 -0500

Doombot gravatar image

updated 2014-11-14 12:47:29 -0500

I wonder if you know a way to efficiently bound the possible homography given by findHomography().

To simplify the question, just imagine that a camera is in front of a wall with many posters and I need to find a specific poster. So the main variation between the flat model and the poster on the wall is the perspective distortion form the camera for objects on the side and maybe that the camera is a little unstable (robot, head-mounted à la gopro, etc.) so again the perspective would change a little bit but not that much.

Right now, for testing and dev purpose I use rectangular objects like the posters of the previous example. I apply the perspectiveTransform() function to find the position of the four corners of the detected object. It allows me to display the outlines. Then, with some mumbo-jumbo code, I check if the angle between the lines is within a range (say 70 to 110 deg). This allow me to bound the possible homography but this is more a patch than a solution.

Actually, maybe using the homography is not necessary at all. In then end, what I need is to find the location of the poster. I use the homography because it takes all the pruned matches and, with RANSAC, only keeps the inliers (outliers will be present because there are relatively similar posters on the wall) and indirectly shows the location of the keypoints that are really part of the model image. To me, showing the outlines of the found poster is only an (albeit useful) diagnostic tool. So, as a bonus, if someone knows an alternate (and fast, this is real-time after all) method to extract the location of the object from a vector of DMatch, I am open to suggestions!

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2014-11-15 09:28:05 -0500

updated 2014-11-24 17:01:13 -0500

With video there are some 'tricks' you can apply to reduce the computation and improve the quality of the homography. Use the target location (found via the homography) from the previous frame to mask (black out everything but) the target in the current camera image. After doing this, no (or very few) keypoints will be generated off target. Warp the current frame with the homography of the previous frame to only compute upright and planar frontal features (upright features mean you do not need to compute an orientation and they will be more discriminating because of it). Recompute scaled target keypoints not every frame, but after maybe a 5% linear size change (or do this offline at various scales if your targets are unchanging). You can even mask the target images to reduce keypoint matching time. Obvious outliers can be rejected quite easily as true matches will be warped (using the previous homography) to a location almost on top of the location you expect them to be (within some small distance), provided the last frame was a success. This all makes for very efficient tracking and pose estimation (recovery is another story). Homography estimation via RANSAC is very fast when there are few ouliers, but it gets exponentially slower as outliers increase in number. The scheme described here reduces the matches to almost all inliers. In the video, the computation time varies, but on an i7-3770, the total processing time is typically below 10ms, even using some of the more processing intensive sub-routines. Outlier rejection is not visualized in the video, but it does occur prior to homography estimation. There are direct methods for computing the homography and the fundamental matrix from two images, but they are not yet a part of OpenCV.

https://www.youtube.com/watch?v=Hnn-uZPdJIY

edit flag offensive delete link more

Comments

Thanks! I might not have the time to delve into it for a moment but this is interesting!

Doombot gravatar imageDoombot ( 2014-11-18 07:16:01 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-11-14 09:48:13 -0500

Seen: 575 times

Last updated: Nov 24 '14