Mercurial Hosting > traffic-intelligence
diff python/storage.py @ 768:f8e0a8ea8402 dev
updated the bounding box code (the name so that it is general for ground truth and UT)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 14 Jan 2016 11:44:39 -0500 |
parents | a05b70f307dd |
children | bf4a1790cfac |
line wrap: on
line diff
--- a/python/storage.py Mon Dec 21 15:16:33 2015 -0500 +++ b/python/storage.py Thu Jan 14 11:44:39 2016 -0500 @@ -300,26 +300,30 @@ def loadPrototypesFromSqlite(filename): pass -def loadGroundTruthFromSqlite(filename, gtType = 'bb', gtNumbers = None): - 'Loads bounding box annotations (ground truth) from an SQLite ' - connection = sqlite3.connect(filename) - gt = [] +def loadBBMovingObjectsFromSqlite(filename, objectType = 'bb', objectNumbers = None): + '''Loads bounding box moving object from an SQLite + (format of SQLite output by the ground truth annotation tool + or Urban Tracker - if gtType == 'bb': - topCorners = loadTrajectoriesFromTable(connection, 'bounding_boxes', 'bbtop', gtNumbers) - bottomCorners = loadTrajectoriesFromTable(connection, 'bounding_boxes', 'bbbottom', gtNumbers) - userTypes = loadUserTypesFromTable(connection.cursor(), 'object', gtNumbers) # string format is same as object + Load descriptions?''' + connection = sqlite3.connect(filename) + objects = [] + + if objectType == 'bb': + topCorners = loadTrajectoriesFromTable(connection, 'bounding_boxes', 'bbtop', objectNumbers) + bottomCorners = loadTrajectoriesFromTable(connection, 'bounding_boxes', 'bbbottom', objectNumbers) + userTypes = loadUserTypesFromTable(connection.cursor(), 'object', objectNumbers) # string format is same as object for t, b in zip(topCorners, bottomCorners): num = t.getNum() if t.getNum() == b.getNum(): - annotation = moving.BBAnnotation(num, t.getTimeInterval(), t, b, userTypes[num]) - gt.append(annotation) + annotation = moving.BBMovingObject(num, t.getTimeInterval(), t, b, userTypes[num]) + objects.append(annotation) else: - print ('Unknown type of annotation {}'.format(gtType)) + print ('Unknown type of bounding box {}'.format(objectType)) connection.close() - return gt + return objects def deleteFromSqlite(filename, dataType): 'Deletes (drops) some tables in the filename depending on type of data' @@ -442,7 +446,7 @@ boundingBoxes = {} # list of bounding boxes for each instant try: cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\' AND name=\'bounding_boxes\'') - result = [row for row in cursor] + result = cursor.fetchall() if len(result) > 0: cursor.execute('SELECT * FROM bounding_boxes') for row in cursor: