프로젝트

일반

사용자정보

개정판 0f542e23

ID0f542e23e8ab20e585e78953380a3ffb15263a61
상위 64435abb
하위 8a4edfbe

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

...

차이점 보기:

DTI_PID/DTI_PID/App.py
40 40
    @history    18.04.23    Jeongwoo    Change method to execute ProjectDialog(dlg.exec_()→dlg.showDialog())
41 41
'''
42 42
if __name__ == '__main__':
43
    import cv2
43 44
    import DTI_PID_UI
44 45
    from ProjectDialog import Ui_Dialog
45 46
    from MainWindow import MainWindow
46 47

  
48
    '''
49
    img = cv2.imread('d:/Projects/DTIPID/HEC/drawings/HEC_P1_600DPI.png')
50
    img = cv2.threshold(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), 127, 255, cv2.THRESH_BINARY)[1]
51
    cv2.imwrite('d:/Projects/DTIPID/HEC/drawings/HEC_P1_600DPI_.png', img)
52
    '''
53

  
47 54
    app = App(sys.argv)
48 55
    try:
49 56
        dlg = Ui_Dialog()
DTI_PID/DTI_PID/DTI_PID.py
349 349
        # up to here
350 350

  
351 351
        sym = cv2.imread(symbolPath, 1)
352
        #symGray = cvtGrayImage(sym)
353
        symGray = cv2.threshold(cvtGrayImage(sym), 127, 255, cv2.THRESH_BINARY)[1]
354
        cv2.imshow('symbol', symGray)
355
        cv2.waitKey(0)
352
        symGray = cvtGrayImage(sym)
353
        ## TODO: 이진화 시켰을때 심볼이 검출되지 않음
354
        ## symGray = cv2.threshold(cvtGrayImage(sym), 127, 255, cv2.THRESH_BINARY)[1]
355
        ## cv2.imshow('symbol', symGray)
356
        ## cv2.waitKey(0)
356 357
        sow, soh = symGray.shape[::-1] # symbol original w, h
357 358

  
358 359
        offsetDrawingArea=[]
......
495 496
            splitCount = splitCount // 2
496 497

  
497 498
        threadLock.acquire()
498
        listWidget.addItem('Found Symbol   : ' + os.path.basename(symbolPath.replace('.png', '')) + ' - (' + str(foundSymbolCount) + ')')
499
        listWidget.addItem('Found Symbol   : ' + os.path.splitext(os.path.basename(symbolPath))[0] + ' - (' + str(foundSymbolCount) + ')')
499 500
        threadLock.release()
500 501

  
501 502
        updateProgressSignal.emit(maxProgressValue)
DTI_PID/DTI_PID/QSymbolEditorDialog.py
31 31
        QDialog.__init__(self, parent)
32 32

  
33 33
        try:
34
            '''
35
            #cvImage = self.convertQImageToMat(image)
36
            cvImage = cv2.cvtColor(self.convertQImageToMat(image), cv2.COLOR_BGR2GRAY)
37
            binaryImg,mask = cv2.threshold(cvImage, 127, 255, cv2.THRESH_BINARY)# + cv2.THRESH_OTSU)
38

  
39
            contourImg = np.ones(cvImage.shape, np.uint8)
40

  
41
            _image, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
42
            maxArea = None
43
            maxAreaContour = None
44
            for contour in contours:
45
                area = cv2.contourArea(contour, True)
46
                #cv2.drawContours(contourImg, [contour], -1, 0, -1)
47
                cv2.drawContours(contourImg, [contour], -1, 255, -1)
48
                #maxArea = area
49
                #maxAreaContour = contour
50
            
51
            for contour in contours:
52
                area = cv2.contourArea(contour, True)
53
                if area < 0:
54
                    cv2.drawContours(contourImg, [contour], -1, 255, -1)
55

  
56
            cv2.imwrite('d:/temp/temp.png', contourImg)
57

  
58
            self.image = QImage(contourImg, contourImg.shape[1],\
59
                contourImg.shape[0], contourImg.shape[1], QImage.Format_Mono)
60

  
61
            #self.image = QImage(contourImg, contourImg.shape[1],\
62
            #    contourImg.shape[0], contourImg.shape[1] * 3, QImage.Format_RGB888)
63
            '''
64

  
65 34
            self.image = image
66 35
            self.selectedSymbol = selectedSymbol
67 36
            self.project = project
......
402 371
                        if not os.path.exists(imageLocation):
403 372
                            os.makedirs(imageLocation) 
404 373
                            
374
                        '''
375
                        arr = self.convertQImageToMat(image)
405 376
                        b = image.bits()
406 377
                        # sip.voidptr must know size to support python buffer interface
407 378
                        b.setsize(image.height() * image.width() * image.depth())
408 379
                        arr = np.frombuffer(b, np.uint8).reshape((image.height(), image.width(), image.bitPlaneCount()))
409 380
                        img = cv2.threshold(cv2.cvtColor(arr, cv2.COLOR_BGR2GRAY), 127, 255, cv2.THRESH_BINARY)[0]
410 381
                        cv2.imwrite(imagePath, img)
382
                        '''
411 383

  
412
                        #image.save(imagePath, 'PNG')
384
                        image.save(imagePath, 'PNG')
413 385

  
414 386
                        svgLocation = os.path.join(self.project.getSvgFilePath(), fileType)
415 387
                        if not os.path.exists(svgLocation):

내보내기 Unified diff

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