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
ca6fabf4
Commit
ca6fabf4
authored
Jul 22, 2021
by
Alchemist_W
Browse files
在菜单edit和鼠标右键 增加图片左右旋转功能 且有标注框的情况下不可以旋转,优化代码
parent
4df7ada9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9707 additions
and
13073 deletions
+9707
-13073
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+30
-27
PPOCRLabel/libs/resources.py
PPOCRLabel/libs/resources.py
+9677
-13046
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
ca6fabf4
...
...
@@ -31,7 +31,7 @@ import cv2
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
import
numpy
as
np
from
labelme
import
LabelFile
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'../..'
)))
...
...
@@ -795,47 +795,50 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
actions
.
create
.
setEnabled
(
False
)
self
.
actions
.
undoLastPoint
.
setEnabled
(
True
)
def
rotateLeftImg
(
self
,
_value
=
False
):
filename
=
self
.
mImgList
[
self
.
currIndex
]
def
rotateImg
(
self
,
filename
,
k
,
_value
):
if
os
.
path
.
exists
(
filename
):
_value
=
True
self
.
actions
.
rotateLeft
.
setEnabled
(
_value
)
self
.
actions
.
rotateRight
.
setEnabled
(
_value
)
pix
=
cv2
.
imread
(
filename
)
pix
=
np
.
rot90
(
pix
,
k
=
1
)
pix
=
np
.
rot90
(
pix
,
k
)
cv2
.
imwrite
(
filename
,
pix
)
self
.
canvas
.
update
()
self
.
loadFile
(
filename
)
else
:
_value
=
False
def
rotateImgWarn
(
self
):
if
self
.
lang
==
'ch'
:
self
.
msgBox
.
warning
(
self
,
"提示"
,
"
\n
请从图片列表选择一个需要旋转的图片,且确保图片存在!
"
)
self
.
msgBox
.
warning
(
self
,
"提示"
,
"
\n
该图片已经有标注框,旋转操作会打乱标注,建议清除标注框后旋转。
"
)
else
:
self
.
msgBox
.
warning
(
self
,
"Warn"
,
"
\n
Please select an image from the list of images to rotate and make sure the image exists!"
)
self
.
msgBox
.
warning
(
self
,
"Warn"
,
"
\n
The picture already has a label box, and rotation will disrupt the label.
\
It is recommended to clear the label box and rotate it."
)
self
.
actions
.
rotateLeft
.
setEnabled
(
_value
)
def
rotateRightImg
(
self
,
_value
=
False
):
def
rotateLeftImg
(
self
,
_value
=
False
):
filename
=
self
.
mImgList
[
self
.
currIndex
]
if
os
.
path
.
exists
(
filename
):
if
self
.
itemsToShapesbox
:
self
.
rotateImgWarn
()
else
:
_value
=
True
self
.
actions
.
rotateRight
.
setEnabled
(
_value
)
pix
=
cv2
.
imread
(
filename
)
pix
=
np
.
rot90
(
pix
,
k
=-
1
)
cv2
.
imwrite
(
filename
,
pix
)
self
.
canvas
.
update
()
self
.
loadFile
(
filename
)
self
.
rotateImg
(
filename
=
filename
,
k
=
1
,
_value
=
_value
)
else
:
_value
=
False
self
.
rotateImgWarn
()
self
.
actions
.
rotateRight
.
setEnabled
(
_value
)
if
self
.
lang
==
'ch'
:
self
.
msgBox
.
warning
(
self
,
"提示"
,
"
\n
请从图片列表选择一个需要旋转的图片,且确保图片存在!"
)
else
:
self
.
msgBox
.
warning
(
self
,
"Warn"
,
"
\n
Please select an image from the list of images to rotate and make sure the image exists!"
)
def
rotateRightImg
(
self
,
_value
=
False
):
filename
=
self
.
mImgList
[
self
.
currIndex
]
if
os
.
path
.
exists
(
filename
):
if
self
.
itemsToShapesbox
:
self
.
rotateImgWarn
()
else
:
_value
=
True
self
.
rotateImg
(
filename
=
filename
,
k
=-
1
,
_value
=
_value
)
else
:
_value
=
False
self
.
rotateImgWarn
()
self
.
actions
.
rotateRight
.
setEnabled
(
_value
)
def
toggleDrawingSensitive
(
self
,
drawing
=
True
):
...
...
PPOCRLabel/libs/resources.py
View file @
ca6fabf4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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