@@ -328,7 +328,7 @@ export default function LiveRecognitionViewer({
328328 < div className = "flex flex-col gap-4" >
329329 { /* Plate number - largest and most prominent */ }
330330 < div className = "bg-background dark:bg-[#0e0e10] rounded-lg border p-5 flex-grow-0" >
331- < div className = "flex justify-between items-start" >
331+ < div className = "flex justify-between items-start w-80 2xl:w-[22rem] " >
332332 < div >
333333 < div className = "text-4xl font-mono font-bold tracking-wider" >
334334 { latestPlate . plate_number }
@@ -351,9 +351,9 @@ export default function LiveRecognitionViewer({
351351 < Calendar className = "h-4 w-4 mr-2 text-muted-foreground" />
352352 { formatTimestamp ( latestPlate . timestamp ) }
353353 </ div >
354- < div className = "font-medium" >
354+ { /* <div className="font-medium">
355355 Confidence: {formatConfidence(latestPlate.confidence)}
356- </ div >
356+ </div> */ }
357357 </ div >
358358 </ div >
359359
@@ -363,31 +363,64 @@ export default function LiveRecognitionViewer({
363363 < div className = "bg-background dark:bg-[#0e0e10] rounded-lg border p-4" >
364364 < h3 className = "text-sm font-medium mb-3" > Cropped Plate</ h3 >
365365 < div className = "flex items-center justify-center bg-black/5 rounded overflow-hidden p-1" >
366- < div
367- style = { {
368- position : "relative" ,
369- width : `${
370- latestPlate . crop_coordinates [ 2 ] -
371- latestPlate . crop_coordinates [ 0 ]
372- } px`,
373- height : `${
374- latestPlate . crop_coordinates [ 3 ] -
375- latestPlate . crop_coordinates [ 1 ]
376- } px`,
377- overflow : "hidden" ,
378- } }
379- >
380- < img
381- src = { getImageSrc ( latestPlate ) }
382- alt = { `License plate ${ latestPlate . plate_number } ` }
383- style = { {
384- position : "absolute" ,
385- left : `-${ latestPlate . crop_coordinates [ 0 ] } px` ,
386- top : `-${ latestPlate . crop_coordinates [ 1 ] } px` ,
387- maxWidth : "none" ,
388- } }
389- />
390- </ div >
366+ { ( ( ) => {
367+ // Original crop dimensions
368+ const cropWidth =
369+ latestPlate . crop_coordinates [ 2 ] -
370+ latestPlate . crop_coordinates [ 0 ] ;
371+ const cropHeight =
372+ latestPlate . crop_coordinates [ 3 ] -
373+ latestPlate . crop_coordinates [ 1 ] ;
374+
375+ // Calculate aspect ratio
376+ const aspectRatio = cropWidth / cropHeight ;
377+
378+ // Minimum dimensions (as percentages of container width)
379+ const minWidthPercent = 50 ; // 50% of container width
380+ const containerWidth = 80 * 4 - 32 ; // w-80 = 20rem = 320px, minus padding
381+
382+ // Calculate minimum width in pixels (based on container)
383+ const minWidth = ( containerWidth * minWidthPercent ) / 100 ;
384+
385+ // Calculate scaling based on minimum width
386+ const scale =
387+ cropWidth < minWidth ? minWidth / cropWidth : 1 ;
388+
389+ // Calculate dimensions respecting aspect ratio
390+ const finalWidth = Math . round ( cropWidth * scale ) ;
391+ const finalHeight = Math . round ( cropHeight * scale ) ;
392+
393+ return (
394+ < div className = "relative w-full flex justify-center" >
395+ < div
396+ style = { {
397+ position : "relative" ,
398+ width : `${ finalWidth } px` ,
399+ height : `${ finalHeight } px` ,
400+ maxWidth : "100%" ,
401+ overflow : "hidden" ,
402+ } }
403+ >
404+ < img
405+ src = { getImageSrc ( latestPlate ) }
406+ alt = { `License plate ${ latestPlate . plate_number } ` }
407+ style = { {
408+ position : "absolute" ,
409+ left : `-${
410+ latestPlate . crop_coordinates [ 0 ] * scale
411+ } px`,
412+ top : `-${
413+ latestPlate . crop_coordinates [ 1 ] * scale
414+ } px`,
415+ maxWidth : "none" ,
416+ transform : `scale(${ scale } )` ,
417+ transformOrigin : "top left" ,
418+ } }
419+ />
420+ </ div >
421+ </ div >
422+ ) ;
423+ } ) ( ) }
391424 </ div >
392425 </ div >
393426 ) }
@@ -461,7 +494,7 @@ export default function LiveRecognitionViewer({
461494 </ CardTitle >
462495 </ CardHeader >
463496 < CardContent >
464- < div className = "max-h-[350px] overflow-y-auto pr-2" >
497+ < div className = "h-full overflow-y-auto pr-2" >
465498 { plateInsights . recentReads ?. length > 0 ? (
466499 < div className = "space-y-4" >
467500 { plateInsights . recentReads . map ( ( read , index ) => (
0 commit comments