0

For an openCV project, I need to find a "perfect" homography from descriptor matching. I pushed paramters : many corners, retroprojection threshold very low...

It's close but I need almost pixel perfect homography.

I name marker the image I'm looking for, query the image which contains the marker.

My idea was to refine the 4 corner positions of the marker in query image. And then recalculate homography from these refined 4 corners.

I was thinking of using hough to detect line intersections. So I get corners which are indeed good candidates.

Now I need a score function to assess which of these candidates is the "best". Here what I tried

1/ - let's call H an homogrphy - test = query + H*marker. So if my homography was "pefect", test would be identical to query (but for shadows...).

2/ Then I calculate the "difference" naively like below. I sum the absolute difference and then divide by the area (otherwise the smaller, the better). Not reliable... I gave more weight to the sums and still fails.

It really seemed a good idea to me but it's an epic fail for now: the difference does not help find the "better" corners. Any idea ?

Thank you very much,

Michaël

def diffImageScore(testImage,workingImage, queryPersp):
height,width,d = testImage.shape
height2,width2,d2 = workingImage.shape
area=quadrilatereArea(queryPersp)*1.0
score=0
height, width, depth = testImage.shape
img1Gray= cv2.cvtColor(cv2.blur(testImage,(3,3)), cv2.COLOR_BGR2GRAY)
img2Gray= cv2.cvtColor(cv2.blur(workingImage,(3,3)), cv2.COLOR_BGR2GRAY)
for i in range(0, height): 
    for j in range(0, width):
        s1=abs(int(img1Gray[i,j]) -int(img2Gray[i,j] )) 
        s1=pow(s1,3)
        score+=s1
return score/area
  • Lots of good leads in this SO thread : https://stackoverflow.com/questions/189943/how-can-i-quantify-difference-between-two-images – Ben Feb 05 '18 at 10:42
  • If those are not OK (depending on your input images), maybe look at Mutual Information – Ben Feb 05 '18 at 10:44
  • yes, thanks. It works "nicely". It was a bad bug elsewhere. So what I do : I calculate precise the homography then I move the 4 corners of the transformed query image, recalculate the homography on 4 matches, check the score and... – Quai DesApps Feb 09 '18 at 13:55

0 Answers0