Spaces:
Running
Running
Upload 51 files
Browse files
src/components/MultiSourceCaptioningView.tsx
CHANGED
@@ -148,6 +148,14 @@ export default function MultiSourceCaptioningView() {
|
|
148 |
boxes = parseFlatBoxArray(output);
|
149 |
}
|
150 |
boxes = normalizeBoxes(boxes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
if (boxes.length === 0) setInferenceStatus("No boxes detected or model output invalid.");
|
152 |
if (Array.isArray(boxes) && boxes.length > 0) {
|
153 |
addBoxesWithTimestamp(boxes); // <-- Add to persistent state
|
@@ -158,10 +166,11 @@ export default function MultiSourceCaptioningView() {
|
|
158 |
// Draw persistent boxes on every frame
|
159 |
useEffect(() => {
|
160 |
const draw = () => {
|
161 |
-
if
|
162 |
-
const video = videoRef.current;
|
163 |
-
|
164 |
if (video.videoWidth === 0) return;
|
|
|
165 |
canvas.width = video.videoWidth;
|
166 |
canvas.height = video.videoHeight;
|
167 |
const ctx = canvas.getContext("2d");
|
@@ -177,7 +186,7 @@ export default function MultiSourceCaptioningView() {
|
|
177 |
draw();
|
178 |
const interval = setInterval(draw, 100);
|
179 |
return () => clearInterval(interval);
|
180 |
-
}, [persistentBoxes, videoRef, canvasRef]);
|
181 |
|
182 |
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
183 |
const file = e.target.files?.[0] || null;
|
|
|
148 |
boxes = parseFlatBoxArray(output);
|
149 |
}
|
150 |
boxes = normalizeBoxes(boxes);
|
151 |
+
// Restore debug logging
|
152 |
+
console.log("Model output:", output);
|
153 |
+
console.log("Boxes after normalization:", boxes);
|
154 |
+
console.log("Canvas size:", canvas.width, canvas.height);
|
155 |
+
if (boxes.length > 0) {
|
156 |
+
const [x1, y1, x2, y2] = boxes[0].bbox_2d;
|
157 |
+
console.log("First box coords:", x1, y1, x2, y2);
|
158 |
+
}
|
159 |
if (boxes.length === 0) setInferenceStatus("No boxes detected or model output invalid.");
|
160 |
if (Array.isArray(boxes) && boxes.length > 0) {
|
161 |
addBoxesWithTimestamp(boxes); // <-- Add to persistent state
|
|
|
166 |
// Draw persistent boxes on every frame
|
167 |
useEffect(() => {
|
168 |
const draw = () => {
|
169 |
+
// Use overlay video for dimensions if available, else fallback to main video
|
170 |
+
const video = overlayVideoRef.current || videoRef.current;
|
171 |
+
if (!video || !canvasRef.current) return;
|
172 |
if (video.videoWidth === 0) return;
|
173 |
+
const canvas = canvasRef.current;
|
174 |
canvas.width = video.videoWidth;
|
175 |
canvas.height = video.videoHeight;
|
176 |
const ctx = canvas.getContext("2d");
|
|
|
186 |
draw();
|
187 |
const interval = setInterval(draw, 100);
|
188 |
return () => clearInterval(interval);
|
189 |
+
}, [persistentBoxes, videoRef, overlayVideoRef, canvasRef]);
|
190 |
|
191 |
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
192 |
const file = e.target.files?.[0] || null;
|