프로젝트

일반

사용자정보

개정판 32735cac

ID32735cac9fb0dc2e1b951bed482ca3c2853b1313
상위 7ac6b06b
하위 698ae50c, 34f2b549

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

심볼 검출 시 정확한 위치 조정할 때 사용하던 기준을 Feature Point Count(mpCount) 에서 Template Matching HitRate로 변경

차이점 보기:

DTI_PID/DTI_PID/DTI_PID.py
230 230
    @brief  Add symbols
231 231
    @author jwkim
232 232
    @date
233
    @history    Change parameter (mpCount → hitRate)
233 234
'''
234 235
def addSearchedSymbol(id, sName, sType
235
                      , sp, w, h, threshold, minMatchCount, mpCount, rotatedAngle
236
                      , sp, w, h, threshold, minMatchCount, hitRate, rotatedAngle
236 237
                      , isDetectOnOrigin, rotateCount, ocrOption, isContainChild
237 238
                      , originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect):
238 239
    global searchedSymbolList
239 240
    newSym = symbol.Symbol(id, sName, sType
240
                           , sp, w, h, threshold, minMatchCount, mpCount, rotatedAngle
241
                           , sp, w, h, threshold, minMatchCount, hitRate, rotatedAngle
241 242
                           , isDetectOnOrigin, rotateCount, ocrOption, isContainChild
242 243
                           , originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect)
243 244
##Add symbols
......
302 303
    @author     jwkim
303 304
    @date   
304 305
    @history    humkyung 2018.04.06 check if symbol file exists
306
                Jeongwoo 2018.05.29 Change method to adjust detail symbol location with hit-rate. Not feature point count
307
                                    Change parameter on add symbol part (mpCount → hitRate)
308
                                    Remove unusing calculation (avg)
305 309
'''
306 310
def detectSymbolOnPid(mainRes, targetSymbol, listWidget):
307 311
    global src
......
424 428
                    roi = roiItem[pt[1]:pt[1]+sh, pt[0]:pt[0]+sw]
425 429
                    mpCount = getMatchPointCount(roi, symGray)
426 430

  
431
                    if not (mpCount >= symbolMinMatchCount):
432
                        continue
427 433

  
434
                    currentHitRate = tmRes[pt[1], pt[0]]
428 435
                    ## 겹치는 영역이 기준값보다 작을 경우
429 436
                    if overlapArea <= ACCEPT_OVERLAY_AREA:
430
                        if mpCount >= symbolMinMatchCount:
431
                            threadLock.acquire()
432
                            foundSymbolCount = foundSymbolCount + 1
433
                            totalMpCount = totalMpCount + mpCount
434
                            addSearchedSymbol(symId, symbolName, symbolType
435
                                              , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
436
                                              , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
437
                                              , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
438
                            threadLock.release()
437
                        #if mpCount >= symbolMinMatchCount:
438
                        threadLock.acquire()
439
                        foundSymbolCount = foundSymbolCount + 1
440
                        addSearchedSymbol(symId, symbolName, symbolType
441
                                            , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, currentHitRate, symbolRotatedAngle
442
                                            , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
443
                                            , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
444
                        threadLock.release()
439 445
                    ## 겹치는 영역이 기준값보다 클 경우
440 446
                    else:
441 447
                        if symbolIndex != -1 and symbolIndex < len(searchedSymbolList):
442 448
                            searchedSymbol = searchedSymbolList[symbolIndex]
443 449
                            ## 현재 심볼과 검출된 심볼이 같을 경우 Match Point가 더 높은 정보로 교체
444 450
                            if symbolName == searchedSymbol.getName():
445
                                symbolMpCount = searchedSymbol.getMpCount()
446
                                if symbolMpCount < mpCount:
451
                                symbolHitRate = searchedSymbol.getHitRate()
452
                                if symbolHitRate < currentHitRate:
447 453
                                    threadLock.acquire()
448
                                    totalMpCount = totalMpCount - symbolMpCount + mpCount
449 454
                                    searchedSymbolList[symbolIndex] = symbol.Symbol(symId, symbolName, symbolType
450
                                                                                    , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
455
                                                                                    , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, currentHitRate, symbolRotatedAngle
451 456
                                                                                    , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
452 457
                                                                                    , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
453 458
                                    threadLock.release()
......
459 464
                                ## 현재 심볼과 검출된 심볼이 같을 경우 Match Point가 더 높은 정보로 교체
460 465
                                if len(matches) != 0:
461 466
                                    for s in matches:
462
                                        symbolMpCount = s.getMpCount()
463
                                        if symbolMpCount < mpCount:
467
                                        symbolHitRate = s.getHitRate()
468
                                        if symbolHitRate < currentHitRate:
464 469
                                            threadLock.acquire()
465
                                            totalMpCount = totalMpCount - symbolMpCount + mpCount
466 470
                                            searchedSymbolList[searchedSymbolList.index(s)] = symbol.Symbol(symId, symbolName, symbolType
467
                                                                                            , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
471
                                                                                            , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, currentHitRate, symbolRotatedAngle
468 472
                                                                                            , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
469 473
                                                                                            , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
470 474
                                            threadLock.release()
471 475
                                else:
472
                                    if mpCount >= symbolMinMatchCount:
473
                                        if searchedSymbol.getIsContainChild() == 1:
474
                                            ## 특정 카테고리 심볼을 걸러냄 (ex - 9900 대 Drum)
475
                                            if (searchedSymbol.getId() // 100) == (symId // 100):
476
                                                continue
477
                                            else:
478
                                                threadLock.acquire()
479
                                                foundSymbolCount = foundSymbolCount + 1
480
                                                totalMpCount = totalMpCount + mpCount
481
                                                addSearchedSymbol(symId, symbolName, symbolType
482
                                                                  , searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, mpCount, symbolRotatedAngle
483
                                                                  , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
484
                                                                  , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
485
                                                threadLock.release()
476
                                    #if mpCount >= symbolMinMatchCount:
477
                                    if searchedSymbol.getIsContainChild() == 1:
478
                                        ## 특정 카테고리 심볼을 걸러냄 (ex - 9900 대 Drum)
479
                                        if (searchedSymbol.getId() // 100) == (symId // 100):
480
                                            continue
481
                                        else:
482
                                            threadLock.acquire()
483
                                            foundSymbolCount = foundSymbolCount + 1
484
                                            addSearchedSymbol(symId, symbolName, symbolType
485
                                                                , searchedItemSp, sw, sh, symbolThreshold, currentHitRate, currentHitRate, symbolRotatedAngle
486
                                                                , isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild
487
                                                                , originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect)
488
                                            threadLock.release()
486 489
                                
487 490
                ## Rotate Symbol
488 491
                symGray = cv2.rotate(symGray, cv2.ROTATE_90_COUNTERCLOCKWISE)
......
493 496

  
494 497
        splitCount = splitCount // 2
495 498

  
496
    avgMpCount = 0
497
    if foundSymbolCount != 0:
498
        avgMpCount = totalMpCount / foundSymbolCount
499

  
500 499
    
501 500
    threadLock.acquire()
502 501
    srcName = os.path.splitext(os.path.basename(mainRes))[0]    
DTI_PID/DTI_PID/LineDetector.py
34 34
        @brief  get angle between given two vectors
35 35
        @author humkyung
36 36
        @date   2018.04.14
37
        @history    2018.05.29  Jeongwoo    Add try-exception
38
        @TODO : Need to modify case - Exception
37 39
    '''
38 40
    def getAngle(self, lhs, rhs):
39
        return math.acos(self.dotProduct(lhs, rhs) / (self.getLength(lhs) * self.getLength(rhs)))
41
        try:
42
            return math.acos(self.dotProduct(lhs, rhs) / (self.getLength(lhs) * self.getLength(rhs)))
43
        except Exception as ex:
44
            return sys.float_info.max
40 45
        
41 46
    """
42 47
        @brief  get distance between given two points
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py
1 1
# coding: utf-8
2
import sys
2 3
import os.path
3 4
import copy
4 5
try:
......
531 532
        @brief      Delete Line Item from scene
532 533
        @author     Jeongwoo
533 534
        @date       2018.05.29
535
        @history    2018.05.29  Add parameter 'self' / Make comments emit()
534 536
    '''
535
    def deleteLineItemFromScene():
536
        self.removed.emit(self)
537
    def deleteLineItemFromScene(self):
538
        #self.removed.emit(self)
537 539
        self.scene().removeItem(self)
538 540
        
539 541
    '''
DTI_PID/DTI_PID/symbol.py
1 1
from SymbolBase import SymbolBase
2 2

  
3
'''
4
    @history    2018.05.29  Jeongwoo    Change parameter and getter/setter (mpCount → hitRate)
5
'''
3 6
class Symbol(SymbolBase):
4
    def __init__(self, id, sName, sType, sp, width, height, threshold, minMatchCount, mpCount, rotatedAngle
7
    def __init__(self, id, sName, sType, sp, width, height, threshold, minMatchCount, hitRate, rotatedAngle
5 8
                 , isDetectOnOrigin, rotationCount, ocrOption, isContainChild = 0
6 9
                 , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None, isExceptDetect = 0, uid = None):
7 10
        SymbolBase.__init__(self, id, sName, sType, threshold, minMatchCount
......
16 19
        self.sp = sp
17 20
        self.width = width
18 21
        self.height = height
19
        self.mpCount = mpCount
22
        self.hitRate = hitRate
20 23
        self.rotatedAngle = rotatedAngle
21 24
        self.text = ''
22 25

  
......
38 41
    def getHeight(self):
39 42
        return self.height
40 43

  
41
    def setMpCount(self, mpCount):
42
        self.mpCount = mpCount
44
    def setHitRate(self, hitRate):
45
        self.hitRate = hitRate
43 46

  
44
    def getMpCount(self):
45
        return self.mpCount
47
    def getHitRate(self):
48
        return self.hitRate
46 49

  
47 50
    def setRotatedAngle(self, rotatedAngle):
48 51
        self.rotatedAngle = rotatedAngle

내보내기 Unified diff

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