How to obtain correct homography values?

asked 2019-12-02 09:25:42 -0600

faghjezu gravatar image

updated 2019-12-02 10:42:39 -0600

I have 2 images and trying to find homography. For this I use findHomography function. Below is the code

im_src = cv2.imread('img1.jpg') 
pts_src = np.array([[1174,457], [1226, 410], [1278, 363],[1331, 315]]) 

im_dst = cv2.imread('img2.jpg')
pts_dst = np.array([[1118, 677],[1167, 640],[1216, 603],[1266, 566]])

h, status = cv2.findHomography(pts_src, pts_dst)
print(h)

The problem is that gives negative values. My H is:

[[ 1.10477291e+00 1.07314763e-01 -4.94501089e+01] [ 6.79069481e-03 1.37522045e+00 -4.52332274e+02] [-4.34205991e-06 1.11550429e-04 1.00000000e+00]]

I tried CV_RANSAC with different parameters, but it still gives negative values.
So my question is how can I obtain correct H values?

edit retag flag offensive close merge delete

Comments

1

Your H values is accurately. Mostly, will get negatives too.

H, _ = cv2.findHomography(src, dst, method=cv2.RANSAC, ransacReprojThreshold=3.0)
supra56 gravatar imagesupra56 ( 2019-12-02 12:03:15 -0600 )edit

RANSAC gives the same values

faghjezu gravatar imagefaghjezu ( 2019-12-02 12:47:29 -0600 )edit

why do you think, negative (position) values are incorrect ?

berak gravatar imageberak ( 2019-12-02 12:57:57 -0600 )edit

Well there are possibilities to check if it's ok or not. For example using warpPerspective.

faghjezu gravatar imagefaghjezu ( 2019-12-02 13:34:10 -0600 )edit