OCR
This commit is contained in:
parent
8eef0d9414
commit
afba7af80b
2
.idea/License_plate_recognition.iml
generated
2
.idea/License_plate_recognition.iml
generated
@ -2,7 +2,7 @@
|
|||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="jdk" jdkName="D:\conda_envs\RLP" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="cnm" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PyDocumentationSettings">
|
<component name="PyDocumentationSettings">
|
||||||
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="pytorh" />
|
<option name="sdkName" value="pytorh" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="D:\conda_envs\RLP" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="cnm" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -22,7 +22,28 @@ def initialize_ocr_model():
|
|||||||
return _processor
|
return _processor
|
||||||
|
|
||||||
def ocr_predict(image_array):
|
def ocr_predict(image_array):
|
||||||
return _processor.predict(image_array)
|
# 获取原始预测结果
|
||||||
|
raw_result = _processor.predict(image_array)
|
||||||
|
|
||||||
|
# 将结果合并为字符串(如果是列表的话)
|
||||||
|
if isinstance(raw_result, list):
|
||||||
|
result_str = ''.join(raw_result)
|
||||||
|
else:
|
||||||
|
result_str = str(raw_result)
|
||||||
|
|
||||||
|
# 过滤掉'·'字符
|
||||||
|
filtered_str = result_str.replace('·', '')
|
||||||
|
|
||||||
|
# 转换为字符列表
|
||||||
|
char_list = list(filtered_str)
|
||||||
|
|
||||||
|
# 确保返回长度为7的列表
|
||||||
|
if len(char_list) >= 7:
|
||||||
|
# 如果长度大于等于7,取前7个字符
|
||||||
|
return char_list[:7]
|
||||||
|
else:
|
||||||
|
# 如果长度小于7,用空字符串补齐到7位
|
||||||
|
return char_list + [''] * (7 - len(char_list))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user