From 671c5085e999368e39404c8d0a45a87f4ee4d000 Mon Sep 17 00:00:00 2001 From: "lamonov.pavel" Date: Tue, 22 Jul 2025 19:27:36 +0300 Subject: [PATCH] =?UTF-8?q?refs=20#=20=D0=A1=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D1=80=D0=B5=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20VIN=20=D0=B8=D0=B7=20=D0=A1=D0=A2=D0=A1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/detect_vin.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 не обнаружен после выравнивания")