comparison scripts/process.py @ 1007:192de96e5255

solved config filename bug
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 03 Jun 2018 14:14:13 -0400
parents 2cf861106d17
children 0d29b75f74ea
comparison
equal deleted inserted replaced
1006:2cf861106d17 1007:192de96e5255
23 # override other tracking config, erase sqlite? 23 # override other tracking config, erase sqlite?
24 parser.add_argument('--delete', dest = 'delete', help = 'data to delete', choices = ['feature', 'object', 'classification', 'interaction']) 24 parser.add_argument('--delete', dest = 'delete', help = 'data to delete', choices = ['feature', 'object', 'classification', 'interaction'])
25 parser.add_argument('--process', dest = 'process', help = 'data to process', choices = ['feature', 'object', 'classification', 'interaction']) 25 parser.add_argument('--process', dest = 'process', help = 'data to process', choices = ['feature', 'object', 'classification', 'interaction'])
26 parser.add_argument('--display', dest = 'display', help = 'data to display (replay over video)', choices = ['feature', 'object', 'classification', 'interaction']) 26 parser.add_argument('--display', dest = 'display', help = 'data to display (replay over video)', choices = ['feature', 'object', 'classification', 'interaction'])
27 parser.add_argument('--analyze', dest = 'analyze', help = 'data to analyze (results)', choices = ['feature', 'object', 'classification', 'interaction']) 27 parser.add_argument('--analyze', dest = 'analyze', help = 'data to analyze (results)', choices = ['feature', 'object', 'classification', 'interaction'])
28 parser.add_argument('--dry', dest = 'dryRun', help = 'dry run of processing', action = 'store_true')
29 parser.add_argument('--nthreads', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1)
28 30
29 # need way of selecting sites as similar as possible to sql alchemy syntax 31 # need way of selecting sites as similar as possible to sql alchemy syntax
30 # override tracking.cfg from db 32 # override tracking.cfg from db
31 # manage cfg files, overwrite them (or a subset of parameters) 33 # manage cfg files, overwrite them (or a subset of parameters)
32 # delete sqlite files 34 # delete sqlite files
33 35
34 # info of metadata 36 # info of metadata
35 37
36 parser.add_argument('--nthreads', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1)
37 38
38 args = parser.parse_args() 39 args = parser.parse_args()
39 # files are relative to metadata location 40 # files are relative to metadata location
40 41
41 session = connectDatabase(args.metadataFilename) 42 session = connectDatabase(args.metadataFilename)
69 if args.nProcesses == 1: 70 if args.nProcesses == 1:
70 pass 71 pass
71 else: 72 else:
72 pool = Pool(args.nProcesses) 73 pool = Pool(args.nProcesses)
73 for vs in videoSequences: 74 for vs in videoSequences:
74 if not (parentDir/vs.getDatabaseFilename()).exists(): 75 if not (parentDir/vs.getDatabaseFilename()).exists() or args.process == 'object':
75 if args.configFilename is None: 76 if args.configFilename is None:
76 configFilename = str(parentDir/vs.cameraView.getTrackingConfigurationFilename()) 77 configFilename = str(parentDir/vs.cameraView.getTrackingConfigurationFilename())
77 else: 78 else:
78 configFilename = args.configFilename 79 configFilename = args.configFilename
79 if vs.cameraView.cameraType is None: 80 if vs.cameraView.cameraType is None:
80 pool.apply_async(cvutils.tracking, args = (configFilename, args.process == 'object', str(parentDir.absolute()/vs.getVideoSequenceFilename()), str(parentDir.absolute()/vs.getDatabaseFilename()), str(parentDir.absolute()/vs.cameraView.getHomographyFilename()), str(parentDir.absolute()/vs.cameraView.getMaskFilename()), False, None, None)) 81 pool.apply_async(cvutils.tracking, args = (configFilename, args.process == 'object', str(parentDir.absolute()/vs.getVideoSequenceFilename()), str(parentDir.absolute()/vs.getDatabaseFilename()), str(parentDir.absolute()/vs.cameraView.getHomographyFilename()), str(parentDir.absolute()/vs.cameraView.getMaskFilename()), False, None, None, args.dryRun))
81 else: 82 else:
82 pool.apply_async(cvutils.tracking, args = (configFilename, args.process == 'object', str(parentDir.absolute()/vs.getVideoSequenceFilename()), str(parentDir.absolute()/vs.getDatabaseFilename()), str(parentDir.absolute()/vs.cameraView.getHomographyFilename()), str(parentDir.absolute()/vs.cameraView.getMaskFilename()), True, vs.cameraView.cameraType.intrinsicCameraMatrix, vs.cameraView.cameraType.distortionCoefficients)) 83 pool.apply_async(cvutils.tracking, args = (configFilename, args.process == 'object', str(parentDir.absolute()/vs.getVideoSequenceFilename()), str(parentDir.absolute()/vs.getDatabaseFilename()), str(parentDir.absolute()/vs.cameraView.getHomographyFilename()), str(parentDir.absolute()/vs.cameraView.getMaskFilename()), True, vs.cameraView.cameraType.intrinsicCameraMatrix, vs.cameraView.cameraType.distortionCoefficients, args.dryRun))
83 else: 84 else:
84 print('SQLite already exists: {}'.format(parentDir/vs.getDatabaseFilename())) 85 print('SQLite already exists: {}'.format(parentDir/vs.getDatabaseFilename()))
85 pool.close() 86 pool.close()
86 pool.join() 87 pool.join()
87 88