Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장연우
/
orc-prj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Your Name
2019-01-10 17:56:57 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
67aaf4607c64071662ad77ef1d8a089ea466ee5d
67aaf460
1 parent
611c52b8
main refactoring
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
main.py
main.py
View file @
67aaf46
...
...
@@ -9,6 +9,7 @@ doc = yaml.load(open('freset.yaml', 'r'))
bil_op
=
doc
[
"bilateralFilterData"
]
th_op
=
doc
[
"thresholdData"
]
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'OCR program'
)
parser
.
add_argument
(
'img_file'
,
type
=
str
,
help
=
"Input Image File Name"
)
...
...
@@ -30,16 +31,17 @@ def tesseract_orc_to_file(img):
with
open
(
'result
\\
foo.txt'
,
"w"
)
as
f
:
f
.
write
(
text
)
def
select_freset
(
type
,
img
):
def
select_freset
(
op
,
img
):
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
if
type
<
7
:
if
op
<
7
:
gray
=
cv2
.
bilateralFilter
(
gray
,
int
(
bil_op
[
0
]),
int
(
bil_op
[
1
]),
int
(
bil_op
[
2
]))
_
,
img
=
cv2
.
threshold
(
gray
,
int
(
th_op
[
'threshVal'
][
type
%
3
]),
int
(
th_op
[
'threshMax'
][
0
]),
cv2
.
THRESH_BINARY_INV
if
type
%
2
else
cv2
.
THRESH_BINARY
)
elif
type
<
13
:
_
,
img
=
cv2
.
threshold
(
gray
,
int
(
th_op
[
'threshVal'
][
type
%
3
]),
_
,
img
=
cv2
.
threshold
(
gray
,
int
(
th_op
[
'threshVal'
][
op
%
3
]),
int
(
th_op
[
'threshMax'
][
0
]),
cv2
.
THRESH_BINARY_INV
if
op
%
2
else
cv2
.
THRESH_BINARY
)
elif
op
<
13
:
_
,
img
=
cv2
.
threshold
(
gray
,
int
(
th_op
[
'threshVal'
][
op
%
3
]),
int
(
th_op
[
'threshMax'
][
0
]),
cv2
.
THRESH_BINARY_INV
if
type
%
2
else
cv2
.
THRESH_BINARY
)
cv2
.
THRESH_BINARY_INV
if
op
%
2
else
cv2
.
THRESH_BINARY
)
tesseract_orc_to_file
(
img
)
...
...
Please
register
or
login
to post a comment