프로젝트

일반

사용자정보

개정판 deb37242

IDdeb37242a4c8a5d5f6fa01ecbb3838786a730c26
상위 8829d0c5
하위 d6aa5aa4, 23b86a3c

백흠경이(가) 5년 이상 전에 추가함

issue #000: fixed findContours because upgrading OpenCV 4.1

Change-Id: Id55cfcf2dc2be5b11532e15f2c9bbc3d65287ab9

차이점 보기:

DTI_PID/DTI_PID/DetectSymbolDialog.py
187 187
        ## contours 추출을 위한 색반전
188 188
        areaImg = cv2.bitwise_not(areaImg) 
189 189
        ## contours 추출
190
        image, contours, hierarchy = cv2.findContours(areaImg, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
190
        contours, hierarchy = cv2.findContours(areaImg, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
191 191
        for contour in contours:
192 192
            [x, y, w, h] = cv2.boundingRect(contour)
193 193

  
......
307 307
    '''
308 308
    def getContours(self, areaImg):
309 309
        
310
        image, contours, hierarchy = cv2.findContours(areaImg, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
310
        contours, hierarchy = cv2.findContours(areaImg, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
311 311

  
312 312
        ## RecList 정리
313 313
        lineWidth = 5
DTI_PID/DTI_PID/LineDetector.py
578 578
            imgNot = cv2.bitwise_xor(self._image, imgNot)
579 579
            imgNot = cv2.erode(imgNot, np.ones((2,2), np.uint8))
580 580

  
581
            image, contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
581
            contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
582 582
            if len(contours) is 0:
583 583
                return []
584 584
                
DTI_PID/DTI_PID/MainWindow.py
2111 2111
                cv2.bitwise_not(imgDiff, imgNot)
2112 2112
                imgNot = cv2.dilate(imgNot, np.ones((8,8), np.uint8))
2113 2113

  
2114
                image, contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
2114
                contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
2115 2115

  
2116 2116
                ##
2117 2117
                idx = 0
DTI_PID/DTI_PID/OcrResultDialog.py
181 181
                cv2.bitwise_not(img, imgNot)
182 182
                imgNot = cv2.dilate(imgNot, np.ones((8,8), np.uint8))
183 183

  
184
                image, contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
184
                contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
185 185
                minX, minY, maxX, maxY = sys.maxsize, sys.maxsize, 0 ,0
186 186
                if len(contours) is 0:
187 187
                    minX, minY, maxX, maxY = self.boundingBox.x(), self.boundingBox.y(), self.boundingBox.x() + self.image.width(), self.boundingBox.y() + self.image.height()
DTI_PID/DTI_PID/RecognitionDialog.py
120 120
            configs = appDocData.getConfigs('Small Object Size', 'Max Area')
121 121
            maxArea = int(configs[0].value) if 1 == len(configs) else 50
122 122
    
123
            _,contours,_ = cv2.findContours(image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
123
            contours,_ = cv2.findContours(image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
124 124
            selectedContours=[]
125 125
            for contour in contours:
126 126
                area = cv2.contourArea(contour)
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
746 746
            imgLine = cv2.bitwise_not(imgLine)
747 747
            imgLine = cv2.erode(imgLine, np.ones((10, 10), np.uint8))
748 748

  
749
            image, contours, hierarchy = cv2.findContours(imgLine, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
749
            contours, hierarchy = cv2.findContours(imgLine, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
750 750
            if contours:
751 751
                contours = sorted(contours, key=cv2.contourArea, reverse=True)
752 752
                [x, y, w, h] = cv2.boundingRect(contours[0])
DTI_PID/DTI_PID/TextDetector.py
63 63
        contourImg = np.ones(imgGray.shape, np.uint8) * 255
64 64
        binaryImg,mask = cv2.threshold(imgGray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
65 65

  
66
        image, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
66
        contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
67 67
        for contour in contours:
68 68
            # remove too big one or horizontal/vertical line
69 69
            [x, y, w, h] = cv2.boundingRect(contour)
......
96 96
        #path = os.path.join(project.getTempPath(), 'bitwise_not_{}.png'.format(appDocData.imgName))
97 97
        #cv2.imwrite(path, eroded)
98 98
        
99
        image, contours, hierarchy = cv2.findContours(eroded, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
99
        contours, hierarchy = cv2.findContours(eroded, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
100 100
        for contour in contours:
101 101
            area = cv2.contourArea(contour, True)
102 102
            if area < 0:
......
107 107

  
108 108
                horizontal,max_width = 0,0
109 109
                vertical,max_height = 0,0
110
                _, _contours, _ = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
110
                _contours, _ = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
111 111
                for xx in _contours:
112 112
                    [_x, _y, _w, _h] = cv2.boundingRect(xx)
113 113
                    cv2.rectangle(img, (_x, _y), (_x+_w, _y+_h), 255, 1)
......
131 131
                    if shrinkSize > 0:
132 132
                        img = cv2.erode(img, np.ones((shrinkSize,shrinkSize), np.uint8))
133 133

  
134
                    _, _contours, _ = cv2.findContours(img, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
134
                    _contours, _ = cv2.findContours(img, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
135 135
                    for xx in _contours:
136 136
                        [_x, _y, _w, _h] = cv2.boundingRect(xx)
137 137
                        cv2.rectangle(img, (_x, _y), (_x+_w, _y+_h), 255, 1)
DTI_PID/DTI_PID/TrainingImageListDialog.py
351 351
                        # //remove noise
352 352
                        '''
353 353
                        if self.isNoisable(boxes[index][0]):
354
                            image, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
354
                            contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
355 355
                            for contour in contours:
356 356
                                # remove too big one
357 357
                                [x, y, w, h] = cv2.boundingRect(contour)

내보내기 Unified diff

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