Mercurial Hosting > traffic-intelligence
diff python/storage.py @ 394:6567fee37c16
renamed table for bounding boxes
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 26 Jul 2013 17:24:33 -0400 |
parents | eaf7765221d9 |
children | a2ff03a52b73 |
line wrap: on
line diff
--- a/python/storage.py Fri Jul 26 02:12:08 2013 -0400 +++ b/python/storage.py Fri Jul 26 17:24:33 2013 -0400 @@ -196,7 +196,7 @@ elif dataType == 'interaction': utils.dropTables(connection, ['interactions', 'indicators']) elif dataType == 'bb': - utils.dropTables(connection, ['boundingbox']) + utils.dropTables(connection, ['bounding_boxes']) else: print('Unknown data type {} to delete from database'.format(dataType)) connection.close() @@ -297,8 +297,8 @@ connection = sqlite3.connect(filename) cursor = connection.cursor() try: - cursor.execute('CREATE TABLE IF NOT EXISTS boundingbox (object_id INTEGER, frame_number INTEGER, x_top_left REAL, y_top_left REAL, x_bottom_right REAL, y_bottom_right REAL, PRIMARY KEY(object_id, frame_number))') - cursor.execute('INSERT INTO boundingbox SELECT object_id, frame_number, min(x), min(y), max(x), max(y) from ' + cursor.execute('CREATE TABLE IF NOT EXISTS bounding_boxes (object_id INTEGER, frame_number INTEGER, x_top_left REAL, y_top_left REAL, x_bottom_right REAL, y_bottom_right REAL, PRIMARY KEY(object_id, frame_number))') + cursor.execute('INSERT INTO bounding_boxes SELECT object_id, frame_number, min(x), min(y), max(x), max(y) from ' '(SELECT object_id, frame_number, (x*{}+y*{}+{})/w as x, (x*{}+y*{}+{})/w as y from ' '(SELECT OF.object_id, P.frame_number, P.x_coordinate as x, P.y_coordinate as y, P.x_coordinate*{}+P.y_coordinate*{}+{} as w from positions P, objects_features OF where P.trajectory_id = OF.trajectory_id)) '.format(invHomography[0,0], invHomography[0,1], invHomography[0,2], invHomography[1,0], invHomography[1,1], invHomography[1,2], invHomography[2,0], invHomography[2,1], invHomography[2,2])+ 'GROUP BY object_id, frame_number') @@ -312,10 +312,10 @@ cursor = connection.cursor() boundingBoxes = {} # list of bounding boxes for each instant try: - cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\' AND name=\'boundingbox\'') + cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\' AND name=\'bounding_boxes\'') result = [row for row in cursor] if len(result) > 0: - cursor.execute('SELECT * FROM boundingbox') + cursor.execute('SELECT * FROM bounding_boxes') #objId = -1 for row in cursor: #if row[0] != objId: