프로젝트

일반

사용자정보

개정판 8d35dc6e

ID8d35dc6ef4692b4f658be4346f39ec618d52c600
상위 0756a00c
하위 389292a7

김정우 이(가) 약 7년 전에 추가함

심볼 생성,수정 시 미검출 심볼 옵션 선택 가능/미검출 심볼일 경우 검출 과정에서 제외/검출을 위한 타겟심볼 생성 부분 수정/isExceptDetect 필드 추가에 따른 관련 부분 수정

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
87 87
        return self.currentPidSource
88 88

  
89 89
    '''
90
        @brief      Get Detecting Target Symbol List (Field 'isExceptDetect' == False(0))
91
        @author     Jeongwoo
92
        @date       18.04.24
93
    '''
94
    def getTargetSymbolList(self):
95
        targetSymbolList = []
96

  
97
        try:
98
            dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
99

  
100
            conn = sqlite3.connect(dbPath)
101
            cursor = conn.cursor()
102
            sql = 'SELECT * FROM Symbol WHERE isExceptDetect = 0'
103
            try:
104
                cursor.execute(sql)
105
                rows = cursor.fetchall()
106
                for row in rows:
107
                    sym = symbol.SymbolBase(row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[0]) ## uid is last item
108
                    targetSymbolList.append(sym)
109
            except Exception as ex:
110
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
111
        finally:
112
            conn.close()
113

  
114
        return targetSymbolList
115

  
116
    '''
90 117
        @brief  build application database
91 118
        @author humkyung
92 119
        @date   2018.04.20
......
652 679
        
653 680
    '''
654 681
        @brief  get symbol name
682
        @history    18.04.24    Jeongwoo    Add isExceptDetect Field
655 683
    '''
656 684
    def getSymbolByQuery(self, fieldName, param):
657 685
        ret = None
658 686

  
659 687
        try:
660
            dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db"
688
            dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
661 689
            conn = sqlite3.connect(dbPath)
662 690
            cursor = conn.cursor()
663 691
            sql = 'SELECT * FROM Symbol WHERE ' + fieldName + ' = "' + param + '"'
......
668 696
                    symbolTuple = rows[0]
669 697
                    ret = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4]
670 698
                                            , symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9]
671
                                            , symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[0]) ## uid is last item
699
                                            , symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0]) ## uid is last item
672 700
                    #ret = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4]
673 701
                    #                        , symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9]
674 702
                    #                        , symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0]) ## uid is last item
......
681 709

  
682 710
    '''
683 711
        @brief  get symbol name list
712
        @history    18.04.24    Jeongwoo    Add isExceptDetect Field
684 713
    '''
685 714
    def getSymbolListByQuery(self, fieldName=None, param=None):
686 715
        ret = []
687 716

  
688 717
        try:
689
            dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db"
718
            dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
690 719
            conn = sqlite3.connect(dbPath)
691 720
            cursor = conn.cursor()
692 721
            if fieldName is not None and param is not None:
......
700 729
                    for symbolTuple in rows:
701 730
                        sym = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4]
702 731
                                                , symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9]
703
                                                , symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[0]) ## uid is last item
732
                                                , symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0]) ## uid is last item
704 733
                        ret.append(sym)
705 734
            except Exception as ex:
706 735
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
DTI_PID/DTI_PID/DTI_PID.py
245 245
def addSearchedSymbol(id, sName, sType
246 246
                      , sp, w, h, threshold, minMatchCount, mpCount, rotatedAngle
247 247
                      , isDetectOnOrigin, rotateCount, ocrOption, isContainChild
248
                      , originalPoint, connectionPoint, baseSymbol, additionalSymbol):
248
                      , originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect):
249 249
    global searchedSymbolList
250 250
    newSym = symbol.Symbol(id, sName, sType
251 251
                           , sp, w, h, threshold, minMatchCount, mpCount, rotatedAngle
252 252
                           , isDetectOnOrigin, rotateCount, ocrOption, isContainChild
253
                           , originalPoint, connectionPoint, baseSymbol, additionalSymbol)
253
                           , originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect)
254 254
##Add symbols
255 255
#def addSearchedSymbol(id, sName, sType, symbolPath
256 256
#                      , sp, w, h, threshold, minMatchCount, mpCount, rotatedAngle
......
336 336
    symbolConnectionPoint = targetSymbol.getConnectionPoint()
337 337
    baseSymbol = targetSymbol.getBaseSymbol()
338 338
    additionalSymbol = targetSymbol.getAdditionalSymbol()
339
    isExceptDetect = targetSymbol.getIsExceptDetect()
340

  
341
    if isExceptDetect == 1:
342
        item = QListWidgetItem('{} file is not target'.format(os.path.basename(symbolPath.replace('.png', ''))))
343
        item.setBackground(QColor('green'))
344
        listWidget.addItem(item)
345
        return
339 346

  
340 347
    foundSymbolCount = 0
341 348

  
342 349
    # check if symbol file exists
343 350
    if not os.path.isfile(symbolPath):
344
        item = QListWidgetItem('{} file not found'.format(symbolPath))
351
        item = QListWidgetItem('{} file not found'.format(os.path.basename(symbolPath.replace('.png', ''))))
345 352
        item.setBackground(QColor('red'))
346 353
        listWidget.addItem(item)
347 354
        return
......
439 446
                            addSearchedSymbol(symId, symbolName, symbolType
440 447
                                              , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
441 448
                                              , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
442
                                              , originalPoint, connectionPoint, baseSymbol, additionalSymbol)
449
                                              , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
443 450
                            threadLock.release()
444 451
                    ## 겹치는 영역이 기준값보다 클 경우
445 452
                    else:
......
454 461
                                    searchedSymbolList[symbolIndex] = symbol.Symbol(symId, symbolName, symbolType
455 462
                                                                                    , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
456 463
                                                                                    , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
457
                                                                                    , originalPoint, connectionPoint, baseSymbol, additionalSymbol)
464
                                                                                    , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
458 465
                                    threadLock.release()
459 466
                            ## 현재 심볼과 검출된 심볼이 같지 않을 경우 (포함)
460 467
                            else:
......
471 478
                                            searchedSymbolList[searchedSymbolList.index(s)] = symbol.Symbol(symId, symbolName, symbolType
472 479
                                                                                            , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
473 480
                                                                                            , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
474
                                                                                            , originalPoint, connectionPoint, baseSymbol, additionalSymbol)
481
                                                                                            , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
475 482
                                            threadLock.release()
476 483
                                else:
477 484
                                    if mpCount >= symbolMinMatchCount:
......
486 493
                                                addSearchedSymbol(symId, symbolName, symbolType
487 494
                                                                  , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
488 495
                                                                  , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
489
                                                                  , originalPoint, connectionPoint, baseSymbol, additionalSymbol)
496
                                                                  , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
490 497
                                                threadLock.release()
491 498
                                
492 499
                ## Rotate Symbol
......
749 756

  
750 757

  
751 758
#Generate target symbol data list
759
'''
760
    @history    18.04.24    Jeongwoo    Add isExceptDetect Field
761
'''
752 762
def initTargetSymbolDataList():
753 763
    ############ region SQLite
754
    conn = sqlite3.connect(AppDocData.instance().getCurrentProject().getPath() + "/db/" + "ITI_PID.db")
755
    cursor = conn.cursor()
756
    sql = 'SELECT * FROM Symbol'
757
    cursor.execute(sql)
758
    rows = cursor.fetchall()
764
    global targetSymbolList
759 765
    dict = {}
766
    tempTargetList = AppDocData.instance().getTargetSymbolList()
760 767

  
761 768
    ## Init Symbol Data from SQLite
762
    for row in rows:
763
        symId = row[1] // 100 # symId
764
        sym = symbol.SymbolBase(row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[0]) ## uid is last item
765
        #sym = symbol.SymbolBase(row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[0]) ## uid is last item
769
    for target in tempTargetList:
770
        symId = target.getId() // 100 # symId
766 771
        if symId in dict:
767
            dict[symId].append(sym)
772
            dict[symId].append(target)
768 773
        else:
769 774
            symGroup = []
770
            symGroup.append(sym)
775
            symGroup.append(target)
771 776
            dict[symId] = symGroup
772
    conn.close()
773 777

  
774 778
    ## Sort each symbol list by symbol id
775 779
    for k, v in dict.items():
DTI_PID/DTI_PID/QSymbolEditorDialog.py
122 122
            self.ui.isContainChildCheckBox.setChecked(True if self.selectedSymbol.getIsContainChild() else False)
123 123
            self.ui.typeComboBox.setCurrentIndex(self.ui.typeComboBox.findText(self.selectedSymbol.getType()))
124 124
            self.ui.baseSymbolComboBox.setCurrentIndex(self.ui.baseSymbolComboBox.findText(self.selectedSymbol.getBaseSymbol()))
125
            self.ui.isExceptDetectCheckBox.setChecked(True if self.selectedSymbol.getIsExceptDetect() else False)
125 126

  
126 127
            additionalSymbol = self.selectedSymbol.getAdditionalSymbol()
127 128
            if additionalSymbol is not None and len(additionalSymbol) > 0:
......
247 248
        connectionPoint = self.makeConnectionPointListString()
248 249
        baseSymbol = self.ui.baseSymbolComboBox.currentText()
249 250
        additionalSymbol = self.makeAdditionalSymbolListString()
251
        isExceptDetect = 1 if self.ui.isExceptDetectCheckBox.isChecked() else 0
250 252

  
251 253
        convertedThreshold = int(threshold) / 100.0
252 254

  
253 255
        newSym = symbol.SymbolBase(int(symId), fileName, type, convertedThreshold, int(minMatchPoint), isDetectOnOrigin
254
                                   , rotationCount, ocrOption, isContainChild, originalPoint, connectionPoint, baseSymbol, additionalSymbol, uid)
256
                                   , rotationCount, ocrOption, isContainChild, originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect, uid)
255 257

  
256 258
        return newSym
257 259
    
DTI_PID/DTI_PID/SG_DbHelper.py
26 26
	        'originalPoint'	TEXT,
27 27
	        'connectionPoint'	TEXT,
28 28
	        'baseSymbol'	TEXT,
29
	        'additionalSymbol'	TEXT
29
	        'additionalSymbol'	TEXT,
30
            'isExceptDetect'    INTEGER DEFAULT 0
30 31
        );
31 32
    '''
32 33

  
......
59 60
    #'''
60 61
    
61 62
    INSERT_SYMBOL_SQL = '''
62
        INSERT INTO Symbol(symId, name, type, threshold, minMatchPoint, isDetectOrigin, rotationCount, ocrOption, isContainChild, originalPoint, connectionPoint, baseSymbol, additionalSymbol) 
63
        VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
63
        INSERT INTO Symbol(symId, name, type, threshold, minMatchPoint, isDetectOrigin, rotationCount, ocrOption, isContainChild, originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect) 
64
        VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
64 65
    '''
65 66
    #INSERT_SYMBOL_SQL = '''
66 67
    #    INSERT INTO Symbol(symId, name, type, path, threshold, minMatchPoint, isDetectOrigin, rotationCount, ocrOption, isContainChild, originalPoint, connectionPoint, baseSymbol, additionalSymbol) 
......
72 73
        SET
73 74
            symId = ?, name = ?, type = ?, threshold = ?, minMatchPoint = ?, isDetectOrigin = ?,
74 75
            rotationCount = ?, ocrOption = ?, isContainChild = ?, originalPoint = ?, connectionPoint = ?,
75
            baseSymbol = ?, additionalSymbol = ?
76
            baseSymbol = ?, additionalSymbol = ?, isExceptDetect = ?
76 77
        WHERE uid = ?
77 78
    '''
78 79
    #UPDATE_SYMBOL_SQL = '''
......
155 156
                           , symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount()
156 157
                           , symbol.getOcrOption(), symbol.getIsContainChild()
157 158
                           , symbol.getOriginalPoint(), symbol.getConnectionPoint()
158
                           , symbol.getBaseSymbol(), symbol.getAdditionalSymbol())
159
                           , symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect)
159 160
            cursor.execute(self.INSERT_SYMBOL_SQL, query)
160 161
            conn.commit()
161 162
            isAdded = True
......
175 176
                           , symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount()
176 177
                           , symbol.getOcrOption(), symbol.getIsContainChild()
177 178
                           , symbol.getOriginalPoint(), symbol.getConnectionPoint()
178
                           , symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getUid())
179
                           , symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), symbol.getUid())
179 180
            cursor.execute(self.UPDATE_SYMBOL_SQL, query)
180 181
            conn.commit()
181 182
            isUpdated = True
DTI_PID/DTI_PID/SymbolBase.py
5 5
    def __init__(self, id, sName, sType, threshold = None, minMatchCount = 0
6 6
                 , isDetectOnOrigin = False, rotationCount = 4, ocrOption = OCR_OPTION_NOT_EXEC, isContainChild = 0
7 7
                 , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None
8
                 , uid = None):
8
                 , isExceptDetect = 0, uid = None):
9 9
    #def __init__(self, id, sName, sType, path = None, threshold = None, minMatchCount = 0
10 10
    #             , isDetectOnOrigin = False, rotationCount = 4, ocrOption = OCR_OPTION_NOT_EXEC, isContainChild = 0
11 11
    #             , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None
......
25 25
        self.connectionPoint = connectionPoint
26 26
        self.baseSymbol = baseSymbol
27 27
        self.additionalSymbol = additionalSymbol
28
        self.isExceptDetect = isExceptDetect
28 29

  
29 30
    def setUid(self, uid):
30 31
        self.uid = uid
......
118 119
    def getAdditionalSymbol(self):
119 120
        return self.additionalSymbol
120 121

  
122
    def setIsExceptDetect(self, isExceptDetect):
123
        self.isExceptDetect = isExceptDetect
124

  
125
    def getIsExceptDetect(self):
126
        return self.isExceptDetect
127

  
121 128
class imgLine():
122 129
    def __init__(self, start, end):
123 130
        self.start = start
DTI_PID/DTI_PID/UI/SymbolEditor.ui
579 579
               <item row="9" column="1">
580 580
                <widget class="QComboBox" name="typeComboBox"/>
581 581
               </item>
582
               <item row="18" column="0">
583
                <widget class="QLabel" name="isExceptDetectLabel">
584
                 <property name="font">
585
                  <font>
586
                   <weight>75</weight>
587
                   <bold>true</bold>
588
                  </font>
589
                 </property>
590
                 <property name="text">
591
                  <string>검출 미포함 여부</string>
592
                 </property>
593
                </widget>
594
               </item>
595
               <item row="18" column="1">
596
                <widget class="QCheckBox" name="isExceptDetectCheckBox">
597
                 <property name="text">
598
                  <string/>
599
                 </property>
600
                </widget>
601
               </item>
582 602
              </layout>
583 603
             </item>
584 604
            </layout>
585
            <zorder>formLayoutWidget</zorder>
586
            <zorder>formLayoutWidget</zorder>
587 605
           </widget>
588 606
          </widget>
589 607
         </item>
......
601 619
    </widget>
602 620
   </item>
603 621
  </layout>
604
  <zorder>widget_2</zorder>
605
  <zorder>widget</zorder>
606
  <zorder>widget_3</zorder>
607 622
 </widget>
608 623
 <resources/>
609 624
 <connections>
DTI_PID/DTI_PID/UI_SymbolEditor.py
304 304
        self.typeComboBox = QtWidgets.QComboBox(self.scrollAreaWidgetContents)
305 305
        self.typeComboBox.setObjectName("typeComboBox")
306 306
        self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.typeComboBox)
307
        self.isExceptDetectLabel = QtWidgets.QLabel(self.scrollAreaWidgetContents)
308
        font = QtGui.QFont()
309
        font.setBold(True)
310
        font.setWeight(75)
311
        self.isExceptDetectLabel.setFont(font)
312
        self.isExceptDetectLabel.setObjectName("isExceptDetectLabel")
313
        self.formLayout.setWidget(18, QtWidgets.QFormLayout.LabelRole, self.isExceptDetectLabel)
314
        self.isExceptDetectCheckBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
315
        self.isExceptDetectCheckBox.setText("")
316
        self.isExceptDetectCheckBox.setObjectName("isExceptDetectCheckBox")
317
        self.formLayout.setWidget(18, QtWidgets.QFormLayout.FieldRole, self.isExceptDetectCheckBox)
307 318
        self.gridLayout_4.addLayout(self.formLayout, 0, 0, 1, 1)
308 319
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
309 320
        self.verticalLayout.addWidget(self.scrollArea)
......
313 324
        self.verticalLayout.addWidget(self.buttonBox)
314 325
        self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
315 326
        self.gridLayout_3.addWidget(self.splitter, 0, 0, 1, 1)
316
        self.widget.raise_()
317
        self.widget_3.raise_()
318 327

  
319 328
        self.retranslateUi(Dialog)
320 329
        self.buttonBox.accepted.connect(Dialog.accept)
......
351 360
        self.connectionPointLabel.setText(_translate("Dialog", "Connection Point"))
352 361
        self.addConnectionPointButton.setText(_translate("Dialog", "추가"))
353 362
        self.typeLabel.setText(_translate("Dialog", "심볼 타입"))
363
        self.isExceptDetectLabel.setText(_translate("Dialog", "검출 미포함 여부"))
354 364

  
355 365

  
356 366
if __name__ == "__main__":
DTI_PID/DTI_PID/symbol.py
3 3
class Symbol(SymbolBase):
4 4
    def __init__(self, id, sName, sType, sp, width, height, threshold, minMatchCount, mpCount, rotatedAngle
5 5
                 , isDetectOnOrigin, rotationCount, ocrOption, isContainChild = 0
6
                 , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None, uid = None):
6
                 , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None, isExceptDetect = 0, uid = None):
7 7
        SymbolBase.__init__(self, id, sName, sType, threshold, minMatchCount
8 8
                            , isDetectOnOrigin, rotationCount, ocrOption, isContainChild
9
                            , originalPoint, connectionPoint, baseSymbol, additionalSymbol, uid)
9
                            , originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect, uid)
10 10
    #def __init__(self, id, sName, sType, path, sp, width, height, threshold, minMatchCount, mpCount, rotatedAngle
11 11
    #             , isDetectOnOrigin, rotationCount, ocrOption, isContainChild = 0
12 12
    #             , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None, uid = None):

내보내기 Unified diff

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