개정판 6850713e
issue #501: add progressbar
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
66 | 66 |
#drawUnknownItems = pyqtSignal(str, QObject) |
67 | 67 |
displayMessage = pyqtSignal(QListWidgetItem) |
68 | 68 |
updateProgress = pyqtSignal(int, str) |
69 |
updateBatchProgress = pyqtSignal(int, int) |
|
69 | 70 |
displayLog = pyqtSignal(MessageType, str) |
70 | 71 |
|
71 | 72 |
def __init__(self): |
... | ... | |
265 | 266 |
listWidget.addItem("Start recognition : " + mainRes) |
266 | 267 |
threadLock.acquire() |
267 | 268 |
|
269 |
worker.updateBatchProgress.emit(len(srcList), 1) |
|
270 |
|
|
268 | 271 |
if worker.isSymbolChecked: |
269 | 272 |
### calculate total count of symbol |
270 | 273 |
for targetItem in targetSymbolList: |
... | ... | |
274 | 277 |
maxProgressValue += 1 |
275 | 278 |
### up to here |
276 | 279 |
threadLock.release() |
277 |
|
|
280 |
|
|
278 | 281 |
if worker.isSymbolChecked: |
279 | 282 |
worker.displayTitle.emit('심볼 인식 중...') |
280 | 283 |
|
... | ... | |
304 | 307 |
pool.submit(Worker.removeDetectedSymbol, sym, appDocData.imgSrc) |
305 | 308 |
pool.shutdown(wait = True) |
306 | 309 |
|
310 |
worker.updateBatchProgress.emit(len(srcList), 1) |
|
311 |
|
|
307 | 312 |
## Remove Noise |
308 | 313 |
kernel1 = np.ones((2, 2), np.uint8) |
309 | 314 |
appDocData.imgSrc = cv2.dilate(appDocData.imgSrc, kernel1) |
... | ... | |
336 | 341 |
|
337 | 342 |
appDocData.imgName = os.path.splitext(os.path.basename(mainRes))[0] |
338 | 343 |
|
344 |
worker.updateBatchProgress.emit(len(srcList), 2) |
|
345 |
|
|
339 | 346 |
removedSymbolImgPath = os.path.join(project.getTempPath(), os.path.basename(mainRes)) |
340 | 347 |
cv2.imwrite(removedSymbolImgPath, appDocData.imgSrc) |
341 | 348 |
|
... | ... | |
363 | 370 |
Worker.recognizeLine(mainRes, listWidget, worker.graphicsView, worker, batch) |
364 | 371 |
|
365 | 372 |
drawUnknownItems(mainRes) |
366 |
|
|
373 |
|
|
374 |
worker.updateBatchProgress.emit(len(srcList), 1) |
|
367 | 375 |
except Exception as ex: |
368 | 376 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
369 | 377 |
worker.displayLog.emit(MessageType.Error, message) |
... | ... | |
1357 | 1365 |
elif image_path is not None: |
1358 | 1366 |
self.ui.labelImage.setText(image_path) |
1359 | 1367 |
|
1368 |
def updateBatchProgress(self, maxValue, weight): |
|
1369 |
''' |
|
1370 |
@brief update batch progressbar |
|
1371 |
@author euisung |
|
1372 |
@date 2018.11.28 |
|
1373 |
''' |
|
1374 |
self.ui.progressBarBatch.setMaximum(maxValue * 5) |
|
1375 |
self.ui.progressBarBatch.setValue(self.ui.progressBarBatch.value() + weight) |
|
1360 | 1376 |
''' |
1361 | 1377 |
@brief display title |
1362 | 1378 |
@author humkyung |
... | ... | |
1403 | 1419 |
#self.obj.drawUnknownItems.connect(self.drawUnknownItems) |
1404 | 1420 |
self.obj.displayMessage.connect(self.addListItem) |
1405 | 1421 |
self.obj.updateProgress.connect(self.updateProgress) |
1422 |
self.obj.updateBatchProgress.connect(self.updateBatchProgress) |
|
1406 | 1423 |
self.obj.displayLog.connect(App.mainWnd().addMessage) |
1407 | 1424 |
self.obj.displayTitle.connect(self.displayTitle) |
1408 | 1425 |
|
DTI_PID/DTI_PID/Recognition_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\ui\Recognition.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/Recognition_batch.ui'
|
|
4 | 4 |
# |
5 | 5 |
# Created by: PyQt5 UI code generator 5.11.3 |
6 | 6 |
# |
... | ... | |
20 | 20 |
self.gridLayout.setObjectName("gridLayout") |
21 | 21 |
self.gridLayout_2 = QtWidgets.QGridLayout() |
22 | 22 |
self.gridLayout_2.setObjectName("gridLayout_2") |
23 |
self.lineCheckBox = QtWidgets.QCheckBox(Recognition) |
|
24 |
self.lineCheckBox.setMaximumSize(QtCore.QSize(47, 16777215)) |
|
25 |
self.lineCheckBox.setChecked(False) |
|
26 |
self.lineCheckBox.setObjectName("lineCheckBox") |
|
27 |
self.gridLayout_2.addWidget(self.lineCheckBox, 0, 2, 1, 1) |
|
28 |
self.checkBoxSymbol = QtWidgets.QCheckBox(Recognition) |
|
29 |
self.checkBoxSymbol.setMaximumSize(QtCore.QSize(103, 16777215)) |
|
30 |
self.checkBoxSymbol.setChecked(True) |
|
31 |
self.checkBoxSymbol.setObjectName("checkBoxSymbol") |
|
32 |
self.gridLayout_2.addWidget(self.checkBoxSymbol, 0, 0, 1, 1) |
|
33 |
self.listWidget = QtWidgets.QListWidget(Recognition) |
|
34 |
self.listWidget.setObjectName("listWidget") |
|
35 |
self.gridLayout_2.addWidget(self.listWidget, 1, 0, 1, 5) |
|
36 |
self.progressBar = QtWidgets.QProgressBar(Recognition) |
|
37 |
self.progressBar.setProperty("value", 0) |
|
38 |
self.progressBar.setObjectName("progressBar") |
|
39 |
self.gridLayout_2.addWidget(self.progressBar, 2, 0, 1, 5) |
|
23 | 40 |
self.labelImage = QtWidgets.QLabel(Recognition) |
24 | 41 |
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) |
25 | 42 |
sizePolicy.setHorizontalStretch(0) |
... | ... | |
34 | 51 |
self.labelImage.setAlignment(QtCore.Qt.AlignCenter) |
35 | 52 |
self.labelImage.setObjectName("labelImage") |
36 | 53 |
self.gridLayout_2.addWidget(self.labelImage, 1, 5, 1, 1) |
37 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
38 |
self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1) |
|
39 | 54 |
self.recognizeButton = QtWidgets.QPushButton(Recognition) |
40 | 55 |
self.recognizeButton.setMinimumSize(QtCore.QSize(150, 0)) |
41 | 56 |
self.recognizeButton.setMaximumSize(QtCore.QSize(150, 16777215)) |
... | ... | |
66 | 81 |
self.labelTitle.setAlignment(QtCore.Qt.AlignCenter) |
67 | 82 |
self.labelTitle.setObjectName("labelTitle") |
68 | 83 |
self.gridLayout_2.addWidget(self.labelTitle, 0, 4, 1, 1) |
69 |
self.lineCheckBox = QtWidgets.QCheckBox(Recognition) |
|
70 |
self.lineCheckBox.setMaximumSize(QtCore.QSize(47, 16777215)) |
|
71 |
self.lineCheckBox.setChecked(False) |
|
72 |
self.lineCheckBox.setObjectName("lineCheckBox") |
|
73 |
self.gridLayout_2.addWidget(self.lineCheckBox, 0, 2, 1, 1) |
|
74 |
self.checkBoxSymbol = QtWidgets.QCheckBox(Recognition) |
|
75 |
self.checkBoxSymbol.setMaximumSize(QtCore.QSize(103, 16777215)) |
|
76 |
self.checkBoxSymbol.setChecked(True) |
|
77 |
self.checkBoxSymbol.setObjectName("checkBoxSymbol") |
|
78 |
self.gridLayout_2.addWidget(self.checkBoxSymbol, 0, 0, 1, 1) |
|
79 |
self.listWidget = QtWidgets.QListWidget(Recognition) |
|
80 |
self.listWidget.setObjectName("listWidget") |
|
81 |
self.gridLayout_2.addWidget(self.listWidget, 1, 0, 1, 5) |
|
84 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
85 |
self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1) |
|
86 |
self.progressBarBatch = QtWidgets.QProgressBar(Recognition) |
|
87 |
self.progressBarBatch.setProperty("value", 0) |
|
88 |
self.progressBarBatch.setObjectName("progressBarBatch") |
|
89 |
self.gridLayout_2.addWidget(self.progressBarBatch, 3, 0, 1, 5) |
|
82 | 90 |
self.buttonBox = QtWidgets.QDialogButtonBox(Recognition) |
83 | 91 |
self.buttonBox.setEnabled(False) |
84 | 92 |
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) |
... | ... | |
91 | 99 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
92 | 100 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close) |
93 | 101 |
self.buttonBox.setObjectName("buttonBox") |
94 |
self.gridLayout_2.addWidget(self.buttonBox, 2, 5, 1, 1) |
|
95 |
self.progressBar = QtWidgets.QProgressBar(Recognition) |
|
96 |
self.progressBar.setProperty("value", 0) |
|
97 |
self.progressBar.setObjectName("progressBar") |
|
98 |
self.gridLayout_2.addWidget(self.progressBar, 2, 0, 1, 5) |
|
102 |
self.gridLayout_2.addWidget(self.buttonBox, 3, 5, 1, 1) |
|
99 | 103 |
self.gridLayout.addLayout(self.gridLayout_2, 0, 1, 1, 1) |
100 | 104 |
|
101 | 105 |
self.retranslateUi(Recognition) |
... | ... | |
105 | 109 |
def retranslateUi(self, Recognition): |
106 | 110 |
_translate = QtCore.QCoreApplication.translate |
107 | 111 |
Recognition.setWindowTitle(_translate("Recognition", "설계정보 인식")) |
108 |
self.recognizeButton.setText(_translate("Recognition", "정보 인식")) |
|
109 |
self.checkBoxText.setText(_translate("Recognition", "텍스트")) |
|
110 | 112 |
self.lineCheckBox.setText(_translate("Recognition", "라인")) |
111 | 113 |
self.checkBoxSymbol.setText(_translate("Recognition", "심볼")) |
114 |
self.recognizeButton.setText(_translate("Recognition", "정보 인식")) |
|
115 |
self.checkBoxText.setText(_translate("Recognition", "텍스트")) |
|
116 |
|
|
117 |
|
|
118 |
if __name__ == "__main__": |
|
119 |
import sys |
|
120 |
app = QtWidgets.QApplication(sys.argv) |
|
121 |
Recognition = QtWidgets.QDialog() |
|
122 |
ui = Ui_Recognition() |
|
123 |
ui.setupUi(Recognition) |
|
124 |
Recognition.show() |
|
125 |
sys.exit(app.exec_()) |
|
112 | 126 |
|
DTI_PID/DTI_PID/UI/Recognition.ui | ||
---|---|---|
24 | 24 |
<layout class="QGridLayout" name="gridLayout"> |
25 | 25 |
<item row="0" column="1"> |
26 | 26 |
<layout class="QGridLayout" name="gridLayout_2"> |
27 |
<item row="0" column="2"> |
|
28 |
<widget class="QCheckBox" name="lineCheckBox"> |
|
29 |
<property name="maximumSize"> |
|
30 |
<size> |
|
31 |
<width>47</width> |
|
32 |
<height>16777215</height> |
|
33 |
</size> |
|
34 |
</property> |
|
35 |
<property name="text"> |
|
36 |
<string>라인</string> |
|
37 |
</property> |
|
38 |
<property name="checked"> |
|
39 |
<bool>false</bool> |
|
40 |
</property> |
|
41 |
</widget> |
|
42 |
</item> |
|
43 |
<item row="0" column="0"> |
|
44 |
<widget class="QCheckBox" name="checkBoxSymbol"> |
|
45 |
<property name="maximumSize"> |
|
46 |
<size> |
|
47 |
<width>103</width> |
|
48 |
<height>16777215</height> |
|
49 |
</size> |
|
50 |
</property> |
|
51 |
<property name="text"> |
|
52 |
<string>심볼</string> |
|
53 |
</property> |
|
54 |
<property name="checked"> |
|
55 |
<bool>true</bool> |
|
56 |
</property> |
|
57 |
</widget> |
|
58 |
</item> |
|
59 |
<item row="1" column="0" colspan="5"> |
|
60 |
<widget class="QListWidget" name="listWidget"/> |
|
61 |
</item> |
|
62 |
<item row="2" column="0" colspan="5"> |
|
63 |
<widget class="QProgressBar" name="progressBar"> |
|
64 |
<property name="value"> |
|
65 |
<number>0</number> |
|
66 |
</property> |
|
67 |
</widget> |
|
68 |
</item> |
|
27 | 69 |
<item row="1" column="5"> |
28 | 70 |
<widget class="QLabel" name="labelImage"> |
29 | 71 |
<property name="sizePolicy"> |
... | ... | |
58 | 100 |
</property> |
59 | 101 |
</widget> |
60 | 102 |
</item> |
61 |
<item row="0" column="3"> |
|
62 |
<spacer name="horizontalSpacer"> |
|
63 |
<property name="orientation"> |
|
64 |
<enum>Qt::Horizontal</enum> |
|
65 |
</property> |
|
66 |
<property name="sizeHint" stdset="0"> |
|
67 |
<size> |
|
68 |
<width>40</width> |
|
69 |
<height>20</height> |
|
70 |
</size> |
|
71 |
</property> |
|
72 |
</spacer> |
|
73 |
</item> |
|
74 | 103 |
<item row="0" column="5" alignment="Qt::AlignRight"> |
75 | 104 |
<widget class="QPushButton" name="recognizeButton"> |
76 | 105 |
<property name="minimumSize"> |
... | ... | |
159 | 188 |
</property> |
160 | 189 |
</widget> |
161 | 190 |
</item> |
162 |
<item row="0" column="2"> |
|
163 |
<widget class="QCheckBox" name="lineCheckBox"> |
|
164 |
<property name="maximumSize"> |
|
165 |
<size> |
|
166 |
<width>47</width> |
|
167 |
<height>16777215</height> |
|
168 |
</size> |
|
169 |
</property> |
|
170 |
<property name="text"> |
|
171 |
<string>라인</string> |
|
172 |
</property> |
|
173 |
<property name="checked"> |
|
174 |
<bool>false</bool> |
|
191 |
<item row="0" column="3"> |
|
192 |
<spacer name="horizontalSpacer"> |
|
193 |
<property name="orientation"> |
|
194 |
<enum>Qt::Horizontal</enum> |
|
175 | 195 |
</property> |
176 |
</widget> |
|
177 |
</item> |
|
178 |
<item row="0" column="0"> |
|
179 |
<widget class="QCheckBox" name="checkBoxSymbol"> |
|
180 |
<property name="maximumSize"> |
|
196 |
<property name="sizeHint" stdset="0"> |
|
181 | 197 |
<size> |
182 |
<width>103</width>
|
|
183 |
<height>16777215</height>
|
|
198 |
<width>40</width>
|
|
199 |
<height>20</height>
|
|
184 | 200 |
</size> |
185 | 201 |
</property> |
186 |
<property name="text"> |
|
187 |
<string>심볼</string> |
|
188 |
</property> |
|
189 |
<property name="checked"> |
|
190 |
<bool>true</bool> |
|
202 |
</spacer> |
|
203 |
</item> |
|
204 |
<item row="3" column="0" colspan="5"> |
|
205 |
<widget class="QProgressBar" name="progressBarBatch"> |
|
206 |
<property name="value"> |
|
207 |
<number>0</number> |
|
191 | 208 |
</property> |
192 | 209 |
</widget> |
193 | 210 |
</item> |
194 |
<item row="1" column="0" colspan="5"> |
|
195 |
<widget class="QListWidget" name="listWidget"/> |
|
196 |
</item> |
|
197 |
<item row="2" column="5"> |
|
211 |
<item row="3" column="5"> |
|
198 | 212 |
<widget class="QDialogButtonBox" name="buttonBox"> |
199 | 213 |
<property name="enabled"> |
200 | 214 |
<bool>false</bool> |
... | ... | |
225 | 239 |
</property> |
226 | 240 |
</widget> |
227 | 241 |
</item> |
228 |
<item row="2" column="0" colspan="5"> |
|
229 |
<widget class="QProgressBar" name="progressBar"> |
|
230 |
<property name="value"> |
|
231 |
<number>0</number> |
|
232 |
</property> |
|
233 |
</widget> |
|
234 |
</item> |
|
235 | 242 |
</layout> |
236 | 243 |
</item> |
237 | 244 |
</layout> |
내보내기 Unified diff