Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/display-trajectories.py @ 334:1d90e9080cb2
moved python scripts to the scripts directory
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 14 Jun 2013 10:34:11 -0400 |
| parents | python/display-trajectories.py@c9201f6b143a |
| children | dc2e68e936c7 |
comparison
equal
deleted
inserted
replaced
| 333:c9201f6b143a | 334:1d90e9080cb2 |
|---|---|
| 1 #! /usr/bin/env python | |
| 2 | |
| 3 import sys,getopt | |
| 4 | |
| 5 import storage, cvutils, utils | |
| 6 | |
| 7 from numpy.linalg.linalg import inv | |
| 8 from numpy import loadtxt | |
| 9 | |
| 10 options, args = getopt.getopt(sys.argv[1:], 'hi:d:t:o:f:',['help']) | |
| 11 # alternative long names are a pain to support ,'video-filename=','database-filename=', 'type=' | |
| 12 | |
| 13 options = dict(options) | |
| 14 | |
| 15 print options, args | |
| 16 | |
| 17 if '--help' in options.keys() or '-h' in options.keys() or len(sys.argv) == 1: | |
| 18 print('Usage: '+sys.argv[0]+' --help|-h -i video-filename -d database-filename [-t object_type] [-o image2world_homography] [-f first_frame]\n' | |
| 19 +'Or : '+sys.argv[0]+' [-t object_type] config_file.cfg\n\n' | |
| 20 'Order matters between positional and named arguments\n' | |
| 21 'object_type can be feature or object') | |
| 22 sys.exit() | |
| 23 | |
| 24 objectType = 'feature' | |
| 25 if '-t' in options.keys(): | |
| 26 objectType = options['-t'] | |
| 27 | |
| 28 if len(args)>0: # consider there is a configuration file | |
| 29 params = utils.TrackingParameters() | |
| 30 params.loadConfigFile(args[0]) | |
| 31 videoFilename = params.videoFilename | |
| 32 databaseFilename = params.databaseFilename | |
| 33 homography = inv(params.homography) | |
| 34 firstFrameNum = params.firstFrameNum | |
| 35 else: | |
| 36 videoFilename = options['-i'] | |
| 37 databaseFilename = options['-d'] | |
| 38 homography = None | |
| 39 if '-o' in options.keys(): | |
| 40 homography = inv(loadtxt(options['-o'])) | |
| 41 firstFrameNum = 0 | |
| 42 if '-f' in options.keys(): | |
| 43 firstFrameNum = int(options['-f']) | |
| 44 | |
| 45 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, objectType) | |
| 46 cvutils.displayTrajectories(videoFilename, objects, homography, firstFrameNum) |
