Going somewhere with a coffee

This commit is contained in:
didier committed 2024-11-16 09:16:25 -05:00
1 parent 236dd82871
commit a10fdbee50
7 files changed
+247 -143

No files matched your search

+18 -4
View File
@@ -2,6 +2,8 @@ import abc
import pandas as pd
from pathlib import Path
from dodgeballtracker.metadata import VideoMetadata
from dodgeballtracker.typing import TrackedDetectedObject, VideoTimestamp
from sqlite3 import Connection
@@ -61,15 +63,20 @@ class SQLiteDataDumper(DataDumper):
ymax DOUBLE PRECISION NOT NULL,
score DOUBLE PRECISION NOT NULL,
category INTEGER NOT NULL,
object_id INTEGER NOT NULL,
video_frame_id INTEGER NOT NULL,
FOREIGN KEY(video_frame_id) REFERENCES video_frame(id)
);
''')
self._conn.commit()
def start(self, video_path: Path, hexa_hash: str) -> None:
def start(self,
video_path: Path,
hexa_hash: str,
metadata: VideoMetadata|None=None) -> None:
self._create_tables()
cur = self._conn.cursor()
@@ -101,9 +108,16 @@ class SQLiteDataDumper(DataDumper):
RETURNING id
''', (ts, frame_index, self._video_id))
frame_id = res.fetchone()[0]
cols = ['xmin', 'ymin', 'xmax', 'ymax', 'score', 'category']
cols = ['xmin', 'ymin', 'xmax', 'ymax', 'score', 'category', 'object_id']
cur.executemany('''
INSERT INTO tracked_detected_object(xmin, ymin, xmax, ymax, score, category, video_frame_id)
VALUES (?, ?, ?, ?, ?, ?, ?)
INSERT INTO tracked_detected_object(xmin,
ymin,
xmax,
ymax,
score,
category,
object_id,
video_frame_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''', (list(x[cols]) + [frame_id] for x in df.iloc))
self._conn.commit()