Mercurial > hg > nsaunier > traffic-intelligence
diff scripts/clean-ground-truth.py @ 795:a34ec862371f
merged with dev branch
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 09 May 2016 15:33:11 -0400 |
| parents | 08f82be22816 |
| children | 933670761a57 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/clean-ground-truth.py Mon May 09 15:33:11 2016 -0400 @@ -0,0 +1,30 @@ +#! /usr/bin/env python +import argparse +import pandas as pd +import sqlite3 +from numpy import min, max + +#import utils +#import storage + +parser = argparse.ArgumentParser(description='The program finds ground truth annotation objects with missing positions (and the times that do not have a position') +#parser.add_argument('configFilename', help = 'name of the configuration file') +parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Ground Truth Sqlite database', required = True) + +args = parser.parse_args() + +data = pd.read_sql_query("select object_id, frame_number from bounding_boxes", sqlite3.connect(args.databaseFilename)) +#aggData = data.groupby(["object_id"]).agg([min, max, len]) + +nProblems = 0 +for object_id in data["object_id"].unique(): + tmp = data[data["object_id"] == object_id] + firstInstant = min(tmp["frame_number"]) + lastInstant = max(tmp["frame_number"]) + if lastInstant-firstInstant != len(tmp)-1: + nProblems += 1 + times=set(range(firstInstant, lastInstant+1)) + print("Object {} has missing positions at instants: {}".format(object_id, times.difference(tmp["frame_number"]))) + +if nProblems == 0: + print("No problems were detected in database {}".format(args.databaseFilename))
