Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c8e2a8b8
authored
2021-10-13 16:50:35 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'feature/ebank' into feature/0918
2 parents
a351ec6f
eb19605f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
src/common/tools/pdf_to_img.py
src/common/tools/pdf_to_img.py
View file @
c8e2a8b
import
os
import
cv2
import
shutil
import
fitz
import
math
...
...
@@ -309,7 +310,7 @@ class PDFHandler:
if
isinstance
(
max_img_count
,
int
)
and
pdf
.
pageCount
>=
max_img_count
:
self
.
img_count
=
pdf
.
pageCount
return
self
.
check_ebank
(
pdf
)
#
self.check_ebank(pdf)
for
pno
in
range
(
pdf
.
pageCount
):
il
=
pdf
.
getPageImageList
(
pno
)
# 获取页面图片对象
# (xref, smask, width, height, bpc, colorspace, alt.colorspace, name, filter, invoker)
...
...
@@ -344,3 +345,14 @@ class PDFHandler:
page
=
pdf
.
loadPage
(
pno
)
self
.
page_to_png
(
page
)
self
.
img_count
=
len
(
self
.
img_path_list
)
def
ebank_draw
(
self
):
for
img_idx
,
img_path
in
enumerate
(
self
.
img_path_list
):
img
=
cv2
.
imread
(
img_path
)
pre
,
suf
=
os
.
path
.
splitext
(
img_path
)
output_path
=
'{0}_res{1}'
.
format
(
pre
,
suf
)
for
(
x0
,
y0
,
x1
,
y0
,
x1
,
y1
,
x0
,
y1
),
text
in
self
.
page_text_list
[
img_idx
]
.
pop
(
'rebuild_text'
):
# print((x0, y0, x1, y0, x1, y1, x0, y1))
# print(text)
cv2
.
rectangle
(
img
,
(
int
(
x0
),
int
(
y0
)),
(
int
(
x1
),
int
(
y1
)),
(
0
,
255
,
0
),
2
)
cv2
.
imwrite
(
output_path
,
img
)
\ No newline at end of file
...
...
Write
Preview
Styling with
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