diff trafficintelligence/storage.py @ 1295:51893de43293

adding comments and preparing functions to load bounding boxes from dltrack
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 14 Feb 2025 15:01:40 -0500
parents 46a30ce1a2e4
children d073524de272
line wrap: on
line diff
--- 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: