# If a plate is found we'll pass this onto OCR for plate_detection in detect_plate_response["predictions"]: # Расширяем область детекции на 20% со всех сторон для захвата региона expand_percent = 0.20 x_expand = int((plate_detection["x_max"] - plate_detection["x_min"]) * expand_percent) y_expand = int((plate_detection["y_max"] - plate_detection["y_min"]) * expand_percent) expanded_x_min = max(0, plate_detection["x_min"] - x_expand) expanded_y_min = max(0, plate_detection["y_min"] - y_expand) expanded_x_max = min(numpy_image.shape[1], plate_detection["x_max"] + x_expand) expanded_y_max = min(numpy_image.shape[0], plate_detection["y_max"] + y_expand) print(f"🔍 ALPR: Оригинальная область: {plate_detection['x_min']},{plate_detection['y_min']} - {plate_detection['x_max']},{plate_detection['y_max']}") print(f"📐 ALPR: Расширенная область: {expanded_x_min},{expanded_y_min} - {expanded_x_max},{expanded_y_max}") # Pull out just the detected plate with EXPANDED coordinates plate_rect = Rect(expanded_x_min, expanded_y_min, expanded_x_max, expanded_y_max) # The image itself... (Its coordinates are now relative to itself) numpy_plate = numpy_image[plate_rect.top:plate_rect.bottom, plate_rect.left:plate_rect.right]