Mercurial Hosting > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
900:85b81c46c526 | 901:753a081989e2 |
---|---|
5 import utils, moving, events, indicators, shutil | 5 import utils, moving, events, indicators, shutil |
6 from base import VideoFilenameAddable | 6 from base import VideoFilenameAddable |
7 | 7 |
8 from os import path | 8 from os import path |
9 import sqlite3, logging | 9 import sqlite3, logging |
10 from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil | 10 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 |
11 from pandas import read_csv, merge | 11 from pandas import read_csv, merge |
12 | 12 |
13 | 13 |
14 commentChar = '#' | 14 commentChar = '#' |
15 | 15 |
1364 if filename is not None and path.exists(filename): | 1364 if filename is not None and path.exists(filename): |
1365 self.loadConfigFile(filename) | 1365 self.loadConfigFile(filename) |
1366 else: | 1366 else: |
1367 print('Configuration filename {} could not be loaded.'.format(filename)) | 1367 print('Configuration filename {} could not be loaded.'.format(filename)) |
1368 | 1368 |
1369 def processVideoArguments(args): | |
1370 '''Loads information from configuration file | |
1371 then checks what was passed on the command line | |
1372 for override (eg video filename and database filename''' | |
1373 if args.configFilename is not None: # consider there is a configuration file | |
1374 params = ProcessParameters(args.configFilename) | |
1375 videoFilename = params.videoFilename | |
1376 databaseFilename = params.databaseFilename | |
1377 if params.homography is not None: | |
1378 invHomography = linalg.inv(params.homography) | |
1379 else: | |
1380 invHomography = None | |
1381 intrinsicCameraMatrix = params.intrinsicCameraMatrix | |
1382 distortionCoefficients = params.distortionCoefficients | |
1383 undistortedImageMultiplication = params.undistortedImageMultiplication | |
1384 undistort = params.undistort | |
1385 firstFrameNum = params.firstFrameNum | |
1386 else: | |
1387 invHomography = None | |
1388 undistort = False | |
1389 intrinsicCameraMatrix = None | |
1390 distortionCoefficients = [] | |
1391 undistortedImageMultiplication = None | |
1392 undistort = False | |
1393 firstFrameNum = 0 | |
1394 | |
1395 # override video and database filenames if present on command line | |
1396 if args.videoFilename is not None: | |
1397 videoFilename = args.videoFilename | |
1398 else: | |
1399 videoFilename = params.videoFilename | |
1400 if args.databaseFilename is not None: | |
1401 databaseFilename = args.databaseFilename | |
1402 else: | |
1403 databaseFilename = params.databaseFilename | |
1404 | |
1405 return params, videoFilename, databaseFilename, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum | |
1406 | |
1407 # deprecated | |
1369 class SceneParameters(object): | 1408 class SceneParameters(object): |
1370 def __init__(self, config, sectionName): | 1409 def __init__(self, config, sectionName): |
1371 from ConfigParser import NoOptionError | 1410 from ConfigParser import NoOptionError |
1372 from ast import literal_eval | 1411 from ast import literal_eval |
1373 try: | 1412 try: |