diff --git a/.idea/License_plate_recognition.iml b/.idea/License_plate_recognition.iml index 2328911..57ba54e 100644 --- a/.idea/License_plate_recognition.iml +++ b/.idea/License_plate_recognition.iml @@ -2,7 +2,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 9475f0b..aeaf94a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/OCR_part/ocr_interface.py b/OCR_part/ocr_interface.py index 294e568..92b8048 100644 --- a/OCR_part/ocr_interface.py +++ b/OCR_part/ocr_interface.py @@ -1,36 +1,17 @@ import numpy as np +from paddleocr import TextRecognition +import cv2 def initialize_ocr_model(): - """ - 初始化OCR模型 - - 返回: - bool: 初始化是否成功 - """ - # OCR模型初始化代码 - # 例如: 加载预训练模型、设置参数等 - + model = TextRecognition(model_name="PP-OCRv5_server_rec") print("OCR模型初始化完成(占位)") - return True + return model def ocr_predict(image_array): - """ - OCR车牌号识别接口函数 - - 参数: - image_array: numpy数组格式的车牌图像,已经过矫正处理 - - 返回: - list: 包含7个字符的列表,代表车牌号的每个字符 - 例如: ['京', 'A', '1', '2', '3', '4', '5'] - """ - # 这是OCR部分的占位函数 - # 实际实现时,这里应该包含: - # 1. 图像预处理 - # 2. OCR模型推理 - # 3. 后处理和字符识别 - - # 临时返回占位结果 - placeholder_result = ['待', '识', '别', '0', '0', '0', '0'] + # 保持原有模型调用方式 + output = initialize_ocr_model().predict(input=image_array) + # 结构化输出结果 + results = output[0]["rec_text"] + placeholder_result = results.split(',') return placeholder_result diff --git a/requirements.txt b/requirements.txt index 57cb5ac..f5e0e68 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,11 @@ PyQt5>=5.15.0 # 图像处理 Pillow>=8.0.0 +#paddleocr +python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ +python -m pip install "paddleocr[all]" + + # 可选:如果需要GPU加速 # torch>=1.9.0 # torchvision>=0.10.0