Compare commits
327 Commits
release/2.
...
release/1.
| Author | SHA1 | Date |
|---|---|---|
|
|
2b16323080 | 6 years ago |
|
|
7f477619c0 | 6 years ago |
|
|
43874ba967 | 6 years ago |
|
|
d851f2c8d3 | 6 years ago |
|
|
ac1df3dbca | 6 years ago |
|
|
e4b09948d1 | 6 years ago |
|
|
280cff56dc | 6 years ago |
|
|
5da58b146c | 6 years ago |
|
|
84a49ca05b | 6 years ago |
|
|
fc512a84e3 | 6 years ago |
|
|
ccd40ec85f | 6 years ago |
|
|
8b64f4c2ea | 6 years ago |
|
|
0c8bdc0885 | 6 years ago |
|
|
e634afe76c | 6 years ago |
|
|
d0d0c4f95c | 6 years ago |
|
|
3ec7d48c0f | 6 years ago |
|
|
3218b48148 | 6 years ago |
|
|
02ae18abf9 | 6 years ago |
|
|
815f20b550 | 6 years ago |
|
|
5f8c3e07d9 | 6 years ago |
|
|
a5fbd902fe | 6 years ago |
|
|
5e25ed64a2 | 6 years ago |
|
|
47703d16ce | 6 years ago |
|
|
764d8f5fc2 | 6 years ago |
|
|
2c35dafeb5 | 6 years ago |
|
|
358182a6d1 | 6 years ago |
|
|
829fe749cc | 6 years ago |
|
|
8750361a5d | 6 years ago |
|
|
ecad10eb02 | 6 years ago |
|
|
51b57c47c7 | 6 years ago |
|
|
04c5c6ab3b | 6 years ago |
|
|
1af833e2b6 | 6 years ago |
|
|
63e4074ab4 | 6 years ago |
|
|
58e0a62799 | 6 years ago |
|
|
c320457d73 | 6 years ago |
|
|
83c420bf31 | 6 years ago |
|
|
c67d04ad6e | 6 years ago |
|
|
e11b8aff79 | 6 years ago |
|
|
43f6ab7a63 | 6 years ago |
|
|
62f85ec0bd | 6 years ago |
|
|
115b517584 | 6 years ago |
|
|
0005f4d171 | 6 years ago |
|
|
2d07a0bcb9 | 6 years ago |
|
|
5d202e44d7 | 6 years ago |
|
|
d93f006212 | 6 years ago |
|
|
9411df5ae7 | 6 years ago |
|
|
f196376249 | 6 years ago |
|
|
3a18b08fc5 | 6 years ago |
|
|
896e573975 | 6 years ago |
|
|
2dfb1cfaa1 | 6 years ago |
|
|
e266466a9a | 6 years ago |
|
|
f94ebce2f5 | 6 years ago |
|
|
29405e325d | 6 years ago |
|
|
d8b9e7a063 | 6 years ago |
|
|
10808204cd | 6 years ago |
|
|
0de72f5d97 | 6 years ago |
|
|
6e87c90486 | 6 years ago |
|
|
90f30dbeb6 | 6 years ago |
|
|
f7ae9a5fb3 | 6 years ago |
|
|
c58fb6e822 | 6 years ago |
|
|
b7e9a81a05 | 6 years ago |
|
|
1063ecbee3 | 6 years ago |
|
|
9bcba212b2 | 6 years ago |
|
|
e53c427330 | 6 years ago |
|
|
ac439ae1aa | 6 years ago |
|
|
95f820b835 | 6 years ago |
|
|
f7dbf2b702 | 6 years ago |
|
|
3a347ebc3a | 6 years ago |
|
|
a52587d91f | 6 years ago |
|
|
e5fcccc495 | 6 years ago |
|
|
7e97976ce6 | 6 years ago |
|
|
0d12338fa9 | 6 years ago |
|
|
4d1e17e70b | 6 years ago |
|
|
c4720557e8 | 6 years ago |
|
|
8ed0882996 | 6 years ago |
|
|
ac7e9dd9f2 | 6 years ago |
|
|
4a839b9d92 | 6 years ago |
|
|
60763646b9 | 6 years ago |
|
|
97c767ccfb | 6 years ago |
|
|
853f6db37d | 6 years ago |
|
|
0eab30cb17 | 6 years ago |
|
|
571275e03c | 6 years ago |
|
|
bad8211491 | 6 years ago |
|
|
6825ee4e11 | 6 years ago |
|
|
d9e005d2a7 | 6 years ago |
|
|
7cacfc97d9 | 6 years ago |
|
|
bb7eca34e7 | 6 years ago |
|
|
f37745ff7c | 6 years ago |
|
|
fa53bc3817 | 6 years ago |
|
|
72faa11b77 | 6 years ago |
|
|
89ea21bf9e | 6 years ago |
|
|
b195d7586f | 6 years ago |
|
|
667d393ecf | 6 years ago |
|
|
e8a649ab5b | 6 years ago |
|
|
580a973841 | 6 years ago |
|
|
4fb914dafe | 6 years ago |
|
|
8b74966a28 | 6 years ago |
|
|
706b25bff3 | 6 years ago |
|
|
250412a408 | 6 years ago |
|
|
0f86cebb57 | 6 years ago |
|
|
03125024cc | 6 years ago |
|
|
e10e788855 | 6 years ago |
|
|
732bb6eb21 | 6 years ago |
|
|
e8ba14955c | 6 years ago |
|
|
3f89879c19 | 6 years ago |
|
|
1cc991e5a8 | 6 years ago |
|
|
cf8bc662de | 6 years ago |
|
|
80608bd618 | 6 years ago |
|
|
a9e7c8f923 | 6 years ago |
|
|
a6db27161a | 6 years ago |
|
|
7d5ce84956 | 6 years ago |
|
|
bd2370f1b9 | 6 years ago |
|
|
6be762d6a0 | 6 years ago |
|
|
4ac63947c4 | 6 years ago |
|
|
de05f4fa43 | 6 years ago |
|
|
0a6537845b | 6 years ago |
|
|
e5d7571503 | 6 years ago |
|
|
3d11aba92d | 6 years ago |
|
|
d8ac92cdad | 6 years ago |
|
|
03960fde89 | 6 years ago |
|
|
c66b97f840 | 6 years ago |
|
|
1614282b23 | 6 years ago |
|
|
96c2e3f136 | 6 years ago |
|
|
3b286e70c3 | 6 years ago |
|
|
6af341a37b | 6 years ago |
|
|
f4d826a5f3 | 6 years ago |
|
|
a0f13f4340 | 6 years ago |
|
|
f6408e11e1 | 6 years ago |
|
|
25d7eb87c2 | 6 years ago |
|
|
bcc8f208ec | 6 years ago |
|
|
a38de9bdbe | 6 years ago |
|
|
278530239d | 6 years ago |
|
|
b578edd6a1 | 6 years ago |
|
|
6ac1497a31 | 6 years ago |
|
|
3e3d06b606 | 6 years ago |
|
|
16352beb89 | 6 years ago |
|
|
f57e23a902 | 6 years ago |
|
|
75fde81704 | 6 years ago |
|
|
e086071da2 | 6 years ago |
|
|
36fbabb108 | 6 years ago |
|
|
f0ce9b90ef | 6 years ago |
|
|
706cfe8391 | 6 years ago |
|
|
7831f18b08 | 6 years ago |
|
|
954c3313d2 | 6 years ago |
|
|
d7080099e9 | 6 years ago |
|
|
bc7dd36e0e | 6 years ago |
|
|
afc752248b | 6 years ago |
|
|
e600d787f5 | 6 years ago |
|
|
dcbc20e20e | 6 years ago |
|
|
28cfb93df5 | 6 years ago |
|
|
6b35afb50a | 6 years ago |
|
|
47f9972a20 | 6 years ago |
|
|
5fa8b5c666 | 6 years ago |
|
|
e01a4b623d | 6 years ago |
|
|
15be2fb979 | 6 years ago |
|
|
0439dfb112 | 6 years ago |
|
|
2681ad5f90 | 6 years ago |
|
|
8e90a40547 | 6 years ago |
|
|
9028077999 | 6 years ago |
|
|
17e722de59 | 6 years ago |
|
|
3fb28d2a87 | 6 years ago |
|
|
9228a49342 | 6 years ago |
|
|
f4d2ebcb3a | 6 years ago |
|
|
3dce09ead4 | 6 years ago |
|
|
3d43a760e6 | 6 years ago |
|
|
136ff79047 | 6 years ago |
|
|
1a19bce923 | 6 years ago |
|
|
d181c7a3ed | 6 years ago |
|
|
b254cdb73a | 6 years ago |
|
|
fb2c33bcb1 | 6 years ago |
|
|
d6b83901fc | 6 years ago |
|
|
bb873ce14d | 6 years ago |
|
|
f3bac1b981 | 6 years ago |
|
|
0983ca7ad2 | 6 years ago |
|
|
3cfffcb5c5 | 6 years ago |
|
|
21d0869b6e | 6 years ago |
|
|
30648fbc84 | 6 years ago |
|
|
60967e8b77 | 6 years ago |
|
|
9295e25091 | 6 years ago |
|
|
c762ca4707 | 6 years ago |
|
|
17e5df1de3 | 6 years ago |
|
|
d53dcb225e | 6 years ago |
|
|
5ea014f5bf | 6 years ago |
|
|
fe35728b7d | 6 years ago |
|
|
a8c8ec1f82 | 6 years ago |
|
|
0f8dc0a622 | 6 years ago |
|
|
1ee51e2f56 | 6 years ago |
|
|
3872da8de0 | 6 years ago |
|
|
bf60c4e7e3 | 6 years ago |
|
|
64ae0c4e38 | 6 years ago |
|
|
7cfc0b910b | 6 years ago |
|
|
ad1aca64d3 | 6 years ago |
|
|
72e4f3643b | 6 years ago |
|
|
eef60848ba | 6 years ago |
|
|
d64a4c3f6d | 6 years ago |
|
|
f27b7edd99 | 6 years ago |
|
|
37f5ff9696 | 6 years ago |
|
|
dc0aea4ec3 | 6 years ago |
|
|
1a024c69c7 | 6 years ago |
|
|
edd4c33f4a | 6 years ago |
|
|
b287673a0b | 6 years ago |
|
|
2a03948d7c | 6 years ago |
|
|
2ee7dcb53a | 6 years ago |
|
|
7a45786ab7 | 6 years ago |
|
|
1392c9c477 | 6 years ago |
|
|
ad545e52f2 | 6 years ago |
|
|
24dfd8b2b2 | 6 years ago |
|
|
de5c741a91 | 6 years ago |
|
|
b6289d0eb0 | 6 years ago |
|
|
77cd8c1e66 | 6 years ago |
|
|
0d17196f94 | 6 years ago |
|
|
84576471c3 | 6 years ago |
|
|
1fd763f89b | 6 years ago |
|
|
8e53734f35 | 6 years ago |
|
|
235b3aff8e | 6 years ago |
|
|
e9a39e2d27 | 6 years ago |
|
|
ae68afd622 | 6 years ago |
|
|
06feb23dff | 6 years ago |
|
|
821149e090 | 6 years ago |
|
|
98c01dabce | 6 years ago |
|
|
2b68ae333a | 6 years ago |
|
|
b063599418 | 6 years ago |
|
|
3942482e2d | 6 years ago |
|
|
78a428dce6 | 6 years ago |
|
|
aee0a1fe96 | 6 years ago |
|
|
be6e69a84f | 6 years ago |
|
|
f1c4f413be | 6 years ago |
|
|
aafa88db70 | 6 years ago |
|
|
a6ccaa513e | 6 years ago |
|
|
cf054cffc1 | 6 years ago |
|
|
f9170fcfce | 6 years ago |
|
|
289bf76067 | 6 years ago |
|
|
9958fdde66 | 6 years ago |
|
|
f415f5fcb6 | 6 years ago |
|
|
cf7372475e | 6 years ago |
|
|
3e1d8f2dee | 6 years ago |
|
|
9cd6e11b3e | 6 years ago |
|
|
a63d91c83f | 6 years ago |
|
|
4d816b6149 | 6 years ago |
|
|
4559f16ec7 | 6 years ago |
|
|
867a60f474 | 6 years ago |
|
|
4a81e9481c | 6 years ago |
|
|
1edfc308b1 | 6 years ago |
|
|
cf2a483369 | 6 years ago |
|
|
06430c9359 | 6 years ago |
|
|
b10bd395c9 | 6 years ago |
|
|
d4c47e2f50 | 6 years ago |
|
|
b479372cd3 | 6 years ago |
|
|
2cdf7a666e | 6 years ago |
|
|
76b8bb7ef1 | 6 years ago |
|
|
e01515599b | 6 years ago |
|
|
e3ac559430 | 6 years ago |
|
|
79180223dc | 6 years ago |
|
|
df14801b43 | 6 years ago |
|
|
c5f9b69c4e | 6 years ago |
|
|
ede5a3f4b6 | 6 years ago |
|
|
b8ed953142 | 6 years ago |
|
|
42f0219cda | 6 years ago |
|
|
bf60cd827b | 6 years ago |
|
|
a3dee6a4b1 | 6 years ago |
|
|
b8bf9b2c66 | 6 years ago |
|
|
fd76c1234b | 6 years ago |
|
|
6b906ad239 | 6 years ago |
|
|
27384a5a5d | 6 years ago |
|
|
ecba3f85d6 | 6 years ago |
|
|
5b5b72e651 | 6 years ago |
|
|
594d34f5ed | 6 years ago |
|
|
cb1cc43259 | 6 years ago |
|
|
227f5f3a36 | 6 years ago |
|
|
d9d51f7daf | 6 years ago |
|
|
0da95ed13b | 6 years ago |
|
|
5d248b168f | 6 years ago |
|
|
99f253bc41 | 6 years ago |
|
|
c7819af417 | 6 years ago |
|
|
25ff7eb517 | 6 years ago |
|
|
f8e01b2ea7 | 6 years ago |
|
|
00a889e166 | 6 years ago |
|
|
a88764eae4 | 6 years ago |
|
|
dbbfe96761 | 6 years ago |
|
|
2aa0c8eb2d | 6 years ago |
|
|
5858441b3d | 6 years ago |
|
|
f78678dd66 | 6 years ago |
|
|
74f983d182 | 6 years ago |
|
|
a7e915bf7b | 6 years ago |
|
|
d4f1758d55 | 6 years ago |
|
|
14dfa73e07 | 6 years ago |
|
|
2ac3ec96f4 | 6 years ago |
|
|
eafa136cf1 | 6 years ago |
|
|
2c6f0b0d55 | 6 years ago |
|
|
f3f2b38efb | 6 years ago |
|
|
03979d71d2 | 6 years ago |
|
|
742cb9a3c6 | 6 years ago |
|
|
74f6a5cb3d | 6 years ago |
|
|
144b022fb6 | 6 years ago |
|
|
ed6b2f0c71 | 6 years ago |
|
|
fc9933354d | 6 years ago |
|
|
d31effaf97 | 6 years ago |
|
|
5fb3c419c9 | 6 years ago |
|
|
5fc9fff98f | 6 years ago |
|
|
29e2fed39c | 6 years ago |
|
|
f265f94c65 | 6 years ago |
|
|
aa7e9ac34e | 6 years ago |
|
|
bc1ad20701 | 6 years ago |
|
|
21af7660b5 | 6 years ago |
|
|
7165f5899d | 6 years ago |
|
|
4009fcf3d0 | 6 years ago |
|
|
3ebf46dae6 | 6 years ago |
|
|
f76ef16e9f | 6 years ago |
|
|
567c74c508 | 6 years ago |
|
|
54d562bfd9 | 6 years ago |
|
|
c75ad203e9 | 6 years ago |
|
|
e33026f38a | 6 years ago |
|
|
78f894f607 | 6 years ago |
|
|
725b17a111 | 6 years ago |
|
|
e11b2108fa | 6 years ago |
|
|
f7cf83eab3 | 6 years ago |
|
|
7bfbbe47bc | 6 years ago |
|
|
bf9833bd94 | 6 years ago |
|
|
935966a2c2 | 6 years ago |
|
|
e0bf9c9cfa | 6 years ago |
|
|
fef18931bd | 6 years ago |
|
|
f893d5bb86 | 6 years ago |
|
|
ff6ba9edcc | 6 years ago |
|
|
6887a320a5 | 6 years ago |
|
|
ea91f26f06 | 6 years ago |
|
|
59cdce6a88 | 6 years ago |
|
|
91341b81bd | 6 years ago |
@ -1,7 +1,8 @@
|
||||
include LICENSE.txt
|
||||
include README.md
|
||||
|
||||
recursive-include ppocr/utils *.txt utility.py logging.py
|
||||
recursive-include ppocr/data/ *.py
|
||||
recursive-include ppocr/utils *.txt utility.py character.py check.py
|
||||
recursive-include ppocr/data/det *.py
|
||||
recursive-include ppocr/postprocess *.py
|
||||
recursive-include tools/infer *.py
|
||||
recursive-include ppocr/postprocess/lanms *.*
|
||||
recursive-include tools/infer *.py
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
# ex: set ts=8 noet:
|
||||
|
||||
all: qt5 test
|
||||
|
||||
test: testpy3
|
||||
|
||||
testpy2:
|
||||
python -m unittest discover tests
|
||||
|
||||
testpy3:
|
||||
python3 -m unittest discover tests
|
||||
|
||||
qt4: qt4py2
|
||||
|
||||
qt5: qt5py3
|
||||
|
||||
qt4py2:
|
||||
pyrcc4 -py2 -o libs/resources.py resources.qrc
|
||||
|
||||
qt4py3:
|
||||
pyrcc4 -py3 -o libs/resources.py resources.qrc
|
||||
|
||||
qt5py3:
|
||||
pyrcc5 -o libs/resources.py resources.qrc
|
||||
|
||||
clean:
|
||||
rm -rf ~/.labelImgSettings.pkl *.pyc dist labelImg.egg-info __pycache__ build
|
||||
|
||||
pip_upload:
|
||||
python3 setup.py upload
|
||||
|
||||
long_description:
|
||||
restview --long-description
|
||||
|
||||
.PHONY: all
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
import sys
|
||||
try:
|
||||
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QComboBox
|
||||
except ImportError:
|
||||
# needed for py3+qt4
|
||||
# Ref:
|
||||
# http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
|
||||
# http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
|
||||
if sys.version_info.major >= 3:
|
||||
import sip
|
||||
sip.setapi('QVariant', 2)
|
||||
from PyQt4.QtGui import QWidget, QHBoxLayout, QComboBox
|
||||
|
||||
|
||||
class ComboBox(QWidget):
|
||||
def __init__(self, parent=None, items=[]):
|
||||
super(ComboBox, self).__init__(parent)
|
||||
|
||||
layout = QHBoxLayout()
|
||||
self.cb = QComboBox()
|
||||
self.items = items
|
||||
self.cb.addItems(self.items)
|
||||
|
||||
self.cb.currentIndexChanged.connect(parent.comboSelectionChanged)
|
||||
|
||||
layout.addWidget(self.cb)
|
||||
self.setLayout(layout)
|
||||
|
||||
def update_items(self, items):
|
||||
self.items = items
|
||||
|
||||
self.cb.clear()
|
||||
self.cb.addItems(self.items)
|
||||
|
Before Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 4.8 MiB |
|
Before Width: | Height: | Size: 6.4 KiB |
@ -1,2 +0,0 @@
|
||||
__version_info__ = ('1', '0', '0')
|
||||
__version__ = '.'.join(__version_info__)
|
||||
@ -1,162 +0,0 @@
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
import json
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from libs.utils import newIcon
|
||||
|
||||
BB = QDialogButtonBox
|
||||
|
||||
|
||||
class Worker(QThread):
|
||||
progressBarValue = pyqtSignal(int)
|
||||
listValue = pyqtSignal(str)
|
||||
endsignal = pyqtSignal(int, str)
|
||||
handle = 0
|
||||
|
||||
def __init__(self, ocr, mImgList, mainThread, model):
|
||||
super(Worker, self).__init__()
|
||||
self.ocr = ocr
|
||||
self.mImgList = mImgList
|
||||
self.mainThread = mainThread
|
||||
self.model = model
|
||||
self.setStackSize(1024*1024)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
findex = 0
|
||||
for Imgpath in self.mImgList:
|
||||
if self.handle == 0:
|
||||
self.listValue.emit(Imgpath)
|
||||
if self.model == 'paddle':
|
||||
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', Imgpath)
|
||||
pass
|
||||
else:
|
||||
strs = ''
|
||||
for res in self.result_dic:
|
||||
chars = res[1][0]
|
||||
cond = res[1][1]
|
||||
posi = res[0]
|
||||
strs += "Transcription: " + chars + " Probability: " + str(cond) + \
|
||||
" Location: " + json.dumps(posi) +'\n'
|
||||
# Sending large amounts of data repeatedly through pyqtSignal may affect the program efficiency
|
||||
self.listValue.emit(strs)
|
||||
self.mainThread.result_dic = self.result_dic
|
||||
self.mainThread.filePath = Imgpath
|
||||
# 保存
|
||||
self.mainThread.saveFile(mode='Auto')
|
||||
findex += 1
|
||||
self.progressBarValue.emit(findex)
|
||||
else:
|
||||
break
|
||||
self.endsignal.emit(0, "readAll")
|
||||
self.exec()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
raise
|
||||
|
||||
|
||||
class AutoDialog(QDialog):
|
||||
|
||||
def __init__(self, text="Enter object label", parent=None, ocr=None, mImgList=None, lenbar=0):
|
||||
super(AutoDialog, self).__init__(parent)
|
||||
self.setFixedWidth(1000)
|
||||
self.parent = parent
|
||||
self.ocr = ocr
|
||||
self.mImgList = mImgList
|
||||
self.pb = QProgressBar()
|
||||
self.pb.setRange(0, lenbar)
|
||||
self.pb.setValue(0)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(self.pb)
|
||||
self.model = 'paddle'
|
||||
self.listWidget = QListWidget(self)
|
||||
layout.addWidget(self.listWidget)
|
||||
|
||||
self.buttonBox = bb = BB(BB.Ok | BB.Cancel, Qt.Horizontal, self)
|
||||
bb.button(BB.Ok).setIcon(newIcon('done'))
|
||||
bb.button(BB.Cancel).setIcon(newIcon('undo'))
|
||||
bb.accepted.connect(self.validate)
|
||||
bb.rejected.connect(self.reject)
|
||||
layout.addWidget(bb)
|
||||
bb.button(BB.Ok).setEnabled(False)
|
||||
|
||||
self.setLayout(layout)
|
||||
# self.setWindowTitle("自动标注中")
|
||||
self.setWindowModality(Qt.ApplicationModal)
|
||||
|
||||
# self.setWindowFlags(Qt.WindowCloseButtonHint)
|
||||
|
||||
self.thread_1 = Worker(self.ocr, self.mImgList, self.parent, 'paddle')
|
||||
self.thread_1.progressBarValue.connect(self.handleProgressBarSingal)
|
||||
self.thread_1.listValue.connect(self.handleListWidgetSingal)
|
||||
self.thread_1.endsignal.connect(self.handleEndsignalSignal)
|
||||
|
||||
def handleProgressBarSingal(self, i):
|
||||
self.pb.setValue(i)
|
||||
|
||||
def handleListWidgetSingal(self, i):
|
||||
self.listWidget.addItem(i)
|
||||
titem = self.listWidget.item(self.listWidget.count() - 1)
|
||||
self.listWidget.scrollToItem(titem)
|
||||
|
||||
def handleEndsignalSignal(self, i, str):
|
||||
if i == 0 and str == "readAll":
|
||||
self.buttonBox.button(BB.Ok).setEnabled(True)
|
||||
self.buttonBox.button(BB.Cancel).setEnabled(False)
|
||||
|
||||
def reject(self):
|
||||
print("reject")
|
||||
self.thread_1.handle = -1
|
||||
self.thread_1.quit()
|
||||
# del self.thread_1
|
||||
# if self.thread_1.isRunning():
|
||||
# self.thread_1.terminate()
|
||||
# self.thread_1.quit()
|
||||
# super(AutoDialog,self).reject()
|
||||
while not self.thread_1.isFinished():
|
||||
pass
|
||||
self.accept()
|
||||
|
||||
def validate(self):
|
||||
self.accept()
|
||||
|
||||
def postProcess(self):
|
||||
try:
|
||||
self.edit.setText(self.edit.text().trimmed())
|
||||
# print(self.edit.text())
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
self.edit.setText(self.edit.text())
|
||||
print(self.edit.text())
|
||||
|
||||
def popUp(self):
|
||||
self.thread_1.start()
|
||||
return 1 if self.exec_() else None
|
||||
|
||||
def closeEvent(self, event):
|
||||
print("???")
|
||||
# if self.thread_1.isRunning():
|
||||
# self.thread_1.quit()
|
||||
#
|
||||
# # self._thread.terminate()
|
||||
# # del self.thread_1
|
||||
# super(AutoDialog, self).closeEvent(event)
|
||||
self.reject()
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,49 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import QColorDialog, QDialogButtonBox
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
BB = QDialogButtonBox
|
||||
|
||||
|
||||
class ColorDialog(QColorDialog):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(ColorDialog, self).__init__(parent)
|
||||
self.setOption(QColorDialog.ShowAlphaChannel)
|
||||
# The Mac native dialog does not support our restore button.
|
||||
self.setOption(QColorDialog.DontUseNativeDialog)
|
||||
# Add a restore defaults button.
|
||||
# The default is set at invocation time, so that it
|
||||
# works across dialogs for different elements.
|
||||
self.default = None
|
||||
self.bb = self.layout().itemAt(1).widget()
|
||||
self.bb.addButton(BB.RestoreDefaults)
|
||||
self.bb.clicked.connect(self.checkRestore)
|
||||
|
||||
def getColor(self, value=None, title=None, default=None):
|
||||
self.default = default
|
||||
if title:
|
||||
self.setWindowTitle(title)
|
||||
if value:
|
||||
self.setCurrentColor(value)
|
||||
return self.currentColor() if self.exec_() else None
|
||||
|
||||
def checkRestore(self, button):
|
||||
if self.bb.buttonRole(button) & BB.ResetRole and self.default:
|
||||
self.setCurrentColor(self.default)
|
||||
@ -1,31 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
SETTING_FILENAME = 'filename'
|
||||
SETTING_RECENT_FILES = 'recentFiles'
|
||||
SETTING_WIN_SIZE = 'window/size'
|
||||
SETTING_WIN_POSE = 'window/position'
|
||||
SETTING_WIN_GEOMETRY = 'window/geometry'
|
||||
SETTING_LINE_COLOR = 'line/color'
|
||||
SETTING_FILL_COLOR = 'fill/color'
|
||||
SETTING_ADVANCE_MODE = 'advanced'
|
||||
SETTING_WIN_STATE = 'window/state'
|
||||
SETTING_SAVE_DIR = 'savedir'
|
||||
SETTING_PAINT_LABEL = 'paintlabel'
|
||||
SETTING_LAST_OPEN_DIR = 'lastOpenDir'
|
||||
SETTING_AUTO_SAVE = 'autosave'
|
||||
SETTING_SINGLE_CLASS = 'singleclass'
|
||||
FORMAT_PASCALVOC='PascalVOC'
|
||||
FORMAT_YOLO='YOLO'
|
||||
SETTING_DRAW_SQUARE = 'draw/square'
|
||||
SETTING_LABEL_FILE_FORMAT= 'labelFileFormat'
|
||||
DEFAULT_ENCODING = 'utf-8'
|
||||
@ -1,143 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf8 -*-
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from libs.constants import DEFAULT_ENCODING
|
||||
import os
|
||||
|
||||
JSON_EXT = '.json'
|
||||
ENCODE_METHOD = DEFAULT_ENCODING
|
||||
|
||||
|
||||
class CreateMLWriter:
|
||||
def __init__(self, foldername, filename, imgsize, shapes, outputfile, databasesrc='Unknown', localimgpath=None):
|
||||
self.foldername = foldername
|
||||
self.filename = filename
|
||||
self.databasesrc = databasesrc
|
||||
self.imgsize = imgsize
|
||||
self.boxlist = []
|
||||
self.localimgpath = localimgpath
|
||||
self.verified = False
|
||||
self.shapes = shapes
|
||||
self.outputfile = outputfile
|
||||
|
||||
def write(self):
|
||||
if os.path.isfile(self.outputfile):
|
||||
with open(self.outputfile, "r") as file:
|
||||
input_data = file.read()
|
||||
outputdict = json.loads(input_data)
|
||||
else:
|
||||
outputdict = []
|
||||
|
||||
outputimagedict = {
|
||||
"image": self.filename,
|
||||
"annotations": []
|
||||
}
|
||||
|
||||
for shape in self.shapes:
|
||||
points = shape["points"]
|
||||
|
||||
x1 = points[0][0]
|
||||
y1 = points[0][1]
|
||||
x2 = points[1][0]
|
||||
y2 = points[2][1]
|
||||
|
||||
height, width, x, y = self.calculate_coordinates(x1, x2, y1, y2)
|
||||
|
||||
shapedict = {
|
||||
"label": shape["label"],
|
||||
"coordinates": {
|
||||
"x": x,
|
||||
"y": y,
|
||||
"width": width,
|
||||
"height": height
|
||||
}
|
||||
}
|
||||
outputimagedict["annotations"].append(shapedict)
|
||||
|
||||
# check if image already in output
|
||||
exists = False
|
||||
for i in range(0, len(outputdict)):
|
||||
if outputdict[i]["image"] == outputimagedict["image"]:
|
||||
exists = True
|
||||
outputdict[i] = outputimagedict
|
||||
break
|
||||
|
||||
if not exists:
|
||||
outputdict.append(outputimagedict)
|
||||
|
||||
Path(self.outputfile).write_text(json.dumps(outputdict), ENCODE_METHOD)
|
||||
|
||||
def calculate_coordinates(self, x1, x2, y1, y2):
|
||||
if x1 < x2:
|
||||
xmin = x1
|
||||
xmax = x2
|
||||
else:
|
||||
xmin = x2
|
||||
xmax = x1
|
||||
if y1 < y2:
|
||||
ymin = y1
|
||||
ymax = y2
|
||||
else:
|
||||
ymin = y2
|
||||
ymax = y1
|
||||
width = xmax - xmin
|
||||
if width < 0:
|
||||
width = width * -1
|
||||
height = ymax - ymin
|
||||
# x and y from center of rect
|
||||
x = xmin + width / 2
|
||||
y = ymin + height / 2
|
||||
return height, width, x, y
|
||||
|
||||
|
||||
class CreateMLReader:
|
||||
def __init__(self, jsonpath, filepath):
|
||||
self.jsonpath = jsonpath
|
||||
self.shapes = []
|
||||
self.verified = False
|
||||
self.filename = filepath.split("/")[-1:][0]
|
||||
try:
|
||||
self.parse_json()
|
||||
except ValueError:
|
||||
print("JSON decoding failed")
|
||||
|
||||
def parse_json(self):
|
||||
with open(self.jsonpath, "r") as file:
|
||||
inputdata = file.read()
|
||||
|
||||
outputdict = json.loads(inputdata)
|
||||
self.verified = True
|
||||
|
||||
if len(self.shapes) > 0:
|
||||
self.shapes = []
|
||||
for image in outputdict:
|
||||
if image["image"] == self.filename:
|
||||
for shape in image["annotations"]:
|
||||
self.add_shape(shape["label"], shape["coordinates"])
|
||||
|
||||
def add_shape(self, label, bndbox):
|
||||
xmin = bndbox["x"] - (bndbox["width"] / 2)
|
||||
ymin = bndbox["y"] - (bndbox["height"] / 2)
|
||||
|
||||
xmax = bndbox["x"] + (bndbox["width"] / 2)
|
||||
ymax = bndbox["y"] + (bndbox["height"] / 2)
|
||||
|
||||
points = [(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)]
|
||||
self.shapes.append((label, points, None, None, True))
|
||||
|
||||
def get_shapes(self):
|
||||
return self.shapes
|
||||
@ -1,31 +0,0 @@
|
||||
import sys, time
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
class EditInList(QListWidget):
|
||||
def __init__(self):
|
||||
super(EditInList,self).__init__()
|
||||
# click to edit
|
||||
self.clicked.connect(self.item_clicked)
|
||||
|
||||
def item_clicked(self, modelindex: QModelIndex) -> None:
|
||||
self.edited_item = self.currentItem()
|
||||
self.closePersistentEditor(self.edited_item)
|
||||
item = self.item(modelindex.row())
|
||||
# time.sleep(0.2)
|
||||
self.edited_item = item
|
||||
self.openPersistentEditor(item)
|
||||
# time.sleep(0.2)
|
||||
self.editItem(item)
|
||||
|
||||
def mouseDoubleClickEvent(self, event):
|
||||
# close edit
|
||||
for i in range(self.count()):
|
||||
self.closePersistentEditor(self.item(i))
|
||||
|
||||
def leaveEvent(self, event):
|
||||
# close edit
|
||||
for i in range(self.count()):
|
||||
self.closePersistentEditor(self.item(i))
|
||||
@ -1,40 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
# needed for py3+qt4
|
||||
# Ref:
|
||||
# http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
|
||||
# http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
|
||||
if sys.version_info.major >= 3:
|
||||
import sip
|
||||
sip.setapi('QVariant', 2)
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
# PyQt5: TypeError: unhashable type: 'QListWidgetItem'
|
||||
|
||||
|
||||
class HashableQListWidgetItem(QListWidgetItem):
|
||||
|
||||
def __init__(self, *args):
|
||||
super(HashableQListWidgetItem, self).__init__(*args)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(id(self))
|
||||
@ -1,107 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
from libs.utils import newIcon, labelValidator
|
||||
|
||||
BB = QDialogButtonBox
|
||||
|
||||
|
||||
class LabelDialog(QDialog):
|
||||
|
||||
def __init__(self, text="Enter object label", parent=None, listItem=None):
|
||||
super(LabelDialog, self).__init__(parent)
|
||||
|
||||
self.edit = QLineEdit() # OLD
|
||||
# self.edit = QTextEdit()
|
||||
self.edit.setText(text)
|
||||
# self.edit.setValidator(labelValidator()) # 验证有效性
|
||||
self.edit.editingFinished.connect(self.postProcess)
|
||||
|
||||
model = QStringListModel()
|
||||
model.setStringList(listItem)
|
||||
completer = QCompleter()
|
||||
completer.setModel(model)
|
||||
self.edit.setCompleter(completer)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(self.edit)
|
||||
self.buttonBox = bb = BB(BB.Ok | BB.Cancel, Qt.Horizontal, self)
|
||||
bb.button(BB.Ok).setIcon(newIcon('done'))
|
||||
bb.button(BB.Cancel).setIcon(newIcon('undo'))
|
||||
bb.accepted.connect(self.validate)
|
||||
bb.rejected.connect(self.reject)
|
||||
layout.addWidget(bb)
|
||||
|
||||
# if listItem is not None and len(listItem) > 0:
|
||||
# self.listWidget = QListWidget(self)
|
||||
# for item in listItem:
|
||||
# self.listWidget.addItem(item)
|
||||
# self.listWidget.itemClicked.connect(self.listItemClick)
|
||||
# self.listWidget.itemDoubleClicked.connect(self.listItemDoubleClick)
|
||||
# layout.addWidget(self.listWidget)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
def validate(self):
|
||||
try:
|
||||
if self.edit.text().trimmed():
|
||||
self.accept()
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
if self.edit.text().strip():
|
||||
self.accept()
|
||||
|
||||
def postProcess(self):
|
||||
try:
|
||||
self.edit.setText(self.edit.text().trimmed())
|
||||
# print(self.edit.text())
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
self.edit.setText(self.edit.text())
|
||||
print(self.edit.text())
|
||||
|
||||
def popUp(self, text='', move=True):
|
||||
self.edit.setText(text)
|
||||
self.edit.setSelection(0, len(text))
|
||||
self.edit.setFocus(Qt.PopupFocusReason)
|
||||
if move:
|
||||
cursor_pos = QCursor.pos()
|
||||
parent_bottomRight = self.parentWidget().geometry()
|
||||
max_x = parent_bottomRight.x() + parent_bottomRight.width() - self.sizeHint().width()
|
||||
max_y = parent_bottomRight.y() + parent_bottomRight.height() - self.sizeHint().height()
|
||||
max_global = self.parentWidget().mapToGlobal(QPoint(max_x, max_y))
|
||||
if cursor_pos.x() > max_global.x():
|
||||
cursor_pos.setX(max_global.x())
|
||||
if cursor_pos.y() > max_global.y():
|
||||
cursor_pos.setY(max_global.y())
|
||||
self.move(cursor_pos)
|
||||
return self.edit.text() if self.exec_() else None
|
||||
|
||||
def listItemClick(self, tQListWidgetItem):
|
||||
try:
|
||||
text = tQListWidgetItem.text().trimmed()
|
||||
except AttributeError:
|
||||
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
|
||||
text = tQListWidgetItem.text().strip()
|
||||
self.edit.setText(text)
|
||||
|
||||
def listItemDoubleClick(self, tQListWidgetItem):
|
||||
self.listItemClick(tQListWidgetItem)
|
||||
self.validate()
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,60 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
import pickle
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class Settings(object):
|
||||
def __init__(self):
|
||||
# Be default, the home will be in the same folder as labelImg
|
||||
home = os.path.expanduser("~")
|
||||
self.data = {}
|
||||
# self.path = os.path.join(home, '.labelImgSettings.pkl')
|
||||
self.path = os.path.join(home, '.autoOCRSettings.pkl')
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.data[key] = value
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.data[key]
|
||||
|
||||
def get(self, key, default=None):
|
||||
if key in self.data:
|
||||
return self.data[key]
|
||||
return default
|
||||
|
||||
def save(self):
|
||||
if self.path:
|
||||
with open(self.path, 'wb') as f:
|
||||
pickle.dump(self.data, f, pickle.HIGHEST_PROTOCOL)
|
||||
return True
|
||||
return False
|
||||
|
||||
def load(self):
|
||||
try:
|
||||
if os.path.exists(self.path):
|
||||
with open(self.path, 'rb') as f:
|
||||
self.data = pickle.load(f)
|
||||
return True
|
||||
except:
|
||||
print('Loading setting failed')
|
||||
return False
|
||||
|
||||
def reset(self):
|
||||
if os.path.exists(self.path):
|
||||
os.remove(self.path)
|
||||
print('Remove setting pkl file ${0}'.format(self.path))
|
||||
self.data = {}
|
||||
self.path = None
|
||||
@ -1,217 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
from libs.utils import distance
|
||||
import sys
|
||||
|
||||
DEFAULT_LINE_COLOR = QColor(0, 255, 0, 128)
|
||||
DEFAULT_FILL_COLOR = QColor(255, 0, 0, 128)
|
||||
DEFAULT_SELECT_LINE_COLOR = QColor(255, 255, 255)
|
||||
DEFAULT_SELECT_FILL_COLOR = QColor(0, 128, 255, 155)
|
||||
DEFAULT_VERTEX_FILL_COLOR = QColor(0, 255, 0, 255)
|
||||
DEFAULT_HVERTEX_FILL_COLOR = QColor(255, 0, 0)
|
||||
MIN_Y_LABEL = 10
|
||||
|
||||
|
||||
class Shape(object):
|
||||
P_SQUARE, P_ROUND = range(2)
|
||||
|
||||
MOVE_VERTEX, NEAR_VERTEX = range(2)
|
||||
|
||||
# The following class variables influence the drawing
|
||||
# of _all_ shape objects.
|
||||
line_color = DEFAULT_LINE_COLOR
|
||||
fill_color = DEFAULT_FILL_COLOR
|
||||
select_line_color = DEFAULT_SELECT_LINE_COLOR
|
||||
select_fill_color = DEFAULT_SELECT_FILL_COLOR
|
||||
vertex_fill_color = DEFAULT_VERTEX_FILL_COLOR
|
||||
hvertex_fill_color = DEFAULT_HVERTEX_FILL_COLOR
|
||||
point_type = P_ROUND
|
||||
point_size = 8
|
||||
scale = 1.0
|
||||
|
||||
def __init__(self, label=None, line_color=None, difficult=False, paintLabel=False):
|
||||
self.label = label
|
||||
self.points = []
|
||||
self.fill = False
|
||||
self.selected = False
|
||||
self.difficult = difficult
|
||||
self.paintLabel = paintLabel
|
||||
|
||||
self._highlightIndex = None
|
||||
self._highlightMode = self.NEAR_VERTEX
|
||||
self._highlightSettings = {
|
||||
self.NEAR_VERTEX: (4, self.P_ROUND),
|
||||
self.MOVE_VERTEX: (1.5, self.P_SQUARE),
|
||||
}
|
||||
|
||||
self._closed = False
|
||||
|
||||
if line_color is not None:
|
||||
# Override the class line_color attribute
|
||||
# with an object attribute. Currently this
|
||||
# is used for drawing the pending line a different color.
|
||||
self.line_color = line_color
|
||||
|
||||
def close(self):
|
||||
self._closed = True
|
||||
|
||||
def reachMaxPoints(self):
|
||||
if len(self.points) >= 4:
|
||||
return True
|
||||
return False
|
||||
|
||||
def addPoint(self, point):
|
||||
if not self.reachMaxPoints():
|
||||
self.points.append(point)
|
||||
|
||||
def popPoint(self):
|
||||
if self.points:
|
||||
return self.points.pop()
|
||||
return None
|
||||
|
||||
def isClosed(self):
|
||||
return self._closed
|
||||
|
||||
def setOpen(self):
|
||||
self._closed = False
|
||||
|
||||
def paint(self, painter):
|
||||
if self.points:
|
||||
color = self.select_line_color if self.selected else self.line_color
|
||||
pen = QPen(color)
|
||||
# Try using integer sizes for smoother drawing(?)
|
||||
pen.setWidth(max(1, int(round(2.0 / self.scale))))
|
||||
painter.setPen(pen)
|
||||
|
||||
line_path = QPainterPath()
|
||||
vrtx_path = QPainterPath()
|
||||
|
||||
line_path.moveTo(self.points[0])
|
||||
# Uncommenting the following line will draw 2 paths
|
||||
# for the 1st vertex, and make it non-filled, which
|
||||
# may be desirable.
|
||||
#self.drawVertex(vrtx_path, 0)
|
||||
|
||||
for i, p in enumerate(self.points):
|
||||
line_path.lineTo(p)
|
||||
self.drawVertex(vrtx_path, i)
|
||||
if self.isClosed():
|
||||
line_path.lineTo(self.points[0])
|
||||
|
||||
painter.drawPath(line_path)
|
||||
painter.drawPath(vrtx_path)
|
||||
painter.fillPath(vrtx_path, self.vertex_fill_color)
|
||||
|
||||
# Draw text at the top-left
|
||||
if self.paintLabel:
|
||||
min_x = sys.maxsize
|
||||
min_y = sys.maxsize
|
||||
for point in self.points:
|
||||
min_x = min(min_x, point.x())
|
||||
min_y = min(min_y, point.y())
|
||||
if min_x != sys.maxsize and min_y != sys.maxsize:
|
||||
font = QFont()
|
||||
font.setPointSize(8)
|
||||
font.setBold(True)
|
||||
painter.setFont(font)
|
||||
if(self.label == None):
|
||||
self.label = ""
|
||||
if(min_y < MIN_Y_LABEL):
|
||||
min_y += MIN_Y_LABEL
|
||||
painter.drawText(min_x, min_y, self.label)
|
||||
|
||||
if self.fill:
|
||||
color = self.select_fill_color if self.selected else self.fill_color
|
||||
painter.fillPath(line_path, color)
|
||||
|
||||
def drawVertex(self, path, i):
|
||||
d = self.point_size / self.scale
|
||||
shape = self.point_type
|
||||
point = self.points[i]
|
||||
if i == self._highlightIndex:
|
||||
size, shape = self._highlightSettings[self._highlightMode]
|
||||
d *= size
|
||||
if self._highlightIndex is not None:
|
||||
self.vertex_fill_color = self.hvertex_fill_color
|
||||
else:
|
||||
self.vertex_fill_color = Shape.vertex_fill_color
|
||||
if shape == self.P_SQUARE:
|
||||
path.addRect(point.x() - d / 2, point.y() - d / 2, d, d)
|
||||
elif shape == self.P_ROUND:
|
||||
path.addEllipse(point, d / 2.0, d / 2.0)
|
||||
else:
|
||||
assert False, "unsupported vertex shape"
|
||||
|
||||
def nearestVertex(self, point, epsilon):
|
||||
for i, p in enumerate(self.points):
|
||||
if distance(p - point) <= epsilon:
|
||||
return i
|
||||
return None
|
||||
|
||||
def containsPoint(self, point):
|
||||
return self.makePath().contains(point)
|
||||
|
||||
def makePath(self):
|
||||
path = QPainterPath(self.points[0])
|
||||
for p in self.points[1:]:
|
||||
path.lineTo(p)
|
||||
return path
|
||||
|
||||
def boundingRect(self):
|
||||
return self.makePath().boundingRect()
|
||||
|
||||
def moveBy(self, offset):
|
||||
self.points = [p + offset for p in self.points]
|
||||
|
||||
def moveVertexBy(self, i, offset):
|
||||
self.points[i] = self.points[i] + offset
|
||||
|
||||
def highlightVertex(self, i, action):
|
||||
self._highlightIndex = i
|
||||
self._highlightMode = action
|
||||
|
||||
def highlightClear(self):
|
||||
self._highlightIndex = None
|
||||
|
||||
def copy(self):
|
||||
shape = Shape("%s" % self.label)
|
||||
shape.points = [p for p in self.points]
|
||||
shape.fill = self.fill
|
||||
shape.selected = self.selected
|
||||
shape._closed = self._closed
|
||||
if self.line_color != Shape.line_color:
|
||||
shape.line_color = self.line_color
|
||||
if self.fill_color != Shape.fill_color:
|
||||
shape.fill_color = self.fill_color
|
||||
shape.difficult = self.difficult
|
||||
return shape
|
||||
|
||||
def __len__(self):
|
||||
return len(self.points)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.points[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.points[key] = value
|
||||
@ -1,86 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import locale
|
||||
from libs.ustr import ustr
|
||||
|
||||
try:
|
||||
from PyQt5.QtCore import *
|
||||
except ImportError:
|
||||
if sys.version_info.major >= 3:
|
||||
import sip
|
||||
sip.setapi('QVariant', 2)
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
|
||||
class StringBundle:
|
||||
|
||||
__create_key = object()
|
||||
|
||||
def __init__(self, create_key, localeStr):
|
||||
assert(create_key == StringBundle.__create_key), "StringBundle must be created using StringBundle.getBundle"
|
||||
self.idToMessage = {}
|
||||
paths = self.__createLookupFallbackList(localeStr)
|
||||
for path in paths:
|
||||
self.__loadBundle(path)
|
||||
|
||||
@classmethod
|
||||
def getBundle(cls, localeStr=None):
|
||||
if localeStr is None:
|
||||
try:
|
||||
localeStr = locale.getlocale()[0] if locale.getlocale() and len(
|
||||
locale.getlocale()) > 0 else os.getenv('LANG')
|
||||
except:
|
||||
print('Invalid locale')
|
||||
localeStr = 'en'
|
||||
|
||||
return StringBundle(cls.__create_key, localeStr)
|
||||
|
||||
def getString(self, stringId):
|
||||
assert(stringId in self.idToMessage), "Missing string id : " + stringId
|
||||
return self.idToMessage[stringId]
|
||||
|
||||
def __createLookupFallbackList(self, localeStr):
|
||||
resultPaths = []
|
||||
basePath = ":/strings"
|
||||
resultPaths.append(basePath)
|
||||
if localeStr is not None:
|
||||
# Don't follow standard BCP47. Simple fallback
|
||||
tags = re.split('[^a-zA-Z]', localeStr)
|
||||
for tag in tags:
|
||||
lastPath = resultPaths[-1]
|
||||
resultPaths.append(lastPath + '-' + tag)
|
||||
|
||||
return resultPaths
|
||||
|
||||
def __loadBundle(self, path):
|
||||
PROP_SEPERATOR = '='
|
||||
f = QFile(path)
|
||||
if f.exists():
|
||||
if f.open(QIODevice.ReadOnly | QFile.Text):
|
||||
text = QTextStream(f)
|
||||
text.setCodec("UTF-8")
|
||||
|
||||
while not text.atEnd():
|
||||
line = ustr(text.readLine())
|
||||
key_value = line.split(PROP_SEPERATOR)
|
||||
key = key_value[0].strip()
|
||||
value = PROP_SEPERATOR.join(key_value[1:]).strip().strip('"')
|
||||
self.idToMessage[key] = value
|
||||
|
||||
f.close()
|
||||
@ -1,51 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
try:
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
except ImportError:
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
|
||||
class ToolBar(QToolBar):
|
||||
|
||||
def __init__(self, title):
|
||||
super(ToolBar, self).__init__(title)
|
||||
layout = self.layout()
|
||||
m = (0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
layout.setContentsMargins(*m)
|
||||
self.setContentsMargins(*m)
|
||||
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
|
||||
|
||||
def addAction(self, action):
|
||||
if isinstance(action, QWidgetAction):
|
||||
return super(ToolBar, self).addAction(action)
|
||||
btn = ToolButton()
|
||||
btn.setDefaultAction(action)
|
||||
btn.setToolButtonStyle(self.toolButtonStyle())
|
||||
self.addWidget(btn)
|
||||
|
||||
|
||||
class ToolButton(QToolButton):
|
||||
"""ToolBar companion class which ensures all buttons have the same size."""
|
||||
minSize = (60, 60)
|
||||
|
||||
def minimumSizeHint(self):
|
||||
ms = super(ToolButton, self).minimumSizeHint()
|
||||
w1, h1 = ms.width(), ms.height()
|
||||
w2, h2 = self.minSize
|
||||
ToolButton.minSize = max(w1, w2), max(h1, h2)
|
||||
return QSize(*ToolButton.minSize)
|
||||
@ -1,29 +0,0 @@
|
||||
# Copyright (c) <2015-Present> Tzutalin
|
||||
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
|
||||
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
||||
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
import sys
|
||||
from libs.constants import DEFAULT_ENCODING
|
||||
|
||||
def ustr(x):
|
||||
'''py2/py3 unicode helper'''
|
||||
|
||||
if sys.version_info < (3, 0, 0):
|
||||
from PyQt4.QtCore import QString
|
||||
if type(x) == str:
|
||||
return x.decode(DEFAULT_ENCODING)
|
||||
if type(x) == QString:
|
||||
#https://blog.csdn.net/friendan/article/details/51088476
|
||||
#https://blog.csdn.net/xxm524/article/details/74937308
|
||||
return unicode(x.toUtf8(), DEFAULT_ENCODING, 'ignore')
|
||||
return x
|
||||
else:
|
||||
return x
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue