comparison python/compute-homography.py @ 236:eb4525853030

added script to display trajectories
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 06 Jul 2012 01:03:52 -0400
parents 584613399513
children 6774bdce03f1
comparison
equal deleted inserted replaced
235:584613399513 236:eb4525853030
55 if '--help' in options.keys() or '-h' in options.keys() or len(args) == 0:: 55 if '--help' in options.keys() or '-h' in options.keys() or len(args) == 0::
56 print('Usage: {0} --help|-h [--video_frame <video frame filename>] [<point_correspondences.txt>]'.format(sys.argv[0])) 56 print('Usage: {0} --help|-h [--video_frame <video frame filename>] [<point_correspondences.txt>]'.format(sys.argv[0]))
57 print('''The positional argument should be the name 57 print('''The positional argument should be the name
58 of a file containing at least 4 non-colinear point coordinates (point correspondences: 58 of a file containing at least 4 non-colinear point coordinates (point correspondences:
59 - the first two lines are the x and y coordinates in the projected space (usually world space) 59 - the first two lines are the x and y coordinates in the projected space (usually world space)
60 - the last two lines are the x and y coordinates in the origin space (usually image space)''') 60 - the last two lines are the x and y coordinates in the origin space (usually image space)
61
62 if providing a video frame, the image points and back projected world points will be plotted''')
61 sys.exit() 63 sys.exit()
62 64
63 dstPts, srcPts = cvutils.loadPointCorrespondences(args[0]) 65 dstPts, srcPts = cvutils.loadPointCorrespondences(args[0])
64 homography, mask = cv2.findHomography(srcPts, dstPts) # method=0, ransacReprojThreshold=3 66 homography, mask = cv2.findHomography(srcPts, dstPts) # method=0, ransacReprojThreshold=3
65 np.savetxt(utils.removeExtension(sys.argv[1])+'-homography.txt',homography) 67 np.savetxt(utils.removeExtension(sys.argv[1])+'-homography.txt',homography)