Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
my_flask_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c657c2e9
authored
Feb 23, 2024
by
周杭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ocr try except
1 parent
5895cfe9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
14 deletions
Identify_sn/main04.py
config_pro.py
config_test.py
Identify_sn/main04.py
View file @
c657c2e
...
...
@@ -236,7 +236,7 @@ for index, row in enumerate(result):
print
(
original_image
.
mode
)
# 放大图片
scale_factor
=
5
# 放大倍数
scale_factor
=
3
# 放大倍数
# scaled_image = original_image.resize(
# (original_image.width * scale_factor, original_image.height * scale_factor)
# )
...
...
@@ -245,7 +245,10 @@ for index, row in enumerate(result):
(
original_image
.
width
*
scale_factor
,
original_image
.
height
*
scale_factor
)
)
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
try
:
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
except
Exception
as
msg
:
log
.
error
(
msg
)
# result = ocr.ocr(image_path.replace("train", "validation"), cls=True)
for
line
in
result
:
log
.
info
(
line
)
...
...
@@ -283,7 +286,10 @@ for index, row in enumerate(result):
if
flag
:
# 旋转45
dst
=
flip_image_45
(
dst
)
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
try
:
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
except
Exception
as
msg
:
log
.
error
(
msg
)
# result = ocr.ocr(image_path.replace("train", "validation"), cls=True)
for
line
in
result
:
log
.
info
(
line
)
...
...
@@ -320,7 +326,10 @@ for index, row in enumerate(result):
if
flag
:
# 旋转90
dst
=
flip_image_45
(
dst
)
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
try
:
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
except
Exception
as
msg
:
log
.
error
(
msg
)
# result = ocr.ocr(image_path.replace("train", "validation"), cls=True)
for
line
in
result
:
log
.
info
(
line
)
...
...
@@ -357,7 +366,10 @@ for index, row in enumerate(result):
if
flag
:
# 旋转180
dst
=
flip_image_90
(
dst
)
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
try
:
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
except
Exception
as
msg
:
log
.
error
(
msg
)
# result = ocr.ocr(image_path.replace("train", "validation"), cls=True)
for
line
in
result
:
log
.
info
(
line
)
...
...
@@ -391,6 +403,54 @@ for index, row in enumerate(result):
log
.
info
(
SQL01
)
cursor_dev
.
execute
(
SQL01
)
conn_dev
.
commit
()
if
flag
:
scale_factor
=
5
dst
=
original_image
.
resize
(
(
original_image
.
width
*
scale_factor
,
original_image
.
height
*
scale_factor
,
)
)
try
:
result
=
ocr
.
ocr
(
np
.
asarray
(
dst
),
cls
=
True
)
except
Exception
as
msg
:
log
.
error
(
msg
)
# result = ocr.ocr(image_path.replace("train", "validation"), cls=True)
for
line
in
result
:
log
.
info
(
line
)
# log.info(line[0][1][0])
result_list
=
flatten_list
(
result
)
log
.
info
(
"result_list
%
s"
,
result_list
)
with
open
(
"./log01.txt"
,
"a+"
,
encoding
=
"utf-8"
)
as
file
:
if
result_list
is
not
None
:
file
.
write
(
path
+
"----"
+
str
(
result_list
)
+
"
\n
"
)
else
:
file
.
write
(
path
+
"----"
+
"NULL"
+
"
\n
"
)
# 使用正则表达式进行过滤 获取车架号
sn_str
=
""
for
item
in
result_list
:
log
.
info
(
item
)
sn_check
=
extract_sn
(
item
)
if
sn_check
is
not
None
:
flag
=
False
sn_str
=
sn_check
if
sn_str
:
log
.
info
(
str
(
row
))
log
.
info
(
sn_str
)
# 定义要执行的SQL语句
SQL01
=
f
"""
INSERT INTO sys_vin_check_ocr_sn_01 (order_id,file_id,db_sn,ocr_sn,create_time)
VALUES ({row[1]},{row[0]},'{row[9]}','{sn_str}',sysdate())
"""
# 执行SQL语句
log
.
info
(
SQL01
)
cursor_dev
.
execute
(
SQL01
)
conn_dev
.
commit
()
if
flag
:
# 定义要执行的SQL语句
SQL02
=
f
"""
...
...
config_pro.py
View file @
c657c2e
...
...
@@ -2,11 +2,11 @@ class Config:
DEBUG
=
False
env
=
'pro'
# 数据库连接配置
host
=
'192.168.
3.227
'
port
=
330
6
user
=
'
dev_user
'
host
=
'192.168.
5.2
'
port
=
330
7
user
=
'
biz_car_service
'
password
=
'df234fl'
database
=
'
neshield
'
database
=
'
glsx_car_service
'
# Kafka consumer配置
kafka_consumer_bootstrap_servers
=
'localhost:9092'
kafka_consumer_group_id
=
'my_consumer_group'
...
...
config_test.py
View file @
c657c2e
...
...
@@ -2,11 +2,11 @@ class Config:
DEBUG
=
False
env
=
'test'
# 数据库连接配置
host
=
'192.168.3.22
7
'
port
=
330
6
user
=
'
dev_user
'
password
=
'
df234fl
'
database
=
'
neshield
'
host
=
'192.168.3.22
2
'
port
=
330
7
user
=
'
root
'
password
=
'
Msd^*$@online
'
database
=
'
glsx_car_service
'
# Kafka consumer配置
kafka_consumer_bootstrap_servers
=
'localhost:9092'
kafka_consumer_group_id
=
'my_consumer_group'
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment