diff --git a/scripts/detect_vin.py b/scripts/detect_vin.py index 3d7b02d..f1ee7d0 100644 --- a/scripts/detect_vin.py +++ b/scripts/detect_vin.py @@ -41,13 +41,16 @@ def auto_rotate_image(image): ocr = PaddleOCR(lang='en', use_textline_orientation=True) # Загрузка изображения -image = cv2.imread("scripts/sts.jpg") +image = cv2.imread("scripts/image.jpg") # Автоматическое выравнивание -aligned_image = auto_rotate_image(image) +# aligned_image = auto_rotate_image(image) +aligned_image = image # Распознавание текста -result = ocr.predict(aligned_image) +result = ocr.predict(image) +output_image = result[0]["doc_preprocessor_res"]["output_img"] +cv2.imwrite('scripts/output_image.jpg', output_image) # Поиск VIN vin_pattern = re.compile(r'^[A-HJ-NPR-Z0-9]{17}$') @@ -70,12 +73,12 @@ if found_vin: x_max, y_max = bbox[2], bbox[3] # Добавление запаса вокруг области - vin_region = aligned_image[ + vin_region = output_image[ y_min:y_max, x_min:x_max ] - cv2.imwrite('scripts/vin_rotated_corrected.jpg', vin_region) + cv2.imwrite('scripts/vin.jpg', vin_region) print(f"VIN найден: {found_vin}") else: print("VIN не обнаружен после выравнивания")