Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/compute-homography.py @ 572:9c429c7efe89
added script to generate undistorted images from video
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 12 Aug 2014 15:33:03 -0400 |
| parents | bd1ad468e928 |
| children | aded6c1c2ebd |
comparison
equal
deleted
inserted
replaced
| 571:a9c1d61a89b4 | 572:9c429c7efe89 |
|---|---|
| 104 np.savetxt('homography.txt',homography) | 104 np.savetxt('homography.txt',homography) |
| 105 | 105 |
| 106 if args.displayPoints and args.videoFrameFilename != None and args.worldFilename != None and homography.size>0: | 106 if args.displayPoints and args.videoFrameFilename != None and args.worldFilename != None and homography.size>0: |
| 107 worldImg = cv2.imread(args.worldFilename) | 107 worldImg = cv2.imread(args.worldFilename) |
| 108 videoImg = cv2.imread(args.videoFrameFilename) | 108 videoImg = cv2.imread(args.videoFrameFilename) |
| 109 if args.undistort: | 109 if args.undistort: |
| 110 [map1, map2] = cvutils.computeUndistortMaps(videoImg.shape[1], videoImg.shape[0], args.undistortedImageMultiplication, np.loadtxt(args.intrinsicCameraMatrixFilename), args.distortionCoefficients) | 110 [map1, map2] = cvutils.computeUndistortMaps(videoImg.shape[1], videoImg.shape[0], args.undistortedImageMultiplication, np.loadtxt(args.intrinsicCameraMatrixFilename), args.distortionCoefficients) |
| 111 videoImg = cv2.remap(videoImg, map1, map2, interpolation=cv2.INTER_LINEAR) | 111 videoImg = cv2.remap(videoImg, map1, map2, interpolation=cv2.INTER_LINEAR) |
| 112 if args.saveImages: | 112 if args.saveImages: |
| 113 cv2.imwrite(utils.removeExtension(args.videoFrameFilename)+'-undistorted.png', videoImg) | 113 cv2.imwrite(utils.removeExtension(args.videoFrameFilename)+'-undistorted.png', videoImg) |
| 114 invHomography = np.linalg.inv(homography) | 114 invHomography = np.linalg.inv(homography) |
