1 answer

I see nothing obvious wrong with your code RANSAC tries to find an homography given a set of matches, and use a probalistic algorihm, sometimes it gives bad homographies, you need reject them and retry... (see "good result or bad result for findHomography" post).