Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/compute-homography.py @ 636:3058e00887bc
removed all issues because of tests with None, using is instead of == or !=
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 24 Mar 2015 18:11:28 +0100 |
| parents | aded6c1c2ebd |
| children | 852f5de42d01 |
comparison
equal
deleted
inserted
replaced
| 635:6ae68383071e | 636:3058e00887bc |
|---|---|
| 73 | 73 |
| 74 # cvFindHomography(imagePoints, worldPoints, H); | 74 # cvFindHomography(imagePoints, worldPoints, H); |
| 75 | 75 |
| 76 | 76 |
| 77 homography = np.array([]) | 77 homography = np.array([]) |
| 78 if args.pointCorrespondencesFilename != None: | 78 if args.pointCorrespondencesFilename is not None: |
| 79 worldPts, videoPts = cvutils.loadPointCorrespondences(args.pointCorrespondencesFilename) | 79 worldPts, videoPts = cvutils.loadPointCorrespondences(args.pointCorrespondencesFilename) |
| 80 homography, mask = cv2.findHomography(videoPts, worldPts) # method=0, ransacReprojThreshold=3 | 80 homography, mask = cv2.findHomography(videoPts, worldPts) # method=0, ransacReprojThreshold=3 |
| 81 elif args.videoFrameFilename != None and args.worldFilename != None: | 81 elif args.videoFrameFilename is not None and args.worldFilename is not None: |
| 82 worldImg = plt.imread(args.worldFilename) | 82 worldImg = plt.imread(args.worldFilename) |
| 83 videoImg = plt.imread(args.videoFrameFilename) | 83 videoImg = plt.imread(args.videoFrameFilename) |
| 84 if args.undistort: | 84 if args.undistort: |
| 85 [map1, map2] = cvutils.computeUndistortMaps(videoImg.shape[1], videoImg.shape[0], args.undistortedImageMultiplication, np.loadtxt(args.intrinsicCameraMatrixFilename), args.distortionCoefficients) | 85 [map1, map2] = cvutils.computeUndistortMaps(videoImg.shape[1], videoImg.shape[0], args.undistortedImageMultiplication, np.loadtxt(args.intrinsicCameraMatrixFilename), args.distortionCoefficients) |
| 86 videoImg = cv2.remap(videoImg, map1, map2, interpolation=cv2.INTER_LINEAR) | 86 videoImg = cv2.remap(videoImg, map1, map2, interpolation=cv2.INTER_LINEAR) |
| 101 f.close() | 101 f.close() |
| 102 | 102 |
| 103 if homography.size>0: | 103 if homography.size>0: |
| 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 is not None and args.worldFilename is not 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) |
