Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
4df7ada9
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4df7ada9
编写于
7月 22, 2021
作者:
锦鲤AI幸运
🎯
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
在菜单edit和鼠标右键 增加图片左右旋转功能
上级
aa12eb26
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
12793 addition
and
8803 deletion
+12793
-8803
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+82
-21
PPOCRLabel/libs/resources.py
PPOCRLabel/libs/resources.py
+12705
-8782
PPOCRLabel/resources.qrc
PPOCRLabel/resources.qrc
+2
-0
PPOCRLabel/resources/strings/strings-zh-CN.properties
PPOCRLabel/resources/strings/strings-zh-CN.properties
+2
-0
PPOCRLabel/resources/strings/strings.properties
PPOCRLabel/resources/strings/strings.properties
+2
-0
未找到文件。
PPOCRLabel/PPOCRLabel.py
浏览文件 @
4df7ada9
...
...
@@ -27,7 +27,12 @@ import json
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__
,
'../..'
)))
sys
.
path
.
append
(
".."
)
...
...
@@ -78,7 +83,7 @@ class WindowMixin(object):
addActions
(
menu
,
actions
)
return
menu
def
toolbar
(
self
,
title
,
actions
=
None
):
def
toolbar
(
self
,
title
,
actions
=
None
):
toolbar
=
ToolBar
(
title
)
toolbar
.
setObjectName
(
u
'%sToolBar'
%
title
)
# toolbar.setOrientation(Qt.Vertical)
...
...
@@ -98,7 +103,7 @@ class MainWindow(QMainWindow, WindowMixin):
# Load setting in the main thread
self
.
settings
=
Settings
()
self
.
settings
.
load
()
self
.
settings
.
load
()
settings
=
self
.
settings
self
.
lang
=
lang
# Load string bundle for i18n
...
...
@@ -159,7 +164,7 @@ class MainWindow(QMainWindow, WindowMixin):
filelistLayout
=
QVBoxLayout
()
filelistLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
filelistLayout
.
addWidget
(
self
.
fileListWidget
)
self
.
AutoRecognition
=
QToolButton
()
self
.
AutoRecognition
.
setToolButtonStyle
(
Qt
.
ToolButtonTextBesideIcon
)
self
.
AutoRecognition
.
setIcon
(
newIcon
(
'Auto'
))
...
...
@@ -176,7 +181,7 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
filedock
.
setObjectName
(
getStr
(
'files'
))
self
.
filedock
.
setWidget
(
fileListContainer
)
self
.
addDockWidget
(
Qt
.
LeftDockWidgetArea
,
self
.
filedock
)
######## Right area ##########
listLayout
=
QVBoxLayout
()
listLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
...
...
@@ -250,7 +255,7 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
imgsplider
.
setMaximum
(
150
)
self
.
imgsplider
.
setSingleStep
(
1
)
self
.
imgsplider
.
setTickPosition
(
QSlider
.
TicksBelow
)
self
.
imgsplider
.
setTickInterval
(
1
)
self
.
imgsplider
.
setTickInterval
(
1
)
op
=
QGraphicsOpacityEffect
()
op
.
setOpacity
(
0.2
)
self
.
imgsplider
.
setGraphicsEffect
(
op
)
...
...
@@ -266,7 +271,9 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
zoomWidget
=
ZoomWidget
()
self
.
colorDialog
=
ColorDialog
(
parent
=
self
)
self
.
zoomWidgetValue
=
self
.
zoomWidget
.
value
()
self
.
msgBox
=
QMessageBox
()
########## thumbnail #########
hlayout
=
QHBoxLayout
()
m
=
(
0
,
0
,
0
,
0
)
...
...
@@ -294,7 +301,7 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
nextButton
.
setStyleSheet
(
'border: none;'
)
self
.
nextButton
.
clicked
.
connect
(
self
.
openNextImg
)
self
.
nextButton
.
setShortcut
(
'd'
)
hlayout
.
addWidget
(
self
.
preButton
)
hlayout
.
addWidget
(
self
.
iconlist
)
hlayout
.
addWidget
(
self
.
nextButton
)
...
...
@@ -303,7 +310,7 @@ class MainWindow(QMainWindow, WindowMixin):
iconListContainer
=
QWidget
()
iconListContainer
.
setLayout
(
hlayout
)
iconListContainer
.
setFixedHeight
(
100
)
########### Canvas ###########
self
.
canvas
=
Canvas
(
parent
=
self
)
self
.
canvas
.
zoomRequest
.
connect
(
self
.
zoomRequest
)
...
...
@@ -442,7 +449,7 @@ class MainWindow(QMainWindow, WindowMixin):
AutoRec
=
action
(
getStr
(
'autoRecognition'
),
self
.
autoRecognition
,
''
,
'Auto'
,
getStr
(
'autoRecognition'
),
enabled
=
False
)
reRec
=
action
(
getStr
(
'reRecognition'
),
self
.
reRecognition
,
reRec
=
action
(
getStr
(
'reRecognition'
),
self
.
reRecognition
,
'Ctrl+Shift+R'
,
'reRec'
,
getStr
(
'reRecognition'
),
enabled
=
False
)
singleRere
=
action
(
getStr
(
'singleRe'
),
self
.
singleRerecognition
,
...
...
@@ -460,6 +467,12 @@ class MainWindow(QMainWindow, WindowMixin):
undoLastPoint
=
action
(
getStr
(
"undoLastPoint"
),
self
.
canvas
.
undoLastPoint
,
'Ctrl+Z'
,
"undo"
,
getStr
(
"undoLastPoint"
),
enabled
=
False
)
rotateLeft
=
action
(
getStr
(
"rotateLeft"
),
self
.
rotateLeftImg
,
'Ctrl+Alt+L'
,
"rotateLeft"
,
getStr
(
"rotateLeft"
),
enabled
=
False
)
rotateRight
=
action
(
getStr
(
"rotateRight"
),
self
.
rotateRightImg
,
'Ctrl+Alt+R'
,
"rotateRight"
,
getStr
(
"rotateRight"
),
enabled
=
False
)
undo
=
action
(
getStr
(
"undo"
),
self
.
undoShapeEdit
,
'Ctrl+Z'
,
"undo"
,
getStr
(
"undo"
),
enabled
=
False
)
...
...
@@ -524,12 +537,13 @@ class MainWindow(QMainWindow, WindowMixin):
fitWindow
=
fitWindow
,
fitWidth
=
fitWidth
,
zoomActions
=
zoomActions
,
saveLabel
=
saveLabel
,
undo
=
undo
,
undoLastPoint
=
undoLastPoint
,
open_dataset_dir
=
open_dataset_dir
,
rotateLeft
=
rotateLeft
,
rotateRight
=
rotateRight
,
fileMenuActions
=
(
opendir
,
open_dataset_dir
,
saveLabel
,
resetAll
,
quit
),
beginner
=
(),
advanced
=
(),
editMenu
=
(
createpoly
,
edit
,
copy
,
delete
,
singleRere
,
None
,
undo
,
undoLastPoint
,
None
,
color1
,
self
.
drawSquaresOption
),
beginnerContext
=
(
create
,
edit
,
copy
,
delete
,
singleRere
),
None
,
rotateLeft
,
rotateRight
,
None
,
color1
,
self
.
drawSquaresOption
),
beginnerContext
=
(
create
,
edit
,
copy
,
delete
,
singleRere
,
rotateLeft
,
rotateRight
,
),
advancedContext
=
(
createMode
,
editMode
,
edit
,
copy
,
delete
,
shapeLineColor
,
shapeFillColor
),
onLoadActive
=
(
...
...
@@ -781,6 +795,49 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
actions
.
create
.
setEnabled
(
False
)
self
.
actions
.
undoLastPoint
.
setEnabled
(
True
)
def
rotateLeftImg
(
self
,
_value
=
False
):
filename
=
self
.
mImgList
[
self
.
currIndex
]
if
os
.
path
.
exists
(
filename
):
_value
=
True
self
.
actions
.
rotateLeft
.
setEnabled
(
_value
)
pix
=
cv2
.
imread
(
filename
)
pix
=
np
.
rot90
(
pix
,
k
=
1
)
cv2
.
imwrite
(
filename
,
pix
)
self
.
canvas
.
update
()
self
.
loadFile
(
filename
)
else
:
_value
=
False
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!"
)
self
.
actions
.
rotateLeft
.
setEnabled
(
_value
)
def
rotateRightImg
(
self
,
_value
=
False
):
filename
=
self
.
mImgList
[
self
.
currIndex
]
if
os
.
path
.
exists
(
filename
):
_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
)
else
:
_value
=
False
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!"
)
self
.
actions
.
rotateRight
.
setEnabled
(
_value
)
def
toggleDrawingSensitive
(
self
,
drawing
=
True
):
"""In the middle of drawing, toggling between modes should be disabled."""
self
.
actions
.
editMode
.
setEnabled
(
not
drawing
)
...
...
@@ -1277,7 +1334,7 @@ class MainWindow(QMainWindow, WindowMixin):
titem
=
self
.
iconlist
.
item
(
i
)
titem
.
setSelected
(
True
)
self
.
iconlist
.
scrollToItem
(
titem
)
break
break
else
:
self
.
fileListWidget
.
clear
()
self
.
mImgList
.
clear
()
...
...
@@ -1285,7 +1342,7 @@ class MainWindow(QMainWindow, WindowMixin):
# if unicodeFilePath and self.iconList.count() > 0:
# if unicodeFilePath in self.mImgList:
if
unicodeFilePath
and
os
.
path
.
exists
(
unicodeFilePath
):
self
.
canvas
.
verified
=
False
...
...
@@ -1316,7 +1373,7 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
addRecentFile
(
self
.
filePath
)
self
.
toggleActions
(
True
)
self
.
showBoundingBoxFromPPlabel
(
filePath
)
self
.
setWindowTitle
(
__appname__
+
' '
+
filePath
)
# Default : select last item if there is at least one item
...
...
@@ -1328,7 +1385,7 @@ class MainWindow(QMainWindow, WindowMixin):
return
True
return
False
def
showBoundingBoxFromPPlabel
(
self
,
filePath
):
imgidx
=
self
.
getImglabelidx
(
filePath
)
if
imgidx
not
in
self
.
PPlabel
.
keys
():
...
...
@@ -1421,6 +1478,7 @@ class MainWindow(QMainWindow, WindowMixin):
def
loadRecent
(
self
,
filename
):
if
self
.
mayContinue
():
print
(
filename
,
"======"
)
self
.
loadFile
(
filename
)
def
scanAllImages
(
self
,
folderPath
):
...
...
@@ -1456,7 +1514,7 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
lastOpenDir
=
targetDirPath
self
.
importDirImages
(
targetDirPath
)
def
openDatasetDirDialog
(
self
,
_value
=
False
):
#1458
def
openDatasetDirDialog
(
self
,
):
if
not
self
.
mayContinue
():
return
...
...
@@ -1467,7 +1525,7 @@ class MainWindow(QMainWindow, WindowMixin):
if
self
.
lang
==
'ch'
:
self
.
msgBox
.
warning
(
self
,
"提示"
,
"
\n
原文件夹已不存在,请从新选择数据集路径!"
)
else
:
self
.
msgBox
.
warning
(
self
,
"Warn"
,
"
\n
The original folder no longer exists, please choose the data set path again!"
)
self
.
msgBox
.
warning
(
self
,
"Warn"
,
"
\n
The original folder no longer exists, please choose the data set path again!"
)
self
.
actions
.
open_dataset_dir
.
setEnabled
(
False
)
defaultOpenDirPath
=
os
.
path
.
dirname
(
self
.
filePath
)
if
self
.
filePath
else
'.'
...
...
@@ -1520,6 +1578,9 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
actions
.
AutoRec
.
setEnabled
(
True
)
self
.
actions
.
reRec
.
setEnabled
(
True
)
self
.
actions
.
open_dataset_dir
.
setEnabled
(
True
)
self
.
actions
.
rotateLeft
.
setEnabled
(
True
)
self
.
actions
.
rotateRight
.
setEnabled
(
True
)
def
openPrevImg
(
self
,
_value
=
False
):
...
...
@@ -1528,7 +1589,7 @@ class MainWindow(QMainWindow, WindowMixin):
if
self
.
filePath
is
None
:
return
currIndex
=
self
.
mImgList
.
index
(
self
.
filePath
)
self
.
mImgList5
=
self
.
mImgList
[:
5
]
if
currIndex
-
1
>=
0
:
...
...
@@ -1558,7 +1619,7 @@ class MainWindow(QMainWindow, WindowMixin):
if
filename
:
print
(
'file name in openNext is '
,
filename
)
self
.
loadFile
(
filename
)
def
updateFileListIcon
(
self
,
filename
):
pass
...
...
@@ -1670,7 +1731,7 @@ class MainWindow(QMainWindow, WindowMixin):
proc
.
startDetached
(
os
.
path
.
abspath
(
__file__
))
def
mayContinue
(
self
):
#
if
not
self
.
dirty
:
if
not
self
.
dirty
:
return
True
else
:
discardChanges
=
self
.
discardChangesDialog
()
...
...
@@ -2097,7 +2158,7 @@ def main():
if
__name__
==
'__main__'
:
resource_file
=
'./libs/resources.py'
if
not
os
.
path
.
exists
(
resource_file
):
output
=
os
.
system
(
'pyrcc5 -o libs/resources.py resources.qrc'
)
...
...
PPOCRLabel/libs/resources.py
浏览文件 @
4df7ada9
此差异已折叠。
点击以展开。
PPOCRLabel/resources.qrc
浏览文件 @
4df7ada9
...
...
@@ -18,6 +18,8 @@
<file
alias=
"quit"
>
resources/icons/quit.png
</file>
<file
alias=
"copy"
>
resources/icons/copy.png
</file>
<file
alias=
"edit"
>
resources/icons/edit.png
</file>
<file
alias=
"rotateLeft"
>
resources/icons/rotateLeft.png
</file>
<file
alias=
"rotateRight"
>
resources/icons/rotateRight.png
</file>
<file
alias=
"open"
>
resources/icons/open.png
</file>
<file
alias=
"save"
>
resources/icons/save.png
</file>
<file
alias=
"format_voc"
>
resources/icons/format_voc.png
</file>
...
...
PPOCRLabel/resources/strings/strings-zh-CN.properties
浏览文件 @
4df7ada9
...
...
@@ -86,6 +86,8 @@ detectionBoxposition=检测框位置
recognitionResult
=
识别结果
creatPolygon
=
四点标注
drawSquares
=
正方形标注
rotateLeft
=
图片左旋转90度
rotateRight
=
图片右旋转90度
saveRec
=
保存识别结果
tempLabel
=
待识别
nullLabel
=
无法识别
...
...
PPOCRLabel/resources/strings/strings.properties
浏览文件 @
4df7ada9
...
...
@@ -85,6 +85,8 @@ iconList=Icon List
detectionBoxposition
=
Detection box position
recognitionResult
=
Recognition result
creatPolygon
=
Create Quadrilateral
rotateLeft
=
Left turn 90 degrees
rotateRight
=
Right turn 90 degrees
drawSquares
=
Draw Squares
saveRec
=
Save Recognition Result
tempLabel
=
TEMPORARY
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录