Spaces:
Configuration error
Configuration error
Upload 51 files
Browse files
src/components/MultiSourceCaptioningView.tsx
CHANGED
|
@@ -350,11 +350,25 @@ export default function MultiSourceCaptioningView() {
|
|
| 350 |
if (boxHistory.length > 0) {
|
| 351 |
const scaleX = canvas.width / overlayVideo.videoWidth;
|
| 352 |
const scaleY = canvas.height / overlayVideo.videoHeight;
|
| 353 |
-
//
|
| 354 |
-
const denormalizedBoxes =
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
drawBoundingBoxesOnCanvas(ctx, denormalizedBoxes, { color: "#FF00FF", lineWidth: 4, font: "20px Arial", scaleX, scaleY });
|
| 359 |
}
|
| 360 |
};
|
|
|
|
| 350 |
if (boxHistory.length > 0) {
|
| 351 |
const scaleX = canvas.width / overlayVideo.videoWidth;
|
| 352 |
const scaleY = canvas.height / overlayVideo.videoHeight;
|
| 353 |
+
// Flatten and denormalize all boxes
|
| 354 |
+
const denormalizedBoxes: any[] = [];
|
| 355 |
+
for (const b of boxHistory) {
|
| 356 |
+
if (Array.isArray(b.bbox_2d[0])) {
|
| 357 |
+
// Multiple boxes per label
|
| 358 |
+
for (const arr of b.bbox_2d) {
|
| 359 |
+
denormalizedBoxes.push({
|
| 360 |
+
...b,
|
| 361 |
+
bbox_2d: denormalizeBox(arr, canvas.width, canvas.height)
|
| 362 |
+
});
|
| 363 |
+
}
|
| 364 |
+
} else {
|
| 365 |
+
// Single box
|
| 366 |
+
denormalizedBoxes.push({
|
| 367 |
+
...b,
|
| 368 |
+
bbox_2d: denormalizeBox(b.bbox_2d, canvas.width, canvas.height)
|
| 369 |
+
});
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
drawBoundingBoxesOnCanvas(ctx, denormalizedBoxes, { color: "#FF00FF", lineWidth: 4, font: "20px Arial", scaleX, scaleY });
|
| 373 |
}
|
| 374 |
};
|