comparison scripts/clean-ground-truth.py @ 782:08f82be22816 dev

added script to detect issues in ground truth databases
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 25 Feb 2016 17:14:22 -0500
parents
children 933670761a57
comparison
equal deleted inserted replaced
781:7c38250ddfc7 782:08f82be22816
1 #! /usr/bin/env python
2 import argparse
3 import pandas as pd
4 import sqlite3
5 from numpy import min, max
6
7 #import utils
8 #import storage
9
10 parser = argparse.ArgumentParser(description='The program finds ground truth annotation objects with missing positions (and the times that do not have a position')
11 #parser.add_argument('configFilename', help = 'name of the configuration file')
12 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Ground Truth Sqlite database', required = True)
13
14 args = parser.parse_args()
15
16 data = pd.read_sql_query("select object_id, frame_number from bounding_boxes", sqlite3.connect(args.databaseFilename))
17 #aggData = data.groupby(["object_id"]).agg([min, max, len])
18
19 nProblems = 0
20 for object_id in data["object_id"].unique():
21 tmp = data[data["object_id"] == object_id]
22 firstInstant = min(tmp["frame_number"])
23 lastInstant = max(tmp["frame_number"])
24 if lastInstant-firstInstant != len(tmp)-1:
25 nProblems += 1
26 times=set(range(firstInstant, lastInstant+1))
27 print("Object {} has missing positions at instants: {}".format(object_id, times.difference(tmp["frame_number"])))
28
29 if nProblems == 0:
30 print("No problems were detected in database {}".format(args.databaseFilename))