Commits

Nicolas Saunier committed bd1ad46

corrected bug and added capability to save undistorted image

Comments (0)

Files changed (2)

python/cvutils.py

                     key = cv2.waitKey(wait)
             cv2.destroyAllWindows()
         else:
-            print('Video capture for {} failed'.format(videoFilename))
+            print('Video capture for {} failed'.format(filename))
 
     def getImagesFromVideo(videoFilename, firstFrameNum = 0, nFrames = 1, saveImage = False, outputPrefix = 'image'):
         '''Returns nFrames images from the video sequence'''

scripts/compute-homography.py

 parser.add_argument('--intrinsic', dest = 'intrinsicCameraMatrixFilename', help = 'name of the intrinsic camera file')
 parser.add_argument('--distortion-coefficients', dest = 'distortionCoefficients', help = 'distortion coefficients', nargs = '*', type = float)
 parser.add_argument('--undistorted-multiplication', dest = 'undistortedImageMultiplication', help = 'undistorted image multiplication', type = float)
-parser.add_argument('--undistort', dest = 'undistort', help = 'undistort the video (because features have been extracted that way)', action = 'store_true')
+parser.add_argument('--undistort', dest = 'undistort', help = 'undistort the video (because features have been extracted that way', action = 'store_true')
+parser.add_argument('--save', dest = 'saveImages', help = 'save the undistorted video frame (display option must be chosen)', action = 'store_true')
 
 args = parser.parse_args()
 
     if args.undistort:        
         [map1, map2] = cvutils.computeUndistortMaps(videoImg.shape[1], videoImg.shape[0], args.undistortedImageMultiplication, np.loadtxt(args.intrinsicCameraMatrixFilename), args.distortionCoefficients)
         videoImg = cv2.remap(videoImg, map1, map2, interpolation=cv2.INTER_LINEAR)
+        if args.saveImages:
+            cv2.imwrite(utils.removeExtension(args.videoFrameFilename)+'-undistorted.png', videoImg)
     invHomography = np.linalg.inv(homography)
     projectedWorldPts = cvutils.projectArray(invHomography, worldPts.T).T
     projectedVideoPts = cvutils.projectArray(homography, videoPts.T).T