-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.tsx
769 lines (730 loc) · 25.7 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
// root\body\index.tsx
import { useState, useRef, useEffect, useCallback } from "react";
import type Webcam from "react-webcam";
import { saveAs } from "file-saver";
import { BodyContainer } from "./indexElements";
import Classifier from "../../pages/classifier";
import SavePopup from "../../components/body/save_capture_popup";
import UploadPopup from "../../components/body/load_image_popup";
import ModelInfoPopup from "../../components/body/model_popup";
import SwitchDevice from "../../components/body/switch_device_popup";
import CreateDirectory from "../../components/body/create_directory_popup";
import DeleteDirectoryPopup from "../../components/body/del_directory_popup";
import ResultsTunerPopup from "../../components/body/results_tuner_popup";
import SignUp from "../../components/body/authentication/signup";
import CreativeCommonsPopup from "../../components/body/creative_commons_popup";
import JSZip from "jszip";
import axios from "axios";
interface ImageCache {
index: number;
src: string;
scores: number[];
classifications: string[];
boxes: any[];
annotated: boolean;
imageDims: number[];
overlapping: boolean[];
overlappingIndices: number[];
}
interface params {
windowSize: {
width: number;
height: number;
};
uuid: string;
creativeCommonsPopupOpen: boolean;
setCreativeCommonsPopupOpen: React.Dispatch<React.SetStateAction<boolean>>;
handleCreativeCommonsAgreement: (agree: boolean) => void;
setSignUpOpen: React.Dispatch<React.SetStateAction<boolean>>;
signUpOpen: boolean;
}
const Body: React.FC<params> = (props) => {
const [imageSrc, setImageSrc] = useState<string>(
"https://ai-cfia.github.io/nachet-frontend/placeholder-image.jpg",
);
const [imageSrcKey, setImageSrcKey] = useState<boolean>(false);
const [resultsRendered, setResultsRendered] = useState<boolean>(false);
const [imageIndex, setImageIndex] = useState<number>(0);
const [imageFormat, setImageFormat] = useState<string>("image/png");
const [imageLabel, setImageLabel] = useState<string>("");
const [saveOpen, setSaveOpen] = useState(false);
const [uploadOpen, setUploadOpen] = useState(false);
const [modelInfoPopupOpen, setModelInfoPopupOpen] = useState(false);
const [switchDeviceOpen, setSwitchDeviceOpen] = useState(false);
const [createDirectoryOpen, setCreateDirectoryOpen] = useState(false);
const [imageCache, setImageCache] = useState<ImageCache[]>([]);
const [devices, setDevices] = useState<MediaDeviceInfo[]>([]);
const [activeDeviceId, setActiveDeviceId] = useState<string | undefined>(
undefined,
);
const [curDir, setCurDir] = useState<string>("General");
const [azureStorageDir, setAzureStorageDir] = useState<any>({});
const [delDirectoryOpen, setDelDirectoryOpen] = useState<boolean>(false);
const [resultsTunerOpen, setResultsTunerOpen] = useState<boolean>(false);
const [scoreThreshold, setScoreThreshold] = useState<number>(50);
const [selectedLabel, setSelectedLabel] = useState<string>("all");
const [labelOccurrences, setLabelOccurrences] = useState<any>({});
const [saveIndividualImage, setSaveIndividualImage] = useState<string>("0");
const [switchTable, setSwitchTable] = useState<boolean>(true);
const webcamRef = useRef<Webcam>(null);
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const [isWebcamActive, setIsWebcamActive] = useState(true); // This state determines the visibility of the webcam
const [backendURL, setBackendURL] = useState<string | null>(null);
const loadCaptureToCache = (src: string): void => {
// appends new image to image cache and its corresponding details
setImageCache((prevCache) => [
...prevCache,
{
index:
imageCache.length > 0
? imageCache[imageCache.length - 1].index + 1
: imageIndex + 1,
src,
scores: [],
classifications: [],
boxes: [],
annotated: false,
imageDims: [],
overlapping: [],
overlappingIndices: [],
},
]);
// sets the current image index to the new image
setImageIndex(
imageCache.length > 0
? imageCache[imageCache.length - 1].index + 1
: imageIndex + 1,
);
};
const getCurrentImage = useCallback(
(index: number): void => {
// gets the current image from the image cache based on index value
if (imageCache.length > 0) {
imageCache.forEach((image) => {
if (image.index === index) {
setImageSrc(image.src);
setSelectedLabel("all");
if (image.src === imageSrc) {
setImageSrcKey(!imageSrcKey);
}
}
});
} else {
setImageSrc(
"https://ai-cfia.github.io/nachet-frontend/placeholder-image.jpg",
);
}
},
[imageCache, imageSrc, imageSrcKey],
);
const getBackendUrl = useCallback(async (): Promise<string> => {
const backendURL = process.env.REACT_APP_BACKEND_URL;
if (backendURL === null || backendURL === undefined || backendURL === "") {
setBackendURL(null);
throw new Error("REACT_APP_BACKEND_URL environment variable is not set.");
}
try {
const healthCheckUrl = `${backendURL}/health`;
const response = await fetch(healthCheckUrl);
console.log("Trying Health");
if (response.status === 200) {
setBackendURL(backendURL);
console.log("STATUS 200");
} else {
setBackendURL(null);
console.log("STATUS 404");
throw new Error("Backend URL is not responding with a 200 status.");
}
} catch (error) {
setBackendURL(null);
throw new Error("Error connecting to backend URL.");
}
return backendURL;
}, []);
const captureFeed = (): void => {
// takes screenshot of webcam feed and loads it to cache when capture button is pressed
const src: string | null | undefined = webcamRef.current?.getScreenshot();
if (src === null || src === undefined) {
return;
}
loadCaptureToCache(src);
};
const uploadImage = (event: any): void => {
// loads image from local storage to cache when upload button is pressed
event.preventDefault();
const file = event.target.files[0];
if (file !== undefined) {
const reader = new FileReader();
reader.onloadend = () => {
if (typeof reader.result !== "string") {
return;
}
loadCaptureToCache(reader.result);
};
reader.readAsDataURL(file);
}
setUploadOpen(false);
};
const removeFromCache = (index: number): void => {
// removes image from cache based on given index value when delete button is pressed
const newCache = imageCache.filter((item) => item.index !== index);
setImageCache(newCache);
if (newCache.length >= 1) {
setImageIndex(newCache[newCache.length - 1].index);
} else {
setImageIndex(0);
}
};
const clearCache = (): void => {
// clears image cache when clear button is pressed
setImageCache([]);
setImageIndex(0);
};
const saveImage = (): void => {
// saves image to local storage or compresses the entire cache into a zip file which is then saved to local storage
(async () => {
// save individual image
if (saveIndividualImage === "0" && imageCache.length > 0) {
saveAs(
imageSrc,
`${imageLabel}-${new Date().getFullYear()}-${
new Date().getMonth() + 1
}-${new Date().getDate()}.${imageFormat.split("/")[1]}`,
);
setSaveOpen(false);
} else if (saveIndividualImage === "1" && imageCache.length > 0) {
// compress all images from cache to zip file and download
const zip = new JSZip();
imageCache.forEach((image) => {
const base64Data = image.src.replace(/^data:image\/\w+;base64,/, "");
zip.file(
`Capture-${image.index}-${new Date().getFullYear()}-${
new Date().getMonth() + 1
}-${new Date().getDate()}.${imageFormat.split("/")[1]}`,
base64Data,
{
base64: true,
},
);
});
const content = await zip.generateAsync({ type: "blob" });
saveAs(
content,
`${new Date().getFullYear()}-${
new Date().getMonth() + 1
}-${new Date().getDate()}.${imageFormat.split("/")[1]}.zip`,
);
setSaveOpen(false);
}
})().catch((error) => {
alert(error);
});
};
const loadResultsToCache = (inferenceData: any): void => {
// amends the image cache given an image index, with the inference data
// which is recieved from the server
inferenceData.forEach((object: any) => {
object.boxes.forEach((params: any) => {
setImageCache((prevCache) =>
prevCache.map((item) => {
// check to see if the image index matches the current image index
if (
item.index === imageIndex &&
object.boxes.length !== item.scores.length
) {
return {
...item,
scores: [...item.scores, params.score.toFixed(2)],
classifications: [...item.classifications, params.label],
boxes: [...item.boxes, params.box],
overlapping: [...item.overlapping, params.overlapping],
overlappingIndices: [
...item.overlappingIndices,
params.overlappingIndices,
],
annotated: [...item.scores, params.score.toFixed(2)].length > 0,
};
}
return item;
}),
);
});
});
// redraw canvas (useEffect)
setResultsRendered(!resultsRendered);
};
const getLabelOccurrence = useCallback((): void => {
// gets the number of occurences of each label in the current
// image based on score threshold and seed label selection in classification results
const result: any = {};
imageCache.forEach((object: any) => {
if (object.index === imageIndex && object.annotated === true) {
object.scores.forEach((score: number, index: number) => {
if (score * 100 >= scoreThreshold) {
const label: string = object.classifications[index];
if (result[label] !== undefined) {
result[label] = (result[label] as number) + 1;
} else {
result[label] = 1;
}
}
});
}
});
setLabelOccurrences(result);
}, [imageCache, imageIndex, scoreThreshold, setLabelOccurrences]);
const handleDirChange = (dir: string): void => {
// sets the current directory for azure storage
setCurDir(dir.replace(/\s/g, "-"));
};
const handleCreateDirectory = async (): Promise<void> => {
try {
const backendUrl = await getBackendUrl();
const response = await axios.post(
`${backendUrl}/create-dir`,
{
container_name: props.uuid,
folder_name: curDir,
},
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
},
);
if (response.status === 200) {
setCreateDirectoryOpen(false);
setCurDir("General");
handleAzureStorageDir()
.then(() => {
// Successful completion of handleAzureStorageDir
})
.catch((error) => {
// Handle any errors from handleAzureStorageDir
console.error("Error in handleAzureStorageDir", error);
});
} else {
alert("Error creating directory, it may already exist");
}
} catch (error) {
if (error instanceof Error) {
// Now TypeScript knows 'error' is of type Error
alert("Error creating directory: " + error.message);
} else {
// Handle cases where 'error' is not an Error object
alert("An unknown error occurred");
}
}
};
const handleDelFromDirectory = async (): Promise<void> => {
try {
const backendUrl = await getBackendUrl();
const response = await axios.post(
`${backendUrl}/del`,
{
container_name: props.uuid,
folder_name: curDir,
},
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
},
);
if (response.status === 200) {
setCurDir("General");
handleAzureStorageDir()
.then(() => {
// Successful completion of handleAzureStorageDir
})
.catch((error) => {
// Handle any errors from handleAzureStorageDir
console.error("Error in handleAzureStorageDir", error);
});
} else {
alert(response.data);
}
} catch (error) {
if (error instanceof Error) {
alert("Error deleting directory: " + error.message);
} else {
alert("An unknown error occurred");
}
}
};
const handleAzureStorageDir = useCallback(async (): Promise<void> => {
try {
const backendUrl = await getBackendUrl();
const response = await axios.post(
`${backendUrl}/dir`,
{
container_name: props.uuid,
},
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
},
);
if (response.status === 200) {
setAzureStorageDir(response.data);
} else {
alert("Error fetching directories: " + JSON.stringify(response.data));
}
} catch (error) {
if (error instanceof Error) {
console.error("Error in handleAzureStorageDir: " + error.message);
} else {
console.error("An unknown error occurred in handleAzureStorageDir");
}
}
}, [props.uuid, setAzureStorageDir, getBackendUrl]);
const handleInferenceRequest = async (): Promise<void> => {
if (curDir !== "") {
const imageObject = imageCache.filter(
(item) => item.index === imageIndex,
);
try {
const backendUrl = await getBackendUrl();
const response = await axios.post(
`${backendUrl}/inf`,
{
image: imageSrc,
imageDims: [
imageObject[0].imageDims[0],
imageObject[0].imageDims[1],
],
folder_name: curDir,
container_name: props.uuid,
},
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
},
);
if (response.status === 200) {
void handleAzureStorageDir();
loadResultsToCache(response.data);
} else {
alert("Error processing inference: " + JSON.stringify(response.data));
}
} catch (error) {
if (error instanceof Error) {
console.error("Error in handleInferenceRequest:", error.message);
alert("Error fetching inference data: " + error.message);
} else {
console.error("An unknown error occurred in handleInferenceRequest");
alert("Cannot connect to server");
}
}
} else {
alert("Please select a directory");
}
};
const loadToCanvas = useCallback((): void => {
// loads the current image to the canvas and draws the bounding boxes and labels,
// should update whenever a change is made to the image cache or the score threshold and the selected label is changed
const image = new Image();
image.src = imageSrc;
const canvas: HTMLCanvasElement | null = canvasRef.current;
if (canvas === null) {
return;
}
const ctx: CanvasRenderingContext2D | null = canvas.getContext("2d");
if (ctx === null) {
return;
}
image.onload = () => {
canvas.width = image.width;
canvas.height = image.height;
ctx.drawImage(image, 0, 0);
imageCache.forEach((storedImage) => {
// find the current image in the image cache based on current index
if (storedImage.index === imageIndex && storedImage.annotated) {
storedImage.classifications.forEach((prediction, index) => {
// !storedImage.overlapping[index] REMOVE THIS TO SHOW ONLY 1 BB
if (
storedImage.scores[index] >= scoreThreshold / 100 &&
(prediction === selectedLabel || selectedLabel === "all")
) {
ctx.beginPath();
// draw label index
ctx.font = "bold 0.9vw Arial";
ctx.fillStyle = "black";
ctx.textAlign = "center";
Object.keys(labelOccurrences).forEach((key, labelIndex) => {
const scorePercentage = (
storedImage.scores[index] * 100
).toFixed(0);
// check to see if label is cut off by the canvas edge, if so, move it to the bottom of the bounding box
if (storedImage.boxes[index].topY <= 40) {
if (prediction === key) {
if (switchTable) {
ctx.fillText(
`[${labelIndex + 1}] - ${scorePercentage}%`,
((storedImage.boxes[index].bottomX as number) -
(storedImage.boxes[index].topX as number)) /
2 +
(storedImage.boxes[index].topX as number),
(storedImage.boxes[index].bottomY as number) + 23,
);
} else {
ctx.fillText(
`[${index + 1}]`,
((storedImage.boxes[index].bottomX as number) -
(storedImage.boxes[index].topX as number)) /
2 +
(storedImage.boxes[index].topX as number),
(storedImage.boxes[index].bottomY as number) + 23,
);
}
}
} else {
// draw label index and score percentage
if (prediction === key) {
if (switchTable) {
ctx.fillText(
`[${labelIndex + 1}] - ${scorePercentage}%`,
((storedImage.boxes[index].bottomX as number) -
(storedImage.boxes[index].topX as number)) /
2 +
(storedImage.boxes[index].topX as number),
storedImage.boxes[index].topY - 8,
);
} else {
// only draw table if switchTable is false (result component switch button)
ctx.fillText(
`[${index + 1}]`,
((storedImage.boxes[index].bottomX as number) -
(storedImage.boxes[index].topX as number)) /
2 +
(storedImage.boxes[index].topX as number),
storedImage.boxes[index].topY - 8,
);
}
}
}
});
// draw bounding box
ctx.lineWidth = 2;
ctx.strokeStyle = "red";
ctx.rect(
storedImage.boxes[index].topX,
storedImage.boxes[index].topY,
storedImage.boxes[index].bottomX -
storedImage.boxes[index].topX,
storedImage.boxes[index].bottomY -
storedImage.boxes[index].topY,
);
ctx.stroke();
ctx.closePath();
}
});
}
// capture label in bottom left
if (storedImage.index === imageIndex) {
storedImage.imageDims = [image.width, image.height];
ctx.beginPath();
ctx.font = "bold 0.9vw Arial";
ctx.textAlign = "left";
ctx.fillStyle = "#4ee44e";
ctx.fillText(`Capture ${storedImage.index}`, 10, canvas.height - 15);
ctx.stroke();
ctx.closePath();
}
});
};
}, [
imageCache,
imageIndex,
imageSrc,
labelOccurrences,
scoreThreshold,
selectedLabel,
switchTable,
]);
useEffect(() => {
getCurrentImage(imageIndex);
}, [
imageIndex,
getCurrentImage,
loadToCanvas,
getLabelOccurrence,
handleAzureStorageDir,
]);
useEffect(() => {
loadToCanvas();
}, [
scoreThreshold,
selectedLabel,
resultsRendered,
labelOccurrences,
switchTable,
imageSrc,
imageSrcKey,
imageIndex,
getCurrentImage,
loadToCanvas,
]);
useEffect(() => {
getLabelOccurrence();
}, [imageIndex, scoreThreshold, imageCache, getLabelOccurrence]);
useEffect(() => {
// retrieves the available devices and sets the active device to the first available device
const updateDevices = async (): Promise<any> => {
try {
const availableDevices =
await navigator.mediaDevices.enumerateDevices();
const videoDevices = availableDevices.filter(
(i) => i.kind === "videoinput",
);
setDevices(videoDevices);
if (activeDeviceId === "" || activeDeviceId === undefined) {
setActiveDeviceId(videoDevices[0].deviceId);
}
} catch (error) {
alert(error);
}
};
updateDevices().catch((error) => {
alert(error);
});
const handleDeviceChange = (): void => {
updateDevices().catch((error) => {
alert(error);
});
};
navigator.mediaDevices.addEventListener("devicechange", handleDeviceChange);
return () => {
navigator.mediaDevices.removeEventListener(
"devicechange",
handleDeviceChange,
);
};
}, [activeDeviceId]);
useEffect(() => {
void handleAzureStorageDir();
}, [props.uuid, handleAzureStorageDir]);
const handleImageUpload = (): void => {
// Set the logic for handling image upload and then:
setIsWebcamActive(false); // Hide the webcam after the image is loaded
};
return (
<BodyContainer width={props.windowSize.width}>
{saveOpen && (
<SavePopup
setSaveOpen={setSaveOpen}
saveImage={saveImage}
imageFormat={imageFormat}
imageLabel={imageLabel}
setImageFormat={setImageFormat}
setImageLabel={setImageLabel}
setSaveIndividualImage={setSaveIndividualImage}
saveIndividualImage={saveIndividualImage}
/>
)}
{uploadOpen && (
<UploadPopup setUploadOpen={setUploadOpen} uploadImage={uploadImage} />
)}
{modelInfoPopupOpen && (
<ModelInfoPopup
setSwitchModelOpen={setModelInfoPopupOpen}
switchModelOpen={modelInfoPopupOpen}
/>
)}
{switchDeviceOpen && (
<SwitchDevice
setSwitchDeviceOpen={setSwitchDeviceOpen}
devices={devices}
setDeviceId={setActiveDeviceId}
activeDeviceId={activeDeviceId}
/>
)}
{delDirectoryOpen && (
<DeleteDirectoryPopup
setDelDirectoryOpen={setDelDirectoryOpen}
handleDelFromDirectory={() => {
handleDelFromDirectory().catch((error) => {
console.error("Error in handleDelFromDirectory", error);
});
}}
curDir={curDir}
/>
)}
{createDirectoryOpen && (
<CreateDirectory
setCreateDirectoryOpen={setCreateDirectoryOpen}
handeDirChange={handleDirChange}
curDir={curDir}
handleCreateDirectory={() => {
handleCreateDirectory().catch((error) => {
console.error("Error in handleCreateDirectory", error);
});
}}
/>
)}
{resultsTunerOpen && (
<ResultsTunerPopup
setResultsTunerOpen={setResultsTunerOpen}
setScoreThreshold={setScoreThreshold}
scoreThreshold={scoreThreshold}
/>
)}
{props.signUpOpen && <SignUp setSignUpOpen={props.setSignUpOpen} />}
{props.creativeCommonsPopupOpen && (
<CreativeCommonsPopup
setCreativeCommonsPopupOpen={props.setCreativeCommonsPopupOpen}
handleCreativeCommonsAgreement={props.handleCreativeCommonsAgreement}
/>
)}
<Classifier
handleInference={() => {
handleInferenceRequest().catch((error) => {
console.error("Error in handleInferenceRequest", error);
});
}}
imageIndex={imageIndex}
setUploadOpen={setUploadOpen}
imageSrc={imageSrc}
webcamRef={webcamRef}
imageFormat={imageFormat}
setSaveOpen={setSaveOpen}
capture={captureFeed}
savedImages={imageCache}
clearImageCache={clearCache}
canvasRef={canvasRef}
removeImage={removeFromCache}
setSwitchModelOpen={setModelInfoPopupOpen}
setSwitchDeviceOpen={setSwitchDeviceOpen}
windowSize={props.windowSize}
activeDeviceId={activeDeviceId}
azureStorageDir={azureStorageDir}
curDir={curDir}
setImageIndex={setImageIndex}
handleDirChange={handleDirChange}
setCreateDirectoryOpen={setCreateDirectoryOpen}
setDelDirectoryOpen={setDelDirectoryOpen}
setResultsTunerOpen={setResultsTunerOpen}
scoreThreshold={scoreThreshold}
selectedLabel={selectedLabel}
setSelectedLabel={setSelectedLabel}
labelOccurrences={labelOccurrences}
switchTable={switchTable}
setSwitchTable={setSwitchTable}
setCurDir={setCurDir}
isWebcamActive={isWebcamActive}
onCaptureClick={() => {
setIsWebcamActive(!isWebcamActive);
}}
onImageUpload={handleImageUpload}
backendURL={backendURL}
/>
</BodyContainer>
);
};
export default Body;