Mercurial > hg > nsaunier > traffic-intelligence
comparison python/cvutils.py @ 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 |
comparison
equal
deleted
inserted
replaced
| 544:749672171789 | 545:9816fab353f3 |
|---|---|
| 392 except NameError: | 392 except NameError: |
| 393 return False | 393 return False |
| 394 savetxt('intrinsic-camera.txt', camera_matrix) | 394 savetxt('intrinsic-camera.txt', camera_matrix) |
| 395 return camera_matrix, dist_coeffs | 395 return camera_matrix, dist_coeffs |
| 396 | 396 |
| 397 def undistortImage(img, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1., interpolation=cv2.INTER_LINEAR): | |
| 398 '''Undistorts the image passed in argument''' | |
| 399 width = img.shape[1] | |
| 400 height = img.shape[0] | |
| 401 [map1, map2] = computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) | |
| 402 return cv2.remap(img, map1, map2, interpolation=interpolation) | |
| 403 | |
| 404 | |
| 397 def printCvMat(cvmat, out = stdout): | 405 def printCvMat(cvmat, out = stdout): |
| 398 '''Prints the cvmat to out''' | 406 '''Prints the cvmat to out''' |
| 399 print('Deprecated, use new interface') | 407 print('Deprecated, use new interface') |
| 400 for i in xrange(cvmat.rows): | 408 for i in xrange(cvmat.rows): |
| 401 for j in xrange(cvmat.cols): | 409 for j in xrange(cvmat.cols): |
