diff scripts/process.py @ 1003:75af46516b2b

work in progress
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 01 Jun 2018 17:19:31 -0400
parents 933670761a57
children 75601be6019f
line wrap: on
line diff
--- a/scripts/process.py	Fri Jun 01 17:19:24 2018 -0400
+++ b/scripts/process.py	Fri Jun 01 17:19:31 2018 -0400
@@ -1,7 +1,7 @@
 #! /usr/bin/env python3
 
 import sys, argparse
-from pathlib2 import Path
+from pathlib import Path
 
 import matplotlib
 matplotlib.use('Agg')
@@ -14,11 +14,14 @@
 parser = argparse.ArgumentParser(description='This program manages the processing of several files based on a description of the sites and video data in an SQLite database following the metadata module.')
 parser.add_argument('--db', dest = 'metadataFilename', help = 'name of the metadata file', required = True)
 parser.add_argument('--videos', dest = 'videoIds', help = 'indices of the video sequences', nargs = '*', type = int)
+parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file')
 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects/interactions to process', type = int)
 parser.add_argument('--prediction-method', dest = 'predictionMethod', help = 'prediction method (constant velocity (cvd: vector computation (approximate); cve: equation solving; cv: discrete time (approximate)), normal adaptation, point set prediction)', choices = ['cvd', 'cve', 'cv', 'na', 'ps', 'mp'])
 parser.add_argument('--pet', dest = 'computePET', help = 'computes PET', action = 'store_true')
+# override other tracking config, erase sqlite?
 parser.add_argument('--delete', dest = 'delete', help = 'data to delete', choices = ['feature', 'object', 'classification', 'interaction'])
 parser.add_argument('--process', dest = 'process', help = 'data to process', choices = ['feature', 'object', 'classification', 'interaction'])
+parser.add_argument('--display', dest = 'display', help = 'data to display (replay over video)', choices = ['feature', 'object', 'classification', 'interaction'])
 parser.add_argument('--analyze', dest = 'analyze', help = 'data to analyze (results)', choices = ['feature', 'object', 'classification', 'interaction'])
 
 # need way of selecting sites as similar as possible to sql alchemy syntax
@@ -26,6 +29,8 @@
 # manage cfg files, overwrite them (or a subset of parameters)
 # delete sqlite files
 
+# info of metadata
+
 parser.add_argument('--nthreads', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1)
 
 args = parser.parse_args()
@@ -41,7 +46,16 @@
             vs = session.query(VideoSequence).get(videoId)
             storage.deleteFromSqlite(str(parentDir/vs.getDatabaseFilename()), args.delete)
 
-if args.process == 'interaction':
+if args.process in ['feature', 'object']: # tracking
+    for videoId in args.videoIds:
+        vs = session.query(VideoSequence).get(videoId)
+        if args.configFilename is None:
+            configFilename = vs.cameraView.getTrackingConfigurationFilename()
+        else:
+            configFilename = args.configFilename
+        #todo cvutils.tracking(configFilename, args.process == 'object', str(parentDir/vs.getVideoSequenceFilename(), str(parentDir/vs.getDatabaseFilename(), configFilename = vs.cameraView.getHomographyFilename())
+    
+elif args.process == 'interaction':
     # safety analysis TODO make function in safety analysis script
     if args.predictionMethod == 'cvd':
         predictionParameters = prediction.CVDirectPredictionParameters()