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]
|