Mercurial Hosting > traffic-intelligence
changeset 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 | 68861b52a319 |
children | 22ddb8f85495 |
files | python/utils.py scripts/display-trajectories.py |
diffstat | 2 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/python/utils.py Fri Jul 12 01:26:22 2013 -0400 +++ b/python/utils.py Fri Jul 12 02:29:49 2013 -0400 @@ -441,14 +441,18 @@ def loadConfigFile(self, filename): from ConfigParser import ConfigParser from numpy import loadtxt - + from os import path + config = ConfigParser() config.readfp(FakeSecHead(openCheck(filename))) self.sectionHeader = config.sections()[0] self.videoFilename = config.get(self.sectionHeader, 'video-filename') self.databaseFilename = config.get(self.sectionHeader, 'database-filename') self.homographyFilename = config.get(self.sectionHeader, 'homography-filename') - self.homography = loadtxt(self.homographyFilename) + if (path.exists(self.homographyFilename)): + self.homography = loadtxt(self.homographyFilename) + else: + self.homography = None self.firstFrameNum = config.getint(self.sectionHeader, 'frame1') self.videoFrameRate = config.getfloat(self.sectionHeader, 'video-fps')
--- a/scripts/display-trajectories.py Fri Jul 12 01:26:22 2013 -0400 +++ b/scripts/display-trajectories.py Fri Jul 12 02:29:49 2013 -0400 @@ -17,6 +17,7 @@ args = parser.parse_args() +homography = None if args.configFilename: # consider there is a configuration file params = utils.TrackingParameters() params.loadConfigFile(args.configFilename) @@ -24,12 +25,14 @@ databaseFilename = params.databaseFilename homography = inv(params.homography) firstFrameNum = params.firstFrameNum -else: + +if args.videoFilename != None: videoFilename = args.videoFilename +if args.databaseFilename != None: databaseFilename = args.databaseFilename - homography = None - if args.homography: - homography = inv(loadtxt(args.homography)) +if args.homography != None: + homography = inv(loadtxt(args.homography)) +if args.firstFrameNum != None: firstFrameNum = args.firstFrameNum objects = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType)