nsaunier/traffic-intelligence
adding comments and preparing functions to load bounding boxes from dltrack
Commit 51893de43293 · Nicolas Saunier · 2025-02-14 15:01 -0500
Comments
No comments yet.
Diff
diff --git a/trafficintelligence/storage.py b/trafficintelligence/storage.py
--- a/trafficintelligence/storage.py
+++ b/trafficintelligence/storage.py
@@ -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: