comparison python/compute-homography.py @ 160:b0719b3ad3db

created function to load point correspondences and updates scripts that use it
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 19 Sep 2011 16:43:28 -0400
parents 4af774bb186d
children ba71924cadf5
comparison
equal deleted inserted replaced
159:115f7f90286d 160:b0719b3ad3db
19 19
20 if len(args) == 0: 20 if len(args) == 0:
21 print('Usage: {0} --help|-h [--video_frame <video frame filename>] [<point_correspondences.txt>]'.format(sys.argv[0])) 21 print('Usage: {0} --help|-h [--video_frame <video frame filename>] [<point_correspondences.txt>]'.format(sys.argv[0]))
22 sys.exit() 22 sys.exit()
23 23
24 points = np.loadtxt(args[0], dtype=np.float32) 24 dstPts, srcPts = cvutils.loadPointCorrespondences(args[0])
25 srcPts = points[2:,:].T
26 dstPts = points[:2,:].T
27 homography, mask = cv2.findHomography(srcPts, dstPts) # method=0, ransacReprojThreshold=3 25 homography, mask = cv2.findHomography(srcPts, dstPts) # method=0, ransacReprojThreshold=3
28 np.savetxt(utils.removeExtension(sys.argv[1])+'-homography.txt',homography) 26 np.savetxt(utils.removeExtension(sys.argv[1])+'-homography.txt',homography)
29 27
30 if '--video_frame' in options.keys() and homography.size>0: 28 if '--video_frame' in options.keys() and homography.size>0:
31 img = cv2.imread(options['--video_frame']) 29 img = cv2.imread(options['--video_frame'])