diff --git a/frigate/embeddings/lpr/lpr.py b/frigate/embeddings/lpr/lpr.py index 2b0ef0da6..a186db8df 100644 --- a/frigate/embeddings/lpr/lpr.py +++ b/frigate/embeddings/lpr/lpr.py @@ -144,13 +144,14 @@ class LicensePlateRecognition: return self.ctc_decoder(outputs) def process_license_plate( - self, image: np.ndarray + self, image: np.ndarray, event_id: str = "" ) -> Tuple[List[str], List[float], List[int]]: """ Complete pipeline for detecting, classifying, and recognizing license plates in the input image. Args: image (np.ndarray): The input image in which to detect, classify, and recognize license plates. + event_id (str): The ID of the event associated with this license plate detection. Returns: Tuple[List[str], List[float], List[int]]: Detected license plate texts, confidence scores, and areas of the plates. @@ -193,14 +194,14 @@ class LicensePlateRecognition: area = height * width average_confidence = conf + avg_confidence = sum(average_confidence) / len(average_confidence) if average_confidence else 0 # Save debug image try: save_image = cv2.cvtColor( rotated_images[original_idx], cv2.COLOR_RGB2BGR ) - confidence_value = average_confidence[0] if average_confidence and len(average_confidence) > 0 else 0 - filename = f"{plate}_{int(confidence_value * 100)}_{area}.jpg" + filename = f"{plate}_{int(avg_confidence * 100)}_{event_id}.jpg" if event_id else f"{plate}_{int(avg_confidence * 100)}.jpg" cv2.imwrite(os.path.join(self.debug_dir, filename), save_image) except Exception as e: logger.warning(f"Failed to save debug image: {e}") diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py index e221bd146..c893e4f4b 100644 --- a/frigate/embeddings/maintainer.py +++ b/frigate/embeddings/maintainer.py @@ -443,7 +443,7 @@ class EmbeddingMaintainer(threading.Thread): # run detection, returns results sorted by confidence, best first license_plates, confidences, areas = ( - self.license_plate_recognition.process_license_plate(license_plate_frame) + self.license_plate_recognition.process_license_plate(license_plate_frame, id) ) logger.debug(f"Text boxes: {license_plates}") diff --git a/web/src/pages/LPRDebug.tsx b/web/src/pages/LPRDebug.tsx index 9a6253252..a582b8239 100644 --- a/web/src/pages/LPRDebug.tsx +++ b/web/src/pages/LPRDebug.tsx @@ -157,11 +157,11 @@ type LPRAttemptProps = { function LPRAttempt({ attempt, config, onRefresh }: LPRAttemptProps) { const [showDialog, setShowDialog] = useState(false); const data = useMemo(() => { - const parts = attempt.split("-"); + const parts = attempt.split("_"); return { - eventId: `${parts[0]}-${parts[1]}`, - plate: parts[2] || "Text not extracted", - score: parts[3] || "0", + plate: parts[0] || "Text not extracted", + score: parts[1] || "0", + eventId: parts[2]?.replace(".jpg", "") || null, }; }, [attempt]);