Mercurial Hosting > traffic-intelligence
diff python/storage.py @ 901:753a081989e2
factorized some argument handling code
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 22 Jun 2017 12:02:34 -0400 |
parents | 1466a63dd1cf |
children | b297525b2cbf |
line wrap: on
line diff
--- a/python/storage.py Wed Jun 21 17:49:58 2017 -0400 +++ b/python/storage.py Thu Jun 22 12:02:34 2017 -0400 @@ -7,7 +7,7 @@ from os import path import sqlite3, logging -from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil +from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg from pandas import read_csv, merge @@ -1366,6 +1366,45 @@ else: print('Configuration filename {} could not be loaded.'.format(filename)) +def processVideoArguments(args): + '''Loads information from configuration file + then checks what was passed on the command line + for override (eg video filename and database filename''' + if args.configFilename is not None: # consider there is a configuration file + params = ProcessParameters(args.configFilename) + videoFilename = params.videoFilename + databaseFilename = params.databaseFilename + if params.homography is not None: + invHomography = linalg.inv(params.homography) + else: + invHomography = None + intrinsicCameraMatrix = params.intrinsicCameraMatrix + distortionCoefficients = params.distortionCoefficients + undistortedImageMultiplication = params.undistortedImageMultiplication + undistort = params.undistort + firstFrameNum = params.firstFrameNum + else: + invHomography = None + undistort = False + intrinsicCameraMatrix = None + distortionCoefficients = [] + undistortedImageMultiplication = None + undistort = False + firstFrameNum = 0 + + # override video and database filenames if present on command line + if args.videoFilename is not None: + videoFilename = args.videoFilename + else: + videoFilename = params.videoFilename + if args.databaseFilename is not None: + databaseFilename = args.databaseFilename + else: + databaseFilename = params.databaseFilename + + return params, videoFilename, databaseFilename, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum + +# deprecated class SceneParameters(object): def __init__(self, config, sectionName): from ConfigParser import NoOptionError