개정판 6eca40c7
Modified to get file name from path by using python function
DTI_PID/DTI_PID/DTI_PID.py | ||
---|---|---|
39 | 39 |
tesseract_cmd = os.environ['TESSERACT_HOME'] + '\\tesseract.exe' |
40 | 40 |
|
41 | 41 |
#region Image path for test |
42 |
''' |
|
42 | 43 |
CONST_IMG_PID_UY1_K_300DPI = "res/UY1-K-2000_P1_300dpi.png" |
43 | 44 |
CONST_IMG_PID_UY1_K_2005G_300DPI = "res/UY1-K-2005G_P1_300dpi_black.png" |
44 | 45 |
CONST_IMG_PID_UY1_K_2006_300DPI = "res/UY1-K-2006_P1_300dpi_black.png" |
45 | 46 |
CONST_IMG_PID_UY1_K_2007_300DPI = "res/UY1-K-2007_P1_300dpi_black.png" |
47 |
''' |
|
46 | 48 |
#endregion |
47 | 49 |
|
48 | 50 |
#region Image path List for test |
... | ... | |
61 | 63 |
WHITE_LIST_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-" |
62 | 64 |
|
63 | 65 |
#DB_NAME = "db/DTI_PID_test.db" |
64 |
DB_NAME = os.path.dirname(os.path.realpath(__file__)) + "/db/DTI_PID.db"
|
|
66 |
DB_NAME = os.path.dirname(os.path.realpath(__file__)) + "\\db\\DTI_PID.db"
|
|
65 | 67 |
|
66 | 68 |
THREAD_MAX_WORKER = 4 |
67 | 69 |
threadLock = threading.Lock() |
... | ... | |
183 | 185 |
symbolClass = targetSymbol.getClass() |
184 | 186 |
symbolType = targetSymbol.getType() |
185 | 187 |
symbolItem = targetSymbol.getItem() |
186 |
symbolPath = os.path.dirname(os.path.realpath(__file__)) + "/" + targetSymbol.getPath()
|
|
188 |
symbolPath = os.path.dirname(os.path.realpath(__file__)) + "\\" + targetSymbol.getPath()
|
|
187 | 189 |
symbolThreshold = targetSymbol.getThreshold() |
188 | 190 |
symbolMinMatchCount = targetSymbol.getMinMatchCount() |
189 | 191 |
isDetectOnOrigin = targetSymbol.getIsDetectOnOrigin() |
... | ... | |
400 | 402 |
|
401 | 403 |
|
402 | 404 |
threadLock.acquire() |
403 |
srcName = mainRes.split("/")[-1] |
|
404 |
srcName = srcName.replace(".png", "") |
|
405 |
srcName = os.path.splitext(os.path.basename(mainRes))[0] |
|
405 | 406 |
print('finish symbol(count) / AvgMpCount : ' + symbolPath + '(' + str(foundSymbolCount) + ') / avgMpCount : ' + str(avgMpCount)) |
406 |
f = open(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_"+srcName+"_600dpi.txt", 'a+')
|
|
407 |
f = open(os.path.dirname(os.path.realpath(__file__)) + "\\res\\Result\\result_"+srcName+"_600dpi.txt", 'a+')
|
|
407 | 408 |
data = 'symbolName - (count) : ' + symbolPath + ' - (' + str(foundSymbolCount) + ') / avgMpCount : '+str(avgMpCount)+'\n' |
408 | 409 |
f.write(data) |
409 | 410 |
f.close() |
... | ... | |
576 | 577 |
drawFoundSymbols(symbol) |
577 | 578 |
#pool.shutdown(wait = True) |
578 | 579 |
|
579 |
|
|
580 |
srcName = mainRes.split("/")[-1] |
|
581 |
srcName = srcName.replace(".png", "") |
|
582 |
cv2.imwrite('res/Result/result_moved_'+srcName+'_600dpi.png', canvas) |
|
580 |
srcName = os.path.splitext(os.path.basename(mainRes))[0] |
|
581 |
cv2.imwrite(os.path.dirname(os.path.realpath(__file__)) + '\\res\\Result\\result_moved_'+srcName+'_600dpi.png', canvas) |
|
583 | 582 |
|
584 | 583 |
#Generate target symbol data list |
585 | 584 |
def initTargetSymbolDataList(): |
... | ... | |
681 | 680 |
(srcGray, tInfoList) = OCR.removeTextFromNpArray(srcGray) |
682 | 681 |
#srcGray = TOCR.removeTextFromNpArray(srcGray, TOCR.FLAG_IMAGE_TO_DATA) |
683 | 682 |
|
684 |
srcName = mainRes.split("/")[-1] |
|
685 |
srcName = srcName.replace(".png", "") |
|
683 |
srcName = os.path.splitext(os.path.basename(mainRes))[0] |
|
684 |
|
|
685 |
#srcName = mainRes.split("/")[-1] |
|
686 |
#srcName = srcName.replace(".png", "") |
|
686 | 687 |
|
687 | 688 |
stop = timeit.default_timer() |
688 | 689 |
seconds = stop - start |
689 |
f = open(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_"+srcName+"_600dpi.txt", 'a+')
|
|
690 |
f = open(os.path.dirname(os.path.realpath(__file__)) + "\\res\\Result\\result_"+srcName+"_600dpi.txt", 'a+')
|
|
690 | 691 |
data = "Running Time : " + str(seconds / 60) + "min\n" |
691 | 692 |
f.write(data) |
692 | 693 |
f.close() |
... | ... | |
703 | 704 |
|
704 | 705 |
print("Searched symbol count : " + str(len(searchedSymbolList))) |
705 | 706 |
|
706 |
removedSymbolImgPath = os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_fslo_"+srcName+"_600dpi.png"
|
|
707 |
removedSymbolImgPath = os.path.dirname(os.path.realpath(__file__)) + "\\res\\Result\\result_fslo_"+srcName+"_600dpi.png"
|
|
707 | 708 |
cv2.imwrite(removedSymbolImgPath, srcGray) |
708 |
cv2.imwrite(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_fslo_rect_"+srcName+"_600dpi.png", src)
|
|
709 |
cv2.imwrite(os.path.dirname(os.path.realpath(__file__)) + "\\res\\Result\\result_fslo_rect_"+srcName+"_600dpi.png", src)
|
|
709 | 710 |
|
710 | 711 |
|
711 | 712 |
####### Potrace |
... | ... | |
734 | 735 |
|
735 | 736 |
if __name__ == '__main__': |
736 | 737 |
if 1 == len(sys.argv): |
737 |
path = "d:/Projects/DTIPID/DTI_PID/DTI_PID/res/UY1-K-2000_P1_300dpi.png"
|
|
738 |
path = "d:\\Projects\\DTIPID\\DTI_PID\\DTI_PID\\res\\UY1-K-2000_P1_300dpi.png"
|
|
738 | 739 |
elif 2 == len(sys.argv): |
739 | 740 |
path = sys.argv[1] # 1 argument given is a string for the path of drawing |
740 | 741 |
|
내보내기 Unified diff