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
647db30f
Commit
647db30f
authored
Jan 29, 2021
by
Leif
Browse files
Fix bugs during save recognition results
parent
6b27cdc1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+19
-11
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
647db30f
...
@@ -1450,7 +1450,7 @@ class MainWindow(QMainWindow, WindowMixin):
...
@@ -1450,7 +1450,7 @@ class MainWindow(QMainWindow, WindowMixin):
item
=
QListWidgetItem
(
closeicon
,
filename
)
item
=
QListWidgetItem
(
closeicon
,
filename
)
self
.
fileListWidget
.
addItem
(
item
)
self
.
fileListWidget
.
addItem
(
item
)
print
(
'
d
irPath in importDirImages is'
,
dirpath
)
print
(
'
D
irPath in importDirImages is'
,
dirpath
)
self
.
iconlist
.
clear
()
self
.
iconlist
.
clear
()
self
.
additems5
(
dirpath
)
self
.
additems5
(
dirpath
)
self
.
changeFileFolder
=
True
self
.
changeFileFolder
=
True
...
@@ -1459,7 +1459,6 @@ class MainWindow(QMainWindow, WindowMixin):
...
@@ -1459,7 +1459,6 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
reRecogButton
.
setEnabled
(
True
)
self
.
reRecogButton
.
setEnabled
(
True
)
self
.
actions
.
AutoRec
.
setEnabled
(
True
)
self
.
actions
.
AutoRec
.
setEnabled
(
True
)
self
.
actions
.
reRec
.
setEnabled
(
True
)
self
.
actions
.
reRec
.
setEnabled
(
True
)
self
.
actions
.
saveLabel
.
setEnabled
(
True
)
def
openPrevImg
(
self
,
_value
=
False
):
def
openPrevImg
(
self
,
_value
=
False
):
...
@@ -1862,6 +1861,8 @@ class MainWindow(QMainWindow, WindowMixin):
...
@@ -1862,6 +1861,8 @@ class MainWindow(QMainWindow, WindowMixin):
for
each
in
states
:
for
each
in
states
:
file
,
state
=
each
.
split
(
'
\t
'
)
file
,
state
=
each
.
split
(
'
\t
'
)
self
.
fileStatedict
[
file
]
=
1
self
.
fileStatedict
[
file
]
=
1
self
.
actions
.
saveLabel
.
setEnabled
(
True
)
self
.
actions
.
saveRec
.
setEnabled
(
True
)
def
saveFilestate
(
self
):
def
saveFilestate
(
self
):
...
@@ -1919,22 +1920,29 @@ class MainWindow(QMainWindow, WindowMixin):
...
@@ -1919,22 +1920,29 @@ class MainWindow(QMainWindow, WindowMixin):
rec_gt_dir
=
os
.
path
.
dirname
(
self
.
PPlabelpath
)
+
'/rec_gt.txt'
rec_gt_dir
=
os
.
path
.
dirname
(
self
.
PPlabelpath
)
+
'/rec_gt.txt'
crop_img_dir
=
os
.
path
.
dirname
(
self
.
PPlabelpath
)
+
'/crop_img/'
crop_img_dir
=
os
.
path
.
dirname
(
self
.
PPlabelpath
)
+
'/crop_img/'
ques_img
=
[]
if
not
os
.
path
.
exists
(
crop_img_dir
):
if
not
os
.
path
.
exists
(
crop_img_dir
):
os
.
mkdir
(
crop_img_dir
)
os
.
mkdir
(
crop_img_dir
)
with
open
(
rec_gt_dir
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
rec_gt_dir
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
for
key
in
self
.
fileStatedict
:
for
key
in
self
.
fileStatedict
:
idx
=
self
.
getImglabelidx
(
key
)
idx
=
self
.
getImglabelidx
(
key
)
try
:
img
=
cv2
.
imread
(
key
)
for
i
,
label
in
enumerate
(
self
.
PPlabel
[
idx
]):
for
i
,
label
in
enumerate
(
self
.
PPlabel
[
idx
]):
if
label
[
'difficult'
]:
continue
if
label
[
'difficult'
]:
continue
img
=
cv2
.
imread
(
key
)
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
label
[
'points'
],
np
.
float32
))
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
label
[
'points'
],
np
.
float32
))
img_name
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
idx
))[
0
]
+
'_crop_'
+
str
(
i
)
+
'.jpg'
img_name
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
idx
))[
0
]
+
'_crop_'
+
str
(
i
)
+
'.jpg'
cv2
.
imwrite
(
crop_img_dir
+
img_name
,
img_crop
)
cv2
.
imwrite
(
crop_img_dir
+
img_name
,
img_crop
)
f
.
write
(
'crop_img/'
+
img_name
+
'
\t
'
)
f
.
write
(
'crop_img/'
+
img_name
+
'
\t
'
)
f
.
write
(
label
[
'transcription'
]
+
'
\n
'
)
f
.
write
(
label
[
'transcription'
]
+
'
\n
'
)
except
Exception
as
e
:
QMessageBox
.
information
(
self
,
"Information"
,
"Cropped images has been saved in "
+
str
(
crop_img_dir
))
ques_img
.
append
(
key
)
print
(
"Can not read image "
,
e
)
if
ques_img
:
QMessageBox
.
information
(
self
,
"Information"
,
"The following images can not be saved, "
"please check the image path and labels.
\n
"
+
""
.
join
(
str
(
i
)
+
'
\n
'
for
i
in
ques_img
))
QMessageBox
.
information
(
self
,
"Information"
,
"Cropped images have been saved in "
+
str
(
crop_img_dir
))
def
speedChoose
(
self
):
def
speedChoose
(
self
):
if
self
.
labelDialogOption
.
isChecked
():
if
self
.
labelDialogOption
.
isChecked
():
...
...
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