Ask Your Question
0

How to know if findHomography + warpPerspective will give good result beforehand?

asked 2013-05-05 07:50:49 -0600

Dirhem gravatar image

I am trying to align some photos by using findHomography + warpPerspective which works great on most of photos. However for some photos it gives really distorted result or entirely washed out with gray color results. So i want to eliminate these photos beforehand and i won't apply warpPerspective to them. My question is how can i examine the result of findHomography so i can skip the warpPerspective if it is going to give me entirely distorted result.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-05-05 12:37:07 -0600

Guanta gravatar image

You can use the output-mask of findHomography (if you use RANSAC or LMEDS). Afaik the output-mask gives you a mask of inliers/outliers, so count the number of inliers and if they are high enough -> accept otherwise reject the image.

If this ain't working good enough, maybe because you have many differences in the number of inliers than you need to try to add some other verification steps (I assume you're using a feature-matching approach):

  • keep only strong features (cv::KeyPointsFilter::retainBest())
  • Improve your matching by applying cross-check / ratio-check, see http://answers.opencv.org/question/15/how-to-get-good-matches-from-the-orb-feature/
  • Reject them at the end (this depends much on your image content): Warp the 2nd image according to the homography matrix (as you already do it), now apply cross-correlation between the 1st and the warped 2nd image and see how good your cross-correlation is (the cc-map should contain an area of high values when your homography matrix was correct).
edit flag offensive delete link more

Comments

Thanks for your answer, i should have explained that this is an android app and i am trying to align photos that have taken by users and most likely these photos will have some person in it and this person will be changed position in these photos. So this app works fine on most of photos but when it comes to photos that background is some kind of solid color and only person in the images has key points then the result of align gets really distorted. I have tried to filter out matches with actual distances but it still gets some false matches from person in the photo. This is why i am trying to examine the homography matrix and be sure if the images will be aligned.

Dirhem gravatar imageDirhem ( 2013-05-07 14:21:47 -0600 )edit
1

So, your matches get distorted by the persons. Do you have any constraints that the persons are only at one side of the image? Otherwise it's kinda difficult and the only idea I have is to detect the persons first (e.g. using CascadeClassifier) and mask the detected areas and then compute the keypoints/features only from the non-masked areas.

Guanta gravatar imageGuanta ( 2013-05-14 03:28:46 -0600 )edit

Question Tools

Stats

Asked: 2013-05-05 07:50:49 -0600

Seen: 2,696 times

Last updated: May 05 '13