mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 17:14:26 +03:00
fixes
This commit is contained in:
parent
c58d875a01
commit
7801ff44d2
@ -144,13 +144,14 @@ class LicensePlateRecognition:
|
|||||||
return self.ctc_decoder(outputs)
|
return self.ctc_decoder(outputs)
|
||||||
|
|
||||||
def process_license_plate(
|
def process_license_plate(
|
||||||
self, image: np.ndarray
|
self, image: np.ndarray, event_id: str = ""
|
||||||
) -> Tuple[List[str], List[float], List[int]]:
|
) -> Tuple[List[str], List[float], List[int]]:
|
||||||
"""
|
"""
|
||||||
Complete pipeline for detecting, classifying, and recognizing license plates in the input image.
|
Complete pipeline for detecting, classifying, and recognizing license plates in the input image.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
image (np.ndarray): The input image in which to detect, classify, and recognize license plates.
|
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:
|
Returns:
|
||||||
Tuple[List[str], List[float], List[int]]: Detected license plate texts, confidence scores, and areas of the plates.
|
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
|
area = height * width
|
||||||
|
|
||||||
average_confidence = conf
|
average_confidence = conf
|
||||||
|
avg_confidence = sum(average_confidence) / len(average_confidence) if average_confidence else 0
|
||||||
|
|
||||||
# Save debug image
|
# Save debug image
|
||||||
try:
|
try:
|
||||||
save_image = cv2.cvtColor(
|
save_image = cv2.cvtColor(
|
||||||
rotated_images[original_idx], cv2.COLOR_RGB2BGR
|
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(avg_confidence * 100)}_{event_id}.jpg" if event_id else f"{plate}_{int(avg_confidence * 100)}.jpg"
|
||||||
filename = f"{plate}_{int(confidence_value * 100)}_{area}.jpg"
|
|
||||||
cv2.imwrite(os.path.join(self.debug_dir, filename), save_image)
|
cv2.imwrite(os.path.join(self.debug_dir, filename), save_image)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to save debug image: {e}")
|
logger.warning(f"Failed to save debug image: {e}")
|
||||||
|
|||||||
@ -443,7 +443,7 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
|
|
||||||
# run detection, returns results sorted by confidence, best first
|
# run detection, returns results sorted by confidence, best first
|
||||||
license_plates, confidences, areas = (
|
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}")
|
logger.debug(f"Text boxes: {license_plates}")
|
||||||
|
|||||||
@ -157,11 +157,11 @@ type LPRAttemptProps = {
|
|||||||
function LPRAttempt({ attempt, config, onRefresh }: LPRAttemptProps) {
|
function LPRAttempt({ attempt, config, onRefresh }: LPRAttemptProps) {
|
||||||
const [showDialog, setShowDialog] = useState(false);
|
const [showDialog, setShowDialog] = useState(false);
|
||||||
const data = useMemo(() => {
|
const data = useMemo(() => {
|
||||||
const parts = attempt.split("-");
|
const parts = attempt.split("_");
|
||||||
return {
|
return {
|
||||||
eventId: `${parts[0]}-${parts[1]}`,
|
plate: parts[0] || "Text not extracted",
|
||||||
plate: parts[2] || "Text not extracted",
|
score: parts[1] || "0",
|
||||||
score: parts[3] || "0",
|
eventId: parts[2]?.replace(".jpg", "") || null,
|
||||||
};
|
};
|
||||||
}, [attempt]);
|
}, [attempt]);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user