프로젝트

일반

사용자정보

개정판 5c89a091

ID5c89a091a79c2b0802104bd33ecb278b26ba7fc4
상위 5f0266c3
하위 1d7af5dc

함의성이(가) 약 6년 전에 추가함

issue #000: fix recognition dialog checkbox state and recognition test and line save fix

Change-Id: Ie048f0ee26cd273c5aafe9c40bd2d556927b4fd9

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
228 228
        configs = docData.getAppConfigs('app', 'mode')
229 229
        if configs and 1 == len(configs) and 'advanced' == configs[0].value:
230 230
            self.actionOCR_Training.triggered.connect(self.oCRTrainingClicked)
231
            self.pushButtonBatchRecognition
231 232
        else:
232 233
            self.actionOCR_Training.setVisible(False)
234
            self.pushButtonBatchRecognition.setVisible(False)
233 235

  
234 236
        # removedItems
235 237
        self.removedItems = {}
......
1845 1847
                    item.angle = angle
1846 1848
                    item.setPen(QPen(Qt.red, 5, Qt.SolidLine))
1847 1849
                    #self.graphicsView.scene.addItem(item)
1848
                    appDocData.symbols.append(item)
1850
                    #appDocData.symbols.append(item)
1849 1851
                    appDocData.allItems.append(item)
1850 1852
            # up to here
1851 1853
        except Exception as ex:
DTI_PID/DTI_PID/RecognitionDialog.py
17 17
from SymbolSvgItem import SymbolSvgItem
18 18
from EngineeringTextItem import QEngineeringTextItem
19 19
from EngineeringUnknownItem import QEngineeringUnknownItem
20
from EngineeringErrorItem import QEngineeringErrorItem
21
from EngineeringEndBreakItem import QEngineeringEndBreakItem
22
from symbol import Symbol
20 23

  
21 24
from MainWindow import MainWindow
22 25

  
......
211 214
    
212 215
            #remove already existing symbol and text
213 216
            if not batch:
214
                items = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem) or \
215
                    issubclass(type(item), QEngineeringTextItem) or \
216
                    type(item) is QEngineeringUnknownItem]
217
                items = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringUnknownItem or type(item) is QEngineeringEndBreakItem or type(item) is QEngineeringErrorItem]
218
                if worker.isSymbolChecked:
219
                    items.extend([item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)])
220
                if worker.isTextChecked:
221
                    items.extend([item for item in worker.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)])
217 222
                for item in items:
218 223
                    worker.graphicsView.scene.removeItem(item)
219

  
220 224
            #up to here
221 225

  
222 226
            srcList = path
......
310 314
                    for sym in searchedSymbolList:
311 315
                        pool.submit(Worker.removeDetectedSymbol, sym, appDocData.imgSrc)
312 316
                    pool.shutdown(wait = True)
317
                    print(searchedSymbolList[0].getOcrOption())
318
                else:
319
                    # if symbol is excluded from recognition, keep it
320
                    import math
321

  
322
                    symbolItems = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)]
323
                    
324
                    for symbolItem in symbolItems:
325
                        symbolName = symbolItem.name
326
                        symbolType = symbolItem.type
327
                        searchedItemSp = [int(symbolItem.loc[0]), int(symbolItem.loc[1])]
328
                        sw = symbolItem.size[0] # check later
329
                        sh = symbolItem.size[1] # check later
330

  
331
                        symbolThreshold = 50 # not necessary
332
                        symbolMinMatchCount = 0 # not necessary
333
                        hitRate = 80 # not necessary
334
                        
335
                        allowed_error = 0.0001
336
                        #degree 0
337
                        if abs(symbolItem.angle - 0) <= allowed_error:
338
                            symbolRotatedAngle = 0
339
                        #degree 90
340
                        elif abs(symbolItem.angle - 1.57) <= allowed_error:
341
                            symbolRotatedAngle = 90
342
                        #degree 180
343
                        elif abs(symbolItem.angle - 3.14) <= allowed_error:
344
                            symbolRotatedAngle = 180
345
                        #degree 270
346
                        elif abs(symbolItem.angle - 4.71) <= allowed_error:
347
                            symbolRotatedAngle = 270
348
                        else:
349
                            symbolRotatedAngle = math.pi / 180 * symbolItem.angle
350

  
351
                        isDetectOnOrigin = 80 # not necessary
352
                        symbolRotateCount = 0 # not necessary
353
                        symbolOcrOption = 0 # not necessary
354
                        isContainChild = 0 # not necessary
355
                        originalPoint = [symbolItem.origin[0] - symbolItem.loc[0], symbolItem.origin[1] - symbolItem.loc[1]]
356
                        symbolConnectionPoint = []
357
                        baseSymbol = str(symbolItem.parentSymbol)
358
                        additionalSymbol = str(symbolItem.childSymbol)
359
                        isExceptDetect = 0 # not necessary
360
                        detectFlip = symbolItem.flip
361

  
362
                        searchedSymbolList.append(Symbol(symbolName, symbolType , 
363
                            searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, hitRate, symbolRotatedAngle , 
364
                            isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild , 
365
                            ','.join(str(x) for x in originalPoint), 
366
                            [], 
367
                            baseSymbol, additionalSymbol, isExceptDetect, detectFlip))
368
                        
369
                        worker.graphicsView.scene.removeItem(symbolItem)
370
                    
371
                    pool = futures.ThreadPoolExecutor(max_workers = THREAD_MAX_WORKER)
372

  
373
                    for sym in searchedSymbolList:
374
                        pool.submit(Worker.removeDetectedSymbol, sym, appDocData.imgSrc)
375
                    pool.shutdown(wait = True)
313 376

  
314 377
                worker.updateBatchProgress.emit(len(srcList), 1)
315 378

  
......
368 431

  
369 432
                if isLineChecked:
370 433
                    Worker.recognizeLine(mainRes, listWidget, worker.graphicsView, worker, batch)
434
                else:
435
                    pass
371 436

  
372 437
                createUnknownItems(mainRes)
373 438

  
......
741 806
                            Worker.addSearchedSymbol(symbolName, symbolType , 
742 807
                                searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, hitRate, symbolRotatedAngle , 
743 808
                                isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild , 
744
                                originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect, detectFlip=1 if index is 1 else 0)
809
                                originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect, detectFlip=1 if index is 1 else 0)
745 810
                            threadLock.release()
746 811
                        else: ## 겹치는 영역이 기준값보다 클 경우
747 812
                            if symbolIndex != -1 and symbolIndex < len(searchedSymbolList):
......
757 822
                                                                            isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild , 
758 823
                                                                            ','.join(str(x) for x in originalPoint), 
759 824
                                                                            '/'.join('{},{},{},{}'.format(param[0], param[1], param[2], param[3]) for param in connectionPoint), 
760
                                                                            baseSymbol, additionalSymbol,isExceptDetect, detectFlip=1 if index is 1 else 0)
825
                                                                            baseSymbol, additionalSymbol, isExceptDetect, detectFlip=1 if index is 1 else 0)
761 826
                                        threadLock.release()
762 827
                                ## 현재 심볼과 검출된 심볼이 같지 않을 경우 (포함)
763 828
                                elif appDocData.isEquipmentType(searchedSymbol.getType()):
......
1416 1481
        self.ui = Recognition_UI.Ui_Recognition()
1417 1482
        self.ui.setupUi(self)
1418 1483

  
1484
        self.ui.buttonBox.setEnabled(True)
1485
        self.ui.listWidget.model().rowsInserted.connect(self.rowInserted)
1486
        self.ui.recognizeButton.clicked.connect(self.recognizeButtonClicked)
1487
        self.ui.lineCheckBox.stateChanged.connect(self.checkBoxChanged)
1488
        self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxChanged)
1489
        self.isAccepted = False
1490
        self.batch = batch
1491

  
1419 1492
        appDocData = AppDocData.instance()
1420 1493
        configs = appDocData.getAppConfigs('app', 'mode')
1421 1494
        if configs and 1 == len(configs) and 'advanced' == configs[0].value:
......
1423 1496
        else:
1424 1497
            self.ui.lineCheckBox.setVisible(False)
1425 1498

  
1426
        self.ui.buttonBox.setEnabled(True)
1427
        self.ui.listWidget.model().rowsInserted.connect(self.rowInserted)
1428
        self.ui.recognizeButton.clicked.connect(self.recognizeButtonClicked)
1429
        self.isAccepted = False
1430
        self.batch = batch
1499
        if self.batch:
1500
            self.ui.lineCheckBox.setCheckState(Qt.Checked)
1501
            self.ui.lineCheckBox.setEnabled(False)
1502
            self.ui.checkBoxSymbol.setEnabled(False)
1503
            self.ui.checkBoxText.setEnabled(False)
1504

  
1505
    def checkBoxChanged(self, checkState):
1506
        '''
1507
        @brief      line cannot be eocognized alone
1508
        @author     euisung
1509
        @date       2019.05.14
1510
        '''
1511
        if checkState is int(Qt.Checked):
1512
            if self.ui.lineCheckBox.isChecked() and not self.ui.checkBoxSymbol.isChecked():
1513
                self.ui.checkBoxSymbol.setCheckState(Qt.Checked)
1514
        elif checkState is int(Qt.Unchecked):
1515
            if self.ui.lineCheckBox.isChecked() and not self.ui.checkBoxSymbol.isChecked():
1516
                self.ui.lineCheckBox.setCheckState(Qt.Unchecked)
1517

  
1431 1518

  
1432 1519
    '''
1433 1520
        @brief      QListWidget Row Inserted Listener
......
1448 1535
        @author     humkyung
1449 1536
        @history    humkyung 2018.10.05 clear imgSrc before recognizing
1450 1537
        """ 
1451
        if self.ui.checkBoxSymbol.isChecked() or self.ui.checkBoxText.isChecked() or self.ui.lineCheckBox.isChecked():
1538
        if self.ui.checkBoxSymbol.isChecked() or self.ui.checkBoxText.isChecked():# or self.ui.lineCheckBox.isChecked():
1452 1539
            appDocData = AppDocData.instance()
1453 1540
            appDocData.imgSrc = None
1454 1541
            area = appDocData.getArea('Drawing')
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
1088 1088
                item.area = node.find('AREA').text
1089 1089
            ## up to here
1090 1090

  
1091
            thicknessNode = node.find('THICKNESS')
1092
            item.thickness = int(thicknessNode.text) if thicknessNode is not None and thicknessNode.text != 'None' else None
1093

  
1091 1094
            connectors = node.find('CONNECTORS')
1092 1095
            if connectors is not None:
1093 1096
                iterIndex = 0
......
1138 1141
            areaNode.text = self.area
1139 1142
            node.append(areaNode)
1140 1143

  
1144
            thicknessNode = Element('THICKNESS')
1145
            thicknessNode.text = str(self.thickness)
1146
            node.append(thicknessNode)
1147

  
1141 1148
            connectorsNode = Element('CONNECTORS')
1142 1149
            for connector in self.connectors:
1143 1150
                connectorsNode.append(connector.toXml())
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
216 216
        allowed_error = 0.1
217 217

  
218 218
        if abs(rect.x() - 0) <= allowed_error and abs(rect.y() - 0) <= allowed_error:
219
            # when first recognition step, symbols are not in scene(not yet added) therefore cannot use scenebounding rect
219 220
            minX = self.loc[0] - margin
220 221
            minY = self.loc[1] - margin
221 222
            maxX = minX + self.size[0] + margin
......
1305 1306
                self.angle = 0
1306 1307
            else:
1307 1308
                self.angle = 0
1309
                
1310
            self.size[0], self.size[1] = self.size[1], self.size[0]
1308 1311
        else:
1309 1312
            self.angle = angle
1310

  
1311
        self.size[0], self.size[1] = self.size[1], self.size[0]
1312 1313
        
1313
        scene = self.scene()
1314
        #scene = self.scene()
1314 1315
        #self.scene().removeItem(self)
1315 1316
        #self.addSvgItemToScene(scene)
1316 1317
        currentPoint = self.getCurrentPoint()

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)