Mercurial Hosting > traffic-intelligence
comparison python/compute-homography.py @ 235:584613399513
added script and functions to remove object tables
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 05 Jul 2012 23:32:14 -0400 |
parents | ba71924cadf5 |
children | eb4525853030 |
comparison
equal
deleted
inserted
replaced
234:2d34060db2e9 | 235:584613399513 |
---|---|
50 # H = cvCreateMat(3, 3, CV_64FC1); | 50 # H = cvCreateMat(3, 3, CV_64FC1); |
51 | 51 |
52 # cvFindHomography(imagePoints, worldPoints, H); | 52 # cvFindHomography(imagePoints, worldPoints, H); |
53 | 53 |
54 | 54 |
55 if '--help' in options.keys() or '-h' in options.keys(): | 55 if '--help' in options.keys() or '-h' in options.keys() or len(args) == 0:: |
56 print('''The argument should be the name of a file containing at least 4 non-colinear point coordinates: | 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 | |
58 of a file containing at least 4 non-colinear point coordinates (point correspondences: | |
57 - 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) |
58 - 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)''') |
59 sys.exit() | |
60 | |
61 if len(args) == 0: | |
62 print('Usage: {0} --help|-h [--video_frame <video frame filename>] [<point_correspondences.txt>]'.format(sys.argv[0])) | |
63 sys.exit() | 61 sys.exit() |
64 | 62 |
65 dstPts, srcPts = cvutils.loadPointCorrespondences(args[0]) | 63 dstPts, srcPts = cvutils.loadPointCorrespondences(args[0]) |
66 homography, mask = cv2.findHomography(srcPts, dstPts) # method=0, ransacReprojThreshold=3 | 64 homography, mask = cv2.findHomography(srcPts, dstPts) # method=0, ransacReprojThreshold=3 |
67 np.savetxt(utils.removeExtension(sys.argv[1])+'-homography.txt',homography) | 65 np.savetxt(utils.removeExtension(sys.argv[1])+'-homography.txt',homography) |