Mercurial Hosting > traffic-intelligence
changeset 397:b36b00dd27c3
added function to read scene metadata
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 28 Jul 2013 18:04:20 -0400 |
parents | 167f6ec44ec5 |
children | 3399bd48cb40 |
files | python/utils.py |
diffstat | 1 files changed, 31 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/python/utils.py Sun Jul 28 16:30:11 2013 -0400 +++ b/python/utils.py Sun Jul 28 18:04:20 2013 -0400 @@ -3,7 +3,7 @@ #from numpy import * #from pylab import * -from datetime import time +from datetime import time, datetime __metaclass__ = type @@ -149,7 +149,6 @@ '''returns a datetime.time for the time in hour, minutes and seconds initialTime is a datetime.time''' from math import floor - from datetime import time seconds = int(floor(float(nFrames)/float(frameRate))+initialTime.hour*3600+initialTime.minute*60+initialTime.second) h = int(floor(seconds/3600.)) seconds = seconds - h*3600 @@ -501,6 +500,11 @@ return optionValues + +######################### +# Utils to read .ini type text files for configuration, meta data... +######################### + class TrackingParameters: def loadConfigFile(self, filename): from ConfigParser import ConfigParser @@ -531,6 +535,31 @@ self.maxSteering = config.getfloat(self.sectionHeader, 'max-steering')/self.videoFrameRate self.useFeaturesForPrediction = config.getboolean(self.sectionHeader, 'use-features-prediction') +class SceneParameters: + def __init__(self, config, sectionName): + from ConfigParser import NoOptionError + from ast import literal_eval + try: + self.sitename = config.get(sectionName, 'sitename') + self.databaseFilename = config.get(sectionName, 'data_filename') + self.homographyFilename = config.get(sectionName, 'homography_filename') + self.videoFilename = config.get(sectionName, 'video_filename') + self.date = datetime.strptime(config.get(sectionName, 'date'), "%Y-%m-%d %H:%M:%S") # 2011-06-22 11:00:39 + self.translation = literal_eval(config.get(sectionName, 'translation')) # = [0.0, 0.0] + self.rotation = config.getfloat(sectionName, 'rotation') + self.duration = config.getint(sectionName, 'duration') + except NoOptionError as e: + print(e) + print('Not a section for scene meta-data') + + @staticmethod + def loadConfigFile(filename): + from ConfigParser import ConfigParser + config = ConfigParser() + config.readfp(openCheck(filename)) + return [SceneParameters(config, sectionName) for sectionName in config.sections()] + + ######################### # sqlite #########################