개정판 64c0fd17
fixed issue #479: 심볼 인식 시 프로그래스 바 표시
DTI_PID/DTI_PID/DTI_PID.py | ||
---|---|---|
292 | 292 |
#print("match Count : " + str(matchCount)) |
293 | 293 |
return matchCount |
294 | 294 |
|
295 |
|
|
296 |
#detect symbols on PID |
|
297 |
def detectSymbolsOnPid(mainRes, targetSymbols, listWidget): |
|
295 |
''' |
|
296 |
@brief detect symbols on PID |
|
297 |
@history humkyung 2018.06.08 add parameteres for signal |
|
298 |
''' |
|
299 |
def detectSymbolsOnPid(mainRes, targetSymbols, listWidget, updateProgressSignal): |
|
298 | 300 |
for detailTarget in targetSymbols: |
299 |
detectSymbolOnPid(mainRes, detailTarget, listWidget) |
|
301 |
detectSymbolOnPid(mainRes, detailTarget, listWidget, updateProgressSignal)
|
|
300 | 302 |
|
301 | 303 |
''' |
302 | 304 |
@brief detect symbol on PID |
... | ... | |
307 | 309 |
Change parameter on add symbol part (mpCount → hitRate) |
308 | 310 |
Remove unusing calculation (avg) |
309 | 311 |
''' |
310 |
def detectSymbolOnPid(mainRes, targetSymbol, listWidget): |
|
312 |
def detectSymbolOnPid(mainRes, targetSymbol, listWidget, updateProgressSignal):
|
|
311 | 313 |
global src |
312 | 314 |
global srcGray |
313 | 315 |
global ocrCompletedSrc |
314 | 316 |
global afterDenoising |
315 | 317 |
global threadLock |
316 | 318 |
global searchedSymbolList |
319 |
global maxProgressValue |
|
317 | 320 |
|
318 | 321 |
symId = targetSymbol.getId() |
319 | 322 |
symbolName = targetSymbol.getName() |
... | ... | |
502 | 505 |
listWidget.addItem('Finish Symbol : ' + os.path.basename(symbolPath.replace('.png', '')) + ' - (' + str(foundSymbolCount) + ')') |
503 | 506 |
threadLock.release() |
504 | 507 |
|
508 |
updateProgressSignal.emit(maxProgressValue) |
|
509 |
|
|
505 | 510 |
''' |
506 | 511 |
@history 2018.05.17 Jeongwoo Bitwise_not target changed (Original Image → Symbol Image) |
507 | 512 |
''' |
... | ... | |
871 | 876 |
humkyung 2018.05.26 add parameters(graphicsView, isSymbolTextChecked, isLineChecked) |
872 | 877 |
Jeongwoo 2018.05.28 Add/Remove Parameters(Add : signal / Remove : graphicsView, isLineChecked) |
873 | 878 |
Jeongwoo 2018.05.30 Remove return value |
879 |
humkyung 2018.06.08 add signal for progressbar to parameter |
|
874 | 880 |
''' |
875 |
def executeRecognition(signal, path, listWidget, isSymbolTextChecked): |
|
881 |
def executeRecognition(signal, updateProgressSignal, path, listWidget, isSymbolTextChecked):
|
|
876 | 882 |
global src |
877 | 883 |
global srcGray |
878 | 884 |
global ocrCompletedSrc |
... | ... | |
880 | 886 |
global threadLock |
881 | 887 |
global textInfoList |
882 | 888 |
global noteTextInfoList |
889 |
global maxProgressValue |
|
883 | 890 |
|
884 | 891 |
#res = [] |
885 | 892 |
try: |
... | ... | |
925 | 932 |
if isSymbolTextChecked: |
926 | 933 |
initMainSrc(mainRes) |
927 | 934 |
|
928 |
#threadLock = threading.Lock() |
|
935 |
threadLock.acquire() |
|
936 |
### calculate total count of symbol |
|
937 |
maxProgressValue = 0 |
|
938 |
for targetItem in targetSymbolList: |
|
939 |
if type(targetItem) is list: |
|
940 |
maxProgressValue += len(targetItem) |
|
941 |
else: |
|
942 |
maxProgressValue += 1 |
|
943 |
print('totalCount = {}'.format(maxProgressValue)) |
|
944 |
### up to here |
|
945 |
threadLock.release() |
|
946 |
|
|
929 | 947 |
pool = futures.ThreadPoolExecutor(max_workers = THREAD_MAX_WORKER) |
930 | 948 |
for targetItem in targetSymbolList: |
931 |
if type(targetItem).__name__ == 'list': |
|
932 |
#detectSymbolsOnPid(mainRes, target) |
|
933 |
pool.submit(detectSymbolsOnPid, mainRes, targetItem, listWidget) |
|
949 |
if type(targetItem) is list: |
|
950 |
pool.submit(detectSymbolsOnPid, mainRes, targetItem, listWidget, updateProgressSignal) |
|
934 | 951 |
else: |
935 |
#detectSymbolOnPid(mainRes, target) |
|
936 |
pool.submit(detectSymbolOnPid, mainRes, targetItem, listWidget) |
|
952 |
pool.submit(detectSymbolOnPid, mainRes, targetItem, listWidget, updateProgressSignal) |
|
937 | 953 |
|
938 | 954 |
pool.shutdown(wait = True) |
939 | 955 |
|
... | ... | |
950 | 966 |
#drawRectOnSrc() |
951 | 967 |
#threadLock.release() |
952 | 968 |
pool.shutdown(wait = True) |
953 |
cv2.imwrite('D:/Visual Studio Project/DTIPID/DTIPID/DTI_PID/DTI_PID/res/Result/PC-K/remove_symbol.png', srcGray.copy()) |
|
969 |
#cv2.imwrite('D:/Visual Studio Project/DTIPID/DTIPID/DTI_PID/DTI_PID/res/Result/PC-K/remove_symbol.png', srcGray.copy())
|
|
954 | 970 |
|
955 | 971 |
####area = AppDocData.instance().getArea('Drawing') |
956 | 972 |
####(_tempOcrSrc, tInfoList) = OCR.removeTextFromNpArray(area.img if area is not None else srcGray, area.x if area is not None else 0, area.y if area is not None else 0) |
... | ... | |
982 | 998 |
listWidget.addItem("Searched symbol count : " + str(len(searchedSymbolList))) |
983 | 999 |
|
984 | 1000 |
signal.emit(searchedSymbolList, textInfoList, noteTextInfoList) |
985 |
|
|
986 |
#xmlPath = xg.writeXml(docData.imgName, docData.imgWidth, docData.imgHeight, searchedSymbolList, textInfoList, noteTextInfoList) |
|
987 |
#res.append(xmlPath) |
|
988 | 1001 |
except Exception as ex: |
989 | 1002 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
990 | 1003 |
|
DTI_PID/DTI_PID/QRecognitionDialog.py | ||
---|---|---|
27 | 27 |
|
28 | 28 |
''' |
29 | 29 |
@history 2018.05.30 Jeongwoo Remove parameter on recognizeLine signal / Change signal name (drawDetectedItems) |
30 |
@history humkyung 2018.06.08 add signal for progressbar |
|
30 | 31 |
''' |
31 | 32 |
finished = pyqtSignal() |
32 | 33 |
intReady = pyqtSignal(int) |
33 | 34 |
recognizeLine = pyqtSignal(QListWidget, QtImageViewer) |
34 | 35 |
drawDetectedItems = pyqtSignal(list, list, list) |
36 |
updateProgress = pyqtSignal(int) |
|
35 | 37 |
|
36 | 38 |
''' |
37 | 39 |
@history 2018.05.25 Jeongwoo Add if-statements by isSymbolTextChecked and isLineChecked variable |
... | ... | |
46 | 48 |
|
47 | 49 |
try: |
48 | 50 |
start = timeit.default_timer() |
49 |
executeRecognition(self.drawDetectedItems, self.path, self.listWidget, self.isSymbolTextChecked) |
|
51 |
executeRecognition(self.drawDetectedItems, self.updateProgress, self.path, self.listWidget, self.isSymbolTextChecked)
|
|
50 | 52 |
if self.isLineChecked: |
51 | 53 |
self.recognizeLine.emit(self.listWidget, self.graphicsView) |
52 | 54 |
self.finished.emit() |
... | ... | |
55 | 57 |
finally: |
56 | 58 |
stop = timeit.default_timer() |
57 | 59 |
seconds = stop - start |
58 |
self.listWidget.addItem("\nRunning Time : " + str(seconds / 60) + "min\n")
|
|
60 |
self.listWidget.addItem("\nRunning Time : {} min".format(str(round(seconds/60, 1))) + "\n")
|
|
59 | 61 |
|
60 | 62 |
''' |
61 | 63 |
@history 2018.05.25 Jeongwoo Add pyqtSignal(svgItemClicked, itemRemoved) |
... | ... | |
97 | 99 |
|
98 | 100 |
def recognizeButtonClicked(self, event): |
99 | 101 |
if self.ui.symbolTextCheckBox.isChecked() or self.ui.lineCheckBox.isChecked(): |
102 |
self.ui.progressBar.setValue(0) |
|
100 | 103 |
self.startThread() |
101 | 104 |
|
102 | 105 |
''' |
106 |
@brief update progressbar with given value |
|
107 |
@author humkyung |
|
108 |
@date 2018.06.08 |
|
109 |
''' |
|
110 |
def updateProgress(self, maxValue): |
|
111 |
self.ui.progressBar.setMaximum(maxValue) |
|
112 |
self.ui.progressBar.setValue(self.ui.progressBar.value() + 1) |
|
113 |
|
|
114 |
''' |
|
103 | 115 |
@brief start thread |
104 | 116 |
@author humkyung |
105 | 117 |
@date 2018.04.?? |
106 | 118 |
@history 2018.05.25 Jeongwoo Moved from MainWindow |
107 | 119 |
2018.05.28 Jeongwoo Add connects (self.loadRecognitionResult, recognizeLine) |
108 | 120 |
2018.05.30 Jeongwoo Change signal name (drawDetectedItems) |
121 |
humkyung 2018.06.08 connect signal to self.updateProgress |
|
109 | 122 |
''' |
110 | 123 |
def startThread(self): |
111 | 124 |
from DTI_PID import recognizeLine |
... | ... | |
131 | 144 |
self.obj.finished.connect(self.thread.quit) |
132 | 145 |
self.obj.drawDetectedItems.connect(self.drawDetectedItems) |
133 | 146 |
self.obj.recognizeLine.connect(recognizeLine) |
147 |
self.obj.updateProgress.connect(self.updateProgress) |
|
134 | 148 |
|
135 | 149 |
# 5 - Connect Thread started signal to Worker operational slot method |
136 | 150 |
self.thread.started.connect(self.obj.procCounter) |
DTI_PID/DTI_PID/Recognition_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file 'dlgRecognition.ui' |
|
3 |
# Form implementation generated from reading ui file '.\UI\dlgRecognition.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.6
|
|
5 |
# Created by: PyQt5 UI code generator 5.10.1
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
... | ... | |
12 | 12 |
def setupUi(self, Recognition): |
13 | 13 |
Recognition.setObjectName("Recognition") |
14 | 14 |
Recognition.setWindowModality(QtCore.Qt.WindowModal) |
15 |
Recognition.resize(845, 300)
|
|
15 |
Recognition.resize(845, 453)
|
|
16 | 16 |
font = QtGui.QFont() |
17 | 17 |
font.setFamily("맑은 고딕") |
18 | 18 |
Recognition.setFont(font) |
19 | 19 |
self.gridLayout = QtWidgets.QGridLayout(Recognition) |
20 | 20 |
self.gridLayout.setObjectName("gridLayout") |
21 |
self.buttonBox = QtWidgets.QDialogButtonBox(Recognition) |
|
22 |
self.buttonBox.setEnabled(False) |
|
23 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
24 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close) |
|
25 |
self.buttonBox.setObjectName("buttonBox") |
|
26 |
self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1) |
|
27 | 21 |
self.listWidget = QtWidgets.QListWidget(Recognition) |
28 | 22 |
self.listWidget.setObjectName("listWidget") |
29 | 23 |
self.gridLayout.addWidget(self.listWidget, 1, 0, 1, 1) |
... | ... | |
31 | 25 |
self.gridLayout_2.setObjectName("gridLayout_2") |
32 | 26 |
self.recognizeButton = QtWidgets.QPushButton(Recognition) |
33 | 27 |
self.recognizeButton.setObjectName("recognizeButton") |
34 |
self.gridLayout_2.addWidget(self.recognizeButton, 0, 2, 1, 1, QtCore.Qt.AlignLeft)
|
|
28 |
self.gridLayout_2.addWidget(self.recognizeButton, 0, 2, 1, 1, QtCore.Qt.AlignRight)
|
|
35 | 29 |
self.symbolTextCheckBox = QtWidgets.QCheckBox(Recognition) |
36 | 30 |
self.symbolTextCheckBox.setMaximumSize(QtCore.QSize(103, 16777215)) |
37 | 31 |
self.symbolTextCheckBox.setChecked(True) |
... | ... | |
43 | 37 |
self.lineCheckBox.setObjectName("lineCheckBox") |
44 | 38 |
self.gridLayout_2.addWidget(self.lineCheckBox, 0, 1, 1, 1) |
45 | 39 |
self.gridLayout.addLayout(self.gridLayout_2, 0, 0, 1, 1) |
40 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
41 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
42 |
self.progressBar = QtWidgets.QProgressBar(Recognition) |
|
43 |
self.progressBar.setProperty("value", 0) |
|
44 |
self.progressBar.setObjectName("progressBar") |
|
45 |
self.horizontalLayout.addWidget(self.progressBar) |
|
46 |
self.buttonBox = QtWidgets.QDialogButtonBox(Recognition) |
|
47 |
self.buttonBox.setEnabled(False) |
|
48 |
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) |
|
49 |
sizePolicy.setHorizontalStretch(0) |
|
50 |
sizePolicy.setVerticalStretch(0) |
|
51 |
sizePolicy.setHeightForWidth(self.buttonBox.sizePolicy().hasHeightForWidth()) |
|
52 |
self.buttonBox.setSizePolicy(sizePolicy) |
|
53 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
54 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close) |
|
55 |
self.buttonBox.setObjectName("buttonBox") |
|
56 |
self.horizontalLayout.addWidget(self.buttonBox, 0, QtCore.Qt.AlignRight) |
|
57 |
self.gridLayout.addLayout(self.horizontalLayout, 4, 0, 1, 1) |
|
46 | 58 |
|
47 | 59 |
self.retranslateUi(Recognition) |
48 | 60 |
self.buttonBox.clicked['QAbstractButton*'].connect(Recognition.accept) |
DTI_PID/DTI_PID/UI/dlgRecognition.ui | ||
---|---|---|
10 | 10 |
<x>0</x> |
11 | 11 |
<y>0</y> |
12 | 12 |
<width>845</width> |
13 |
<height>300</height>
|
|
13 |
<height>453</height>
|
|
14 | 14 |
</rect> |
15 | 15 |
</property> |
16 | 16 |
<property name="font"> |
... | ... | |
22 | 22 |
<string>설계정보 인식</string> |
23 | 23 |
</property> |
24 | 24 |
<layout class="QGridLayout" name="gridLayout"> |
25 |
<item row="2" column="0"> |
|
26 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
27 |
<property name="enabled"> |
|
28 |
<bool>false</bool> |
|
29 |
</property> |
|
30 |
<property name="orientation"> |
|
31 |
<enum>Qt::Horizontal</enum> |
|
32 |
</property> |
|
33 |
<property name="standardButtons"> |
|
34 |
<set>QDialogButtonBox::Close</set> |
|
35 |
</property> |
|
36 |
</widget> |
|
37 |
</item> |
|
38 | 25 |
<item row="1" column="0"> |
39 | 26 |
<widget class="QListWidget" name="listWidget"/> |
40 | 27 |
</item> |
41 | 28 |
<item row="0" column="0"> |
42 | 29 |
<layout class="QGridLayout" name="gridLayout_2"> |
43 |
<item row="0" column="2" alignment="Qt::AlignLeft">
|
|
30 |
<item row="0" column="2" alignment="Qt::AlignRight">
|
|
44 | 31 |
<widget class="QPushButton" name="recognizeButton"> |
45 | 32 |
<property name="text"> |
46 | 33 |
<string>정보 인식</string> |
... | ... | |
81 | 68 |
</item> |
82 | 69 |
</layout> |
83 | 70 |
</item> |
71 |
<item row="4" column="0"> |
|
72 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
73 |
<item> |
|
74 |
<widget class="QProgressBar" name="progressBar"> |
|
75 |
<property name="value"> |
|
76 |
<number>0</number> |
|
77 |
</property> |
|
78 |
</widget> |
|
79 |
</item> |
|
80 |
<item alignment="Qt::AlignRight"> |
|
81 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
82 |
<property name="enabled"> |
|
83 |
<bool>false</bool> |
|
84 |
</property> |
|
85 |
<property name="sizePolicy"> |
|
86 |
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
|
87 |
<horstretch>0</horstretch> |
|
88 |
<verstretch>0</verstretch> |
|
89 |
</sizepolicy> |
|
90 |
</property> |
|
91 |
<property name="orientation"> |
|
92 |
<enum>Qt::Horizontal</enum> |
|
93 |
</property> |
|
94 |
<property name="standardButtons"> |
|
95 |
<set>QDialogButtonBox::Close</set> |
|
96 |
</property> |
|
97 |
</widget> |
|
98 |
</item> |
|
99 |
</layout> |
|
100 |
</item> |
|
84 | 101 |
</layout> |
85 | 102 |
</widget> |
86 | 103 |
<resources/> |
내보내기 Unified diff