개정판 e72a2246
issue #663: 배친 인식 수정
Change-Id: Ib60d760d9a64473935f11c7eaa2de5b67073853d
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
80 | 80 |
displayLog = pyqtSignal(MessageType, str) |
81 | 81 |
add_detected_items_to_scene = pyqtSignal(QGraphicsScene) |
82 | 82 |
|
83 |
def __init__(self): |
|
83 |
def __init__(self, mutex, cond):
|
|
84 | 84 |
super(Worker, self).__init__() |
85 |
self.mutex = mutex |
|
86 |
self.cond = cond |
|
85 | 87 |
|
86 | 88 |
''' |
87 | 89 |
@history 2018.05.25 Jeongwoo Add if-statements by isSymbolTextChecked and isLineChecked variable |
... | ... | |
92 | 94 |
|
93 | 95 |
def procCounter(self): # A slot takes no params |
94 | 96 |
try: |
97 |
self.mutex.lock() |
|
95 | 98 |
if self.isSymbolChecked or self.isTrainingChecked: |
96 | 99 |
Worker.executeRecognition(self.path, self.listWidget, self.isLineChecked, self) |
97 | 100 |
except Exception as ex: |
... | ... | |
106 | 109 |
(_type, value, traceback) = sys.exc_info() |
107 | 110 |
sys.excepthook(_type, value, traceback) |
108 | 111 |
finally: |
112 |
self.mutex.unlock() |
|
109 | 113 |
self.finished.emit() |
110 | 114 |
|
111 | 115 |
''' |
... | ... | |
1166 | 1170 |
|
1167 | 1171 |
worker.create_unknown_items(mainRes) |
1168 | 1172 |
worker.add_detected_items_to_scene.emit(worker.scene) |
1173 |
worker.cond.wait(worker.mutex) |
|
1174 |
""" |
|
1169 | 1175 |
while not worker.scene._end: |
1170 | 1176 |
pass |
1177 |
""" |
|
1171 | 1178 |
|
1172 | 1179 |
worker.scene._end = False |
1173 | 1180 |
# clear drawing |
... | ... | |
2364 | 2371 |
|
2365 | 2372 |
self.ui.buttonBox.setDisabled(True) |
2366 | 2373 |
|
2374 |
self.mutex = QMutex() |
|
2375 |
self.cond = QWaitCondition() |
|
2376 |
|
|
2367 | 2377 |
# 1 - create Worker and Thread inside the Form |
2368 |
self.obj = Worker() # no parent! |
|
2378 |
self.obj = Worker(self.mutex, self.cond) # no parent!
|
|
2369 | 2379 |
self.obj.path = self.path |
2370 | 2380 |
self.obj.listWidget = self.ui.listWidget |
2371 | 2381 |
self.obj.scene = self._scene |
... | ... | |
2381 | 2391 |
|
2382 | 2392 |
# 3 - Connect Worker Signals to the Thread slots |
2383 | 2393 |
self.obj.finished.connect(self.thread.quit) |
2384 |
# self.obj.drawDetectedItems.connect(self.drawDetectedItems) |
|
2385 |
# self.obj.drawDetectedLines.connect(self.drawDetectedLines) |
|
2386 |
# self.obj.drawUnknownItems.connect(self.drawUnknownItems) |
|
2387 | 2394 |
self.obj.displayMessage.connect(self.addListItem) |
2388 | 2395 |
self.obj.updateProgress.connect(self.updateProgress) |
2389 | 2396 |
self.obj.updateBatchProgress.connect(self.updateBatchProgress) |
... | ... | |
2515 | 2522 |
sys.exc_info()[-1].tb_lineno) |
2516 | 2523 |
self.displayLog.emit(MessageType.Error, message) |
2517 | 2524 |
finally: |
2525 |
self.cond.wakeAll() |
|
2518 | 2526 |
scene._end = True |
내보내기 Unified diff