'use client'; import { AlertTriangle, ImageIcon, Loader2 } from 'lucide-react'; import Image from 'next/image'; import { useProtectedMediaObjectUrl } from '@/hooks/useProtectedMedia'; import type { BoundingBoxOverlayItem, DetectionResultItem } from '@/types'; import BoundingBoxOverlay from '@/components/annotation/boundingBoxOverlay'; interface AnnotatedDetectionImageProps { detection?: DetectionResultItem; videoWidth: number; videoHeight: number; } export default function AnnotatedDetectionImage({ detection, videoWidth, videoHeight, }: AnnotatedDetectionImageProps) { const { objectUrl, isLoading, isError } = useProtectedMediaObjectUrl( detection?.detection.context_image_url, ); const overlayDetections: BoundingBoxOverlayItem[] = detection ? [ { id: detection.id, class_name: detection.detection.class_name, display_name: detection.detection.display_name, confidence: detection.detection.confidence, bounding_box: detection.detection.bounding_box, }, ] : []; const aspectRatio = videoWidth > 0 && videoHeight > 0 ? `${videoWidth} / ${videoHeight}` : '16 / 9'; return (
{!detection ? (

Select a detection to view its image.

) : isLoading ? (

Loading detection image...

) : isError || !objectUrl ? (

Failed to load the detection image.

) : ( <> {`${detection.detection.display_name} )}
); }