Mercurial Hosting > traffic-intelligence
view scripts/display-trajectories.py @ 364:a50a69e04c2a
script modification so that command line arguments take precedence over config file
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 12 Jul 2013 02:29:49 -0400 |
parents | 7b865f4174aa |
children | 1917db662aa7 |
line wrap: on
line source
#! /usr/bin/env python import sys, argparse import storage, cvutils, utils from numpy.linalg.linalg import inv from numpy import loadtxt parser = argparse.ArgumentParser(description='The program displays feature or object trajectories overlaid over the video frames.', epilog = 'Either the configuration filename or the other parameters (at least video and database filenames) need to be provided.') parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file') parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file') parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file') parser.add_argument('-t', dest = 'trajectoryType', help = 'type of trajectories to display', choices = ['feature', 'object'], default = 'feature') parser.add_argument('-o', dest = 'homography', help = 'name of the image to world homography') parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to display', default = 0, type = int) args = parser.parse_args() homography = None if args.configFilename: # consider there is a configuration file params = utils.TrackingParameters() params.loadConfigFile(args.configFilename) videoFilename = params.videoFilename databaseFilename = params.databaseFilename homography = inv(params.homography) firstFrameNum = params.firstFrameNum if args.videoFilename != None: videoFilename = args.videoFilename if args.databaseFilename != None: databaseFilename = args.databaseFilename if args.homography != None: homography = inv(loadtxt(args.homography)) if args.firstFrameNum != None: firstFrameNum = args.firstFrameNum objects = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType) cvutils.displayTrajectories(videoFilename, objects, homography, firstFrameNum)