Mercurial Hosting > traffic-intelligence
diff python/tests/cvutils.txt @ 933:8ac7f61c6e4f
major rework of homography calibration, no in ideal points if correcting for distortion
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 14 Jul 2017 02:11:21 -0400 |
parents | 66f382852e61 |
children |
line wrap: on
line diff
--- a/python/tests/cvutils.txt Fri Jul 14 00:12:03 2017 -0400 +++ b/python/tests/cvutils.txt Fri Jul 14 02:11:21 2017 -0400 @@ -6,7 +6,7 @@ >>> intrinsicCameraMatrix = array([[ 377.42, 0. , 639.12], [ 0. , 378.43, 490.2 ], [ 0. , 0. , 1. ]]) >>> distortionCoefficients = array([-0.11759321, 0.0148536, 0.00030756, -0.00020578, -0.00091816])# distortionCoefficients = array([-0.11759321, 0., 0., 0., 0.]) >>> multiplicationFactor = 1.31 ->>> [map1, map2] = cvutils.computeUndistortMaps(width, height, multiplicationFactor, intrinsicCameraMatrix, distortionCoefficients) +>>> [map1, map2], tmp = cvutils.computeUndistortMaps(width, height, multiplicationFactor, intrinsicCameraMatrix, distortionCoefficients) >>> undistorted = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) >>> (undistorted.shape == array([int(round(height*multiplicationFactor)), int(round(width*multiplicationFactor)), 3])).all() True @@ -26,6 +26,11 @@ >>> (reducedPoints == reducedPoints).all() True +>>> undistortedPoints2 = cv2.undistortPoints(imgPoints, intrinsicCameraMatrix, distortionCoefficients).reshape(-1, 2) # undistort and project as if seen by new camera +>>> undistortedPoints2 = cvutils.newCameraProject(undistortedPoints2.T, newCameraMatrix) +>>> (undistortedPoints == undistortedPoints2.T).all() +True + >>> undistortedPoints = cv2.undistortPoints(imgPoints, intrinsicCameraMatrix, distortionCoefficients).reshape(-1, 2) # undistort to ideal points >>> origPoints = cvutils.worldToImageProject(undistortedPoints.T, intrinsicCameraMatrix, distortionCoefficients).T >>> (round(origPoints[1:,:]) == imgPoints[0][1:,:]).all()