Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
94cb4568
Commit
94cb4568
authored
Jan 21, 2021
by
Leif
Browse files
fix image autoRotate & add limitation on image size
parent
fd8d1b0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+6
-2
PPOCRLabel/libs/autoDialog.py
PPOCRLabel/libs/autoDialog.py
+9
-2
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
94cb4568
...
...
@@ -24,6 +24,7 @@ import sys
from
functools
import
partial
from
collections
import
defaultdict
import
json
import
cv2
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
...
...
@@ -1242,10 +1243,13 @@ class MainWindow(QMainWindow, WindowMixin):
# if unicodeFilePath in self.mImgList:
if
unicodeFilePath
and
os
.
path
.
exists
(
unicodeFilePath
):
self
.
imageData
=
read
(
unicodeFilePath
,
None
)
self
.
canvas
.
verified
=
False
image
=
QImage
.
fromData
(
self
.
imageData
)
cvimg
=
cv2
.
imdecode
(
np
.
fromfile
(
unicodeFilePath
,
dtype
=
np
.
uint8
),
1
)
height
,
width
,
depth
=
cvimg
.
shape
cvimg
=
cv2
.
cvtColor
(
cvimg
,
cv2
.
COLOR_BGR2RGB
)
image
=
QImage
(
cvimg
.
data
,
width
,
height
,
width
*
depth
,
QImage
.
Format_RGB888
)
if
image
.
isNull
():
self
.
errorMessage
(
u
'Error opening file'
,
u
"<p>Make sure <i>%s</i> is a valid image file."
%
unicodeFilePath
)
...
...
PPOCRLabel/libs/autoDialog.py
View file @
94cb4568
...
...
@@ -7,6 +7,8 @@ except ImportError:
from
PyQt4.QtCore
import
*
import
json
import
cv2
import
numpy
as
np
from
libs.utils
import
newIcon
...
...
@@ -34,11 +36,16 @@ class Worker(QThread):
if
self
.
handle
==
0
:
self
.
listValue
.
emit
(
Imgpath
)
if
self
.
model
==
'paddle'
:
self
.
result_dic
=
self
.
ocr
.
ocr
(
Imgpath
,
cls
=
True
,
det
=
True
)
h
,
w
,
_
=
cv2
.
imdecode
(
np
.
fromfile
(
Imgpath
,
dtype
=
np
.
uint8
),
1
).
shape
if
h
>
32
and
w
>
32
:
self
.
result_dic
=
self
.
ocr
.
ocr
(
Imgpath
,
cls
=
True
,
det
=
True
)
else
:
print
(
'The size of'
,
Imgpath
,
'is too small to be recognised'
)
self
.
result_dic
=
None
# 结果保存
if
self
.
result_dic
is
None
or
len
(
self
.
result_dic
)
==
0
:
print
(
'Can not recognise file
is :
'
,
Imgpath
)
print
(
'Can not recognise file'
,
Imgpath
)
pass
else
:
strs
=
''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment