Mercurial Hosting > traffic-intelligence
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/display-trajectories.py Fri Jun 14 10:34:11 2013 -0400 @@ -0,0 +1,46 @@ +#! /usr/bin/env python + +import sys,getopt + +import storage, cvutils, utils + +from numpy.linalg.linalg import inv +from numpy import loadtxt + +options, args = getopt.getopt(sys.argv[1:], 'hi:d:t:o:f:',['help']) +# alternative long names are a pain to support ,'video-filename=','database-filename=', 'type=' + +options = dict(options) + +print options, args + +if '--help' in options.keys() or '-h' in options.keys() or len(sys.argv) == 1: + print('Usage: '+sys.argv[0]+' --help|-h -i video-filename -d database-filename [-t object_type] [-o image2world_homography] [-f first_frame]\n' + +'Or : '+sys.argv[0]+' [-t object_type] config_file.cfg\n\n' + 'Order matters between positional and named arguments\n' + 'object_type can be feature or object') + sys.exit() + +objectType = 'feature' +if '-t' in options.keys(): + objectType = options['-t'] + +if len(args)>0: # consider there is a configuration file + params = utils.TrackingParameters() + params.loadConfigFile(args[0]) + videoFilename = params.videoFilename + databaseFilename = params.databaseFilename + homography = inv(params.homography) + firstFrameNum = params.firstFrameNum +else: + videoFilename = options['-i'] + databaseFilename = options['-d'] + homography = None + if '-o' in options.keys(): + homography = inv(loadtxt(options['-o'])) + firstFrameNum = 0 + if '-f' in options.keys(): + firstFrameNum = int(options['-f']) + +objects = storage.loadTrajectoriesFromSqlite(databaseFilename, objectType) +cvutils.displayTrajectories(videoFilename, objects, homography, firstFrameNum)