# HG changeset patch # User Nicolas Saunier # Date 1371219900 14400 # Node ID c9201f6b143a523510ee53b8a6a97926ef47c54e # Parent a6ca86107f27bec1d65c60b2a97e56afa19c2156 moved the config parser to utils 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