-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Closed
Labels
Description
System information (version)
- OpenCV => 3.4.1.15
- Operating System / Platform => Ubuntu 16.04 64 Bit
- Compiler: Unknown -- I'm using the standard
pip install opencv-pythonPython binding. - Python => 3.6.6
- numpy => 1.14.2
Detailed description
I'm using the python3 binding. I couldn't find anywhere Python-specific to report this bug, so I opted to report it here.
getPerspectiveTransform and findHomography should both give the same correct result when given 4 coordinate pairs. But when testing with my data, findHomography returns a correct homography matrix, but getPerspectiveTransform returns a completely different (and incorrect) matrix.
Steps to reproduce
import cv2
import numpy as np
utm = np.float32([[ 396388.56, 5782566. ],
[ 396477. , 5782564. ],
[ 396475. , 5782467.5 ],
[ 396386.56 ,5782469.5 ]])
px = np.float32([[ 0. , 0.],
[22992. , 0.],
[22992., 25095.],
[ 0., 25095.]])
print(str(cv2.getPerspectiveTransform(utm,px)))
# This one is incorrect.
# array([[-2.03567784e-03, 1.39543393e-04, -2.06672399e-11],
# [-9.74034793e-05, 6.67847650e-06, 3.51683667e-10],
# [-1.20329423e-08, -1.72111512e-07, 1.00000000e+00]])
print(str(cv2.findHomography(utm, px)))
# This one is correct.
# (array([[ 2.59858416e+02, -5.38566665e+00, -7.18619311e+07],
# [-5.87827526e+00, -2.59929984e+02, 1.50539237e+09],
# [ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]), array([[1],
# [1],
# [1],
# [1]], dtype=uint8))Reactions are currently unavailable