프로젝트

일반

사용자정보

개정판 a5003140

IDa500314050af4225e4e9c95900b1ca6b46e7c354
상위 fbf468d4
하위 cf3634ce

humkyung 이(가) 6년 이상 전에 추가함

revised #577: Equipment Desc. 영역 설정

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
56 56
        self.height = None
57 57
    
58 58
    '''
59
        @brief  parse area
60
        @author humkyung
61
        @date   2018.06.29
62
    '''
63
    def parse(self, strArea):
64
        import re
65

  
66
        found = re.findall('\d+', strArea)
67
        if len(found) == 4:
68
            self.x = int(found[0])
69
            self.y = int(found[1])
70
            self.width = int(found[2])
71
            self.height = int(found[3])
72
        
73
    '''
59 74
        @brief  clone an object
60 75
    '''
61 76
    def clone(self):
......
495 510
        # Catch the exception
496 511
        except Exception as ex:
497 512
            # Roll back any change if something goes wrong
498
            conn.rollback()
499 513
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
500 514
        finally:
501
            # Close the db connection
502
            '''DO NOTHING'''
515
            pass
503 516

  
504 517
    '''
505 518
        @brief      Make Directory
......
785 798
                for row in rows:
786 799
                    area = Area()
787 800
                    area.name = row[1]
788
                    tokens = row[2].split(',')
789
                    area.x = round(float(tokens[0]))
790
                    area.y = round(float(tokens[1]))
791
                    area.width = round(float(tokens[2]))
792
                    area.height = round(float(tokens[3]))
801
                    area.parse(row[2])
793 802
                    self._areas.append(area)
794 803
            # Catch the exception
795 804
            except Exception as ex:
......
921 930

  
922 931
        try:
923 932
            # Creates or opens a file called mydb with a SQLite3 DB
924
            dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
933
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db")
925 934
            conn = sqlite3.connect(dbPath)
926 935
            # Get a cursor object
927 936
            cursor = conn.cursor()
928 937

  
929 938
            for area in self._areas:
930
                sql = "insert or replace into configuration values('Area','{}','{},{},{},{}')".format(area.name, round(area.x), round(area.y), round(area.width), round(area.height))
939
                sql = "insert or replace into configuration values('Area','{}','({},{}),({},{})')".format(area.name, round(area.x), round(area.y), round(area.width), round(area.height))
931 940
                cursor.execute(sql)
932 941

  
933 942
            conn.commit()
DTI_PID/DTI_PID/DTI_PID.py
850 850
                Jeongwoo 2018.06.21 If noteTextInfoList is None, change from None to empty list
851 851
'''
852 852
def executeRecognition(signal, updateProgressSignal, path, listWidget, isSymbolTextChecked):
853
    import re
854

  
853 855
    global src
854 856
    global srcGray
855 857
    global ocrCompletedSrc
......
892 894
                srcGray = src.copy()
893 895
            srcGray = cv2.threshold(srcGray, 127, 255, cv2.THRESH_BINARY)[1]
894 896
            
897
            # remove equipment desc. area
898
            configs = docData.getConfigs('{} Equipment Desc Area'.format(docData.imgName))
899
            for config in configs:
900
                found = re.findall('\d+', config.value)
901
                if len(found) == 4:
902
                    cv2.rectangle(srcGray, (int(found[0]), int(found[1])), (int(found[2]), int(found[3])), 255, -1)
903
            # up to here
904
            
895 905
            area = docData.getArea('Drawing')
896 906
            if area is not None:
897
                #TODO: 영역을 설정한 값과 이미지 좌표계를 차이를 보정
898 907
                area.img = srcGray[round(area.y):round(area.y+area.height), round(area.x):round(area.x+area.width)]
899 908

  
900 909
            listWidget.addItem("Start recognition : " + mainRes)
......
1105 1114
    @date   2018.06.11
1106 1115
'''
1107 1116
def getDifference(orgImagePath, recImagePath):
1117
    import re
1118

  
1108 1119
    global srcGray
1109 1120
    global ocrCompletedSrc
1110 1121
    global textInfoList
1111 1122
    global noteTextInfoList
1112 1123

  
1113 1124
    try:
1125
        docData = AppDocData.instance()
1114 1126
        if os.path.isfile(orgImagePath) and os.path.isfile(recImagePath):
1115 1127
            imgOriginal = cv2.threshold(cvtGrayImage(cv2.imread(orgImagePath, 1)), 127, 255, cv2.THRESH_BINARY)[1]
1128
            # remove equipment desc. area
1129
            configs = docData.getConfigs('{} Equipment Desc Area'.format(docData.imgName))
1130
            for config in configs:
1131
                found = re.findall('\d+', config.value)
1132
                if len(found) == 4:
1133
                    cv2.rectangle(imgOriginal, (int(found[0]), int(found[1])), (int(found[2]), int(found[3])), 255, -1)
1134
            # up to here
1135

  
1116 1136
            imgRecognized = cv2.threshold(cvtGrayImage(cv2.imread(recImagePath, 1)), 127, 255, cv2.THRESH_BINARY)[1]
1117 1137

  
1118 1138
            imgDiff = np.ones(imgOriginal.shape, np.uint8)*255

내보내기 Unified diff

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