# HG changeset patch # User Nicolas Saunier # Date 1404849103 14400 # Node ID 9816fab353f3e6af4dd4fa3592f456546434049e # Parent 749672171789f45957088ba2530086ada7013fce added function to undistort image, mostly for checking camera calibration results diff -r 749672171789 -r 9816fab353f3 python/cvutils.py --- 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')