changeset 545:9816fab353f3

added function to undistort image, mostly for checking camera calibration results
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 08 Jul 2014 15:51:43 -0400
parents 749672171789
children b5525249eda1
files python/cvutils.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/python/cvutils.py	Tue Jul 08 15:32:47 2014 -0400
+++ b/python/cvutils.py	Tue Jul 08 15:51:43 2014 -0400
@@ -394,6 +394,14 @@
         savetxt('intrinsic-camera.txt', camera_matrix)
         return camera_matrix, dist_coeffs
 
+    def undistortImage(img, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1., interpolation=cv2.INTER_LINEAR):
+        '''Undistorts the image passed in argument'''
+        width = img.shape[1]
+        height = img.shape[0]
+        [map1, map2] = computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients)
+        return cv2.remap(img, map1, map2, interpolation=interpolation)
+
+
 def printCvMat(cvmat, out = stdout):
     '''Prints the cvmat to out'''
     print('Deprecated, use new interface')