Mercurial Hosting > traffic-intelligence
changeset 333:c9201f6b143a
moved the config parser to utils
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 14 Jun 2013 10:25:00 -0400 |
parents | a6ca86107f27 |
children | 1d90e9080cb2 |
files | python/display-trajectories.py python/safety-analysis.py python/utils.py |
diffstat | 3 files changed, 23 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
diff -r a6ca86107f27 -r c9201f6b143a python/display-trajectories.py --- a/python/display-trajectories.py Fri Jun 14 09:53:32 2013 -0400 +++ b/python/display-trajectories.py Fri Jun 14 10:25:00 2013 -0400 @@ -2,13 +2,10 @@ import sys,getopt -import storage -import cvutils -from utils import FakeSecHead +import storage, cvutils, utils from numpy.linalg.linalg import inv from numpy import loadtxt -from ConfigParser import ConfigParser 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=' @@ -29,13 +26,12 @@ objectType = options['-t'] if len(args)>0: # consider there is a configuration file - config = ConfigParser() - config.readfp(FakeSecHead(open(args[0]))) - sectionHeader = config.sections()[0] - videoFilename = config.get(sectionHeader, 'video-filename') - databaseFilename = config.get(sectionHeader, 'database-filename') - homography = inv(loadtxt(config.get(sectionHeader, 'homography-filename'))) - firstFrameNum = config.getint(sectionHeader, 'frame1') + 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']
diff -r a6ca86107f27 -r c9201f6b143a python/safety-analysis.py --- a/python/safety-analysis.py Fri Jun 14 09:53:32 2013 -0400 +++ b/python/safety-analysis.py Fri Jun 14 10:25:00 2013 -0400 @@ -22,12 +22,8 @@ # TODO work on the way to indicate an interaction definition if len(args)>0: # consider there is a configuration file - config = ConfigParser() - config.readfp(FakeSecHead(open(args[0]))) - sectionHeader = config.sections()[0] - videoFilename = config.get(sectionHeader, 'video-filename') - databaseFilename = config.get(sectionHeader, 'database-filename') - homography = inv(loadtxt(config.get(sectionHeader, 'homography-filename'))) - firstFrameNum = config.getint(sectionHeader, 'frame1') + params = utils.TrackingParameters() + params.loadConfigFile(args[0]) +
diff -r a6ca86107f27 -r c9201f6b143a python/utils.py --- a/python/utils.py Fri Jun 14 09:53:32 2013 -0400 +++ b/python/utils.py Fri Jun 14 10:25:00 2013 -0400 @@ -437,7 +437,19 @@ return optionValues - +class TrackingParameters: + def loadConfigFile(self, filename): + from ConfigParser import ConfigParser + from numpy import loadtxt + + 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) + self.firstFrameNum = config.getint(self.sectionHeader, 'frame1') ######################### # sqlite