프로젝트

일반

사용자정보

개정판 5a225f86

ID5a225f86c86a9a7a7437b3068040bbd5f2733628
상위 520f7a6b
하위 4b8fa38b, 6eca40c7

humkyung 이(가) 약 7년 전에 추가함

Modified to use relative path

차이점 보기:

DTI_PID/DTI_PID/DTI_PID.py
35 35
#endregion
36 36

  
37 37
## Tesseract path
38
pytesseract.pytesseract.tesseract_cmd = 'D:\\Program Files\\Tesseract-OCR\\tesseract.exe'
39
tesseract_cmd = 'D:\\Program Files\\Tesseract-OCR\\tesseract.exe'
38
pytesseract.pytesseract.tesseract_cmd = os.environ['TESSERACT_HOME'] + '\\tesseract.exe'
39
tesseract_cmd = os.environ['TESSERACT_HOME'] + '\\tesseract.exe'
40 40

  
41 41
#region Image path for test
42 42
CONST_IMG_PID_UY1_K_300DPI = "res/UY1-K-2000_P1_300dpi.png"
......
61 61
WHITE_LIST_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-"
62 62

  
63 63
#DB_NAME = "db/DTI_PID_test.db"
64
DB_NAME = "db/DTI_PID.db"
64
DB_NAME = os.path.dirname(os.path.realpath(__file__)) + "/db/DTI_PID.db"
65 65

  
66 66
THREAD_MAX_WORKER = 4
67 67
threadLock = threading.Lock()
......
183 183
    symbolClass = targetSymbol.getClass()
184 184
    symbolType = targetSymbol.getType()
185 185
    symbolItem = targetSymbol.getItem()
186
    symbolPath = targetSymbol.getPath()
186
    symbolPath = os.path.dirname(os.path.realpath(__file__)) + "/" + targetSymbol.getPath()
187 187
    symbolThreshold = targetSymbol.getThreshold()
188 188
    symbolMinMatchCount = targetSymbol.getMinMatchCount()
189 189
    isDetectOnOrigin = targetSymbol.getIsDetectOnOrigin()
......
403 403
    srcName = mainRes.split("/")[-1]
404 404
    srcName = srcName.replace(".png", "")
405 405
    print('finish symbol(count) / AvgMpCount : ' + symbolPath + '(' + str(foundSymbolCount) + ') / avgMpCount : ' + str(avgMpCount))
406
    f = open("res/Result/result_"+srcName+"_600dpi.txt", 'a+')
406
    f = open(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_"+srcName+"_600dpi.txt", 'a+')
407 407
    data = 'symbolName - (count) : ' + symbolPath + ' - (' + str(foundSymbolCount) + ') / avgMpCount : '+str(avgMpCount)+'\n'
408 408
    f.write(data)
409 409
    f.close()
......
581 581
    srcName = srcName.replace(".png", "")
582 582
    cv2.imwrite('res/Result/result_moved_'+srcName+'_600dpi.png', canvas)
583 583

  
584

  
585

  
586

  
587

  
588 584
#Generate target symbol data list
589 585
def initTargetSymbolDataList():
590 586
    ############ region SQLite
......
650 646
    
651 647
    srcList = []
652 648
    srcList.append(path)
653
    #srcList = [CONST_IMG_PID_UY1_K_2006_300DPI]
654
    #srcList = [CONST_IMG_PID_UY1_K_300DPI]
655
    #srcList = [CONST_IMG_PID_UY1_K_2005G_300DPI, CONST_IMG_PID_UY1_K_2007_300DPI]
656
    #srcList = [CONST_IMG_PID_UY1_K_300DPI, CONST_IMG_PID_UY1_K_2005G_300DPI, CONST_IMG_PID_UY1_K_2006_300DPI, CONST_IMG_PID_UY1_K_2007_300DPI]
657
    #srcList = [CONST_IMG_PID_UY1_K_2006_300DPI]
658 649

  
659 650
    initTargetSymbolDataList()
660 651

  
......
695 686

  
696 687
        stop = timeit.default_timer()    
697 688
        seconds = stop - start
698
        f = open("res/Result/result_"+srcName+"_600dpi.txt", 'a+')
689
        f = open(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_"+srcName+"_600dpi.txt", 'a+')
699 690
        data = "Running Time : " + str(seconds / 60) + "min\n"
700 691
        f.write(data)
701 692
        f.close()
......
712 703
        
713 704
        print("Searched symbol count : " + str(len(searchedSymbolList)))
714 705

  
715
        removedSymbolImgPath = "res/Result/result_fslo_"+srcName+"_600dpi.png"
706
        removedSymbolImgPath = os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_fslo_"+srcName+"_600dpi.png"
716 707
        cv2.imwrite(removedSymbolImgPath, srcGray)
717
        cv2.imwrite("res/Result/result_fslo_rect_"+srcName+"_600dpi.png", src)
708
        cv2.imwrite(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/result_fslo_rect_"+srcName+"_600dpi.png", src)
718 709

  
719 710

  
720 711
        ####### Potrace
......
723 714

  
724 715
        xg.writeXml(srcName, srcWidth, srcHeight, searchedSymbolList, textInfoList, imgLineList)
725 716
    
717
    '''
726 718
    b, g, r = cv2.split(src)
727 719
    pltSrc = cv2.merge([r, g, b])
728 720

  
......
738 730
        elif k == 'r':
739 731
            print('result')
740 732
            break;
733
    '''
741 734

  
742 735
if __name__ == '__main__':
743
    path =  "res/UY1-K-2000_P1_300dpi.png" 
744
    #path = sys.argv[1]  # 1 argument given is a string for the path of drawing
736
    if 1 == len(sys.argv):
737
        path =  "d:/Projects/DTIPID/DTI_PID/DTI_PID/res/UY1-K-2000_P1_300dpi.png" 
738
    elif 2 == len(sys.argv):
739
        path = sys.argv[1]  # 1 argument given is a string for the path of drawing
740
    
745 741
    #region Program start
746 742
    main(path)
747 743
    #endregion
DTI_PID/DTI_PID/XmlGenerator.py
2 2
import symbol
3 3
import TextInfo as ti
4 4
import math
5
import os
5 6

  
6 7
ROOT_NODE_NAME = "DWG"
7 8
ROOT_DWGNAME_NODE_NAME = "DWGNAME"
......
45 46
def writeXml(pidName, pidWidth, pidHeight, searchedSymbolList, textInfoList, imgLineList):
46 47
    xmlData = generateXml(pidName, pidWidth, pidHeight, searchedSymbolList, textInfoList, imgLineList)
47 48
    #xmlData = indent(xmlData)
48
    ElementTree(xmlData).write("res/Result/"+pidName+".xml")
49
    ElementTree(xmlData).write(os.path.dirname(os.path.realpath(__file__)) + "/res/Result/"+pidName+".xml")
49 50

  
50 51
def generateXml(pidName, pidWidth, pidHeight, searchedSymbolList, textInfoList, imgLineList):
51 52
    xml = Element(ROOT_NODE_NAME) # Root Node

내보내기 Unified diff

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