def computeMOT(self, i): # create sqlite and cfg file with id i cfg_name = config_files +str(i)+'.cfg' sql_name = sqlite_files +str(i)+'.sqlite' open(cfg_name,'w').close() config = ConfigObj(cfg_name) cfg_list.write_config(i ,config) command = ['cp', 'tracking_only.sqlite', sql_name] process = subprocess.Popen(command) process.wait() command = ['trajextract.py', args.inputVideo, '-o', args.homography, '-t', cfg_name, '-d', sql_name, '--gf'] # suppress output of grouping extraction devnull = open(os.devnull, 'wb') process = subprocess.Popen(command, stdout = devnull) process.wait() obj = trajstorage.CVsqlite(sql_name) print "loading", i obj.loadObjects() motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(cdb.annotations, obj.objects, args.matchDistance, firstFrame, lastFrame) if motp is None: motp = 0 self.lock.acquire() self.IDlist.put(i) self.motplist.put(motp) self.motalist.put(mota) obj.close() if args.PrintMOTA: print("ID: mota:{} motp:{}".format(mota, motp)) self.lock.release() return mota
def computeMOT(self, i): obj = trajstorage.CVsqlite(sqlite_files + str(i) + ".sqlite") obj.loadObjects() motp, mota, mt, mme, fpt, gt = moving.computeClearMOT( cdb.annotations, obj.objects, args.matchDistance, firstFrame, lastFrame) self.lock.acquire() self.IDlist.put(i) self.motalist.put(mota) obj.close() if args.PrintMOTA: print("ID", i, " : ", mota) self.lock.release() return mota
def computeMOT(i, lock, printlock, motalist, IDlist): obj = trajstorage.CVsqlite(sqlite_files + str(i) + ".sqlite") obj.loadObjects() motp, mota, mt, mme, fpt, gt = moving.computeClearMOT( cdb.annotations, obj.objects, args.matchDistance, firstFrame, lastFrame) lock.acquire() IDlist.put(i) motalist.put(mota) obj.close() lock.release() printlock.acquire() if args.PrintMOTA: print("Done ID ----- ", i, "With MOTA:", mota) else: print("Done ID ----- ", i) printlock.release()
if args.maskFilename is not None: maskObjects = [] from matplotlib.pyplot import imread mask = imread(args.maskFilename) if len(mask) > 1: mask = mask[:,:,0] for obj in objects: maskObjects += obj.getObjectsInMask(mask, inv(homography), 2) # TODO add option to keep object if at least one feature in mask objects = maskObjects annotations = storage.loadGroundTruthFromSqlite(args.groundTruthDatabaseFilename) for a in annotations: a.computeCentroidTrajectory(homography) if args.display: motp, mota, mt, mme, fpt, gt, gtMatches, toMatches = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant, True) else: motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant) print 'MOTP: {}'.format(motp) print 'MOTA: {}'.format(mota) print 'Number of missed objects.frames: {}'.format(mt) print 'Number of mismatches: {}'.format(mme) print 'Number of false alarms.frames: {}'.format(fpt) if args.display: cvutils.displayTrajectories(args.videoFilename, objects, {}, inv(homography), args.firstInstant, args.lastInstant, annotations = annotations, gtMatches = gtMatches, toMatches = toMatches)#, rescale = args.rescale, nFramesStep = args.nFramesStep, saveAllImages = args.saveAllImages, undistort = (undistort or args.undistort), intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication) #print('Ground truth matches') #print(gtMatches) #print('Object matches')