comparison python/cvutils.py @ 924:a71455bd8367

work in progress on undistortion acceleration
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 07 Jul 2017 18:01:45 -0400
parents 8f60ecfc2f06
children dbd81710d515
comparison
equal deleted inserted replaced
923:238008f81c16 924:a71455bd8367
120 else: 120 else:
121 cv2.imshow(windowName, img) 121 cv2.imshow(windowName, img)
122 122
123 def computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients): 123 def computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients):
124 newImgSize = (int(round(width*undistortedImageMultiplication)), int(round(height*undistortedImageMultiplication))) 124 newImgSize = (int(round(width*undistortedImageMultiplication)), int(round(height*undistortedImageMultiplication)))
125 newCameraMatrix = deepcopy(intrinsicCameraMatrix) 125 #newCameraMatrix = deepcopy(intrinsicCameraMatrix)
126 newCameraMatrix[0,2] = newImgSize[0]/2. 126 #newCameraMatrix[0,2] = newImgSize[0]/2.
127 newCameraMatrix[1,2] = newImgSize[1]/2. 127 #newCameraMatrix[1,2] = newImgSize[1]/2.
128 return cv2.initUndistortRectifyMap(intrinsicCameraMatrix, array(distortionCoefficients), identity(3), newCameraMatrix, newImgSize, cv2.CV_32FC1) 128 newCameraMatrix = cv2.getDefaultNewCameraMatrix(intrinsicCameraMatrix, newImgSize, True)
129 return cv2.initUndistortRectifyMap(intrinsicCameraMatrix, array(distortionCoefficients), None, newCameraMatrix, newImgSize, cv2.CV_32FC1)
129 130
130 def playVideo(filenames, windowNames = None, firstFrameNums = None, frameRate = -1, interactive = False, printFrames = True, text = None, rescale = 1., step = 1, colorBlind = False): 131 def playVideo(filenames, windowNames = None, firstFrameNums = None, frameRate = -1, interactive = False, printFrames = True, text = None, rescale = 1., step = 1, colorBlind = False):
131 '''Plays the video(s)''' 132 '''Plays the video(s)'''
132 if colorBlind: 133 if colorBlind:
133 colorType = 'colorblind' 134 colorType = 'colorblind'