# HG changeset patch # User Nicolas Saunier # Date 1739563300 18000 # Node ID 51893de4329366da29315ca2c30aa99967a66150 # Parent 3deeb42dffddfcd3e9be9b1f7e1cd55ae0224616 adding comments and preparing functions to load bounding boxes from dltrack diff -r 3deeb42dffdd -r 51893de43293 trafficintelligence/storage.py --- a/trafficintelligence/storage.py Tue Oct 08 15:41:20 2024 -0400 +++ b/trafficintelligence/storage.py Fri Feb 14 15:01:40 2025 -0500 @@ -472,9 +472,7 @@ def loadBBMovingObjectsFromSqlite(filename, objectType = 'bb', objectNumbers = None, timeStep = None): '''Loads bounding box moving object from an SQLite (format of SQLite output by the ground truth annotation tool - or Urban Tracker - - Load descriptions?''' + or Urban Tracker''' objects = [] if Path(filename).is_file(): with sqlite3.connect(filename) as connection: @@ -492,6 +490,12 @@ print ('Unknown type of bounding box {}'.format(objectType)) return objects +def saveBBMovingObjectsToSqlite(outputFilename, objects): + '''Saves bounding boxes as obtained from annotation + object detector-based tracking tool like dltrack + CREATE TABLE 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 ) )''' + pass + def saveInteraction(cursor, interaction): roadUserNumbers = list(interaction.getRoadUserNumbers()) cursor.execute('INSERT INTO interactions VALUES({}, {}, {}, {}, {})'.format(interaction.getNum(), roadUserNumbers[0], roadUserNumbers[1], interaction.getFirstInstant(), interaction.getLastInstant())) @@ -563,9 +567,9 @@ # load first and last object instants # CREATE TEMP TABLE IF NOT EXISTS object_instants AS SELECT OF.object_id, min(frame_number) as first_instant, max(frame_number) as last_instant from positions P, objects_features OF WHERE P.trajectory_id = OF.trajectory_id group by OF.object_id order by OF.object_id -def createBoundingBoxTable(filename, invHomography = None): +def createBoundingBoxTableFromFeatures(filename, invHomography = None): '''Create the table to store the object bounding boxes in image space - ''' + calculated from the object feature coordinates''' with sqlite3.connect(filename) as connection: cursor = connection.cursor() try: