프로젝트

일반

사용자정보

개정판 422da6c8

ID422da6c8103a73bd17bad928aa28266a9b414a6f
상위 8958cadd
하위 ade0521c

함의성이(가) 약 6년 전에 추가함

issue #000: 1221

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
1658 1658
                diffItems = []
1659 1659

  
1660 1660
                image, contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
1661

  
1662
                ##
1663
                i = 0
1664
                ##
1661 1665
                for contour in contours:
1662 1666
                    [x, y, w, h] = cv2.boundingRect(contour)
1663 1667

  
1664 1668
                    # remove too small one
1665
                    if (w < 10 or h < 10): continue
1669
                    if (w < 10 or h < 10):
1670
                        i += 1
1671
                        continue
1666 1672

  
1667 1673
                    '''
1668 1674
                    rect = QRectF(x, y, w, h)
......
1679 1685
                    approx = cv2.approxPolyDP(contour, epsilon, True)
1680 1686
                    approx = [pt[0] for pt in approx]
1681 1687
                    item = QEngineeringUnknownItem(approx)
1688

  
1682 1689
                    item.area = 'Drawing'
1683 1690
                    diffItems.append(item)
1684 1691
                    # up to here
1685 1692

  
1693
                    ##
1694
                    
1695
                    mask = np.zeros_like(imgNot)
1696
                    cv2.drawContours(mask, contours, i, 123, -1) # Draw filled contour in mask
1697
                    out = np.zeros_like(imgNot) # Extract out the object and place into output image
1698
                    out[mask == 123] = image[mask == 123]
1699

  
1700
                    # Now crop
1701
                    ##print(out)
1702
                    (x, y) = np.where(mask == 123)
1703
                    (topx, topy) = (np.min(x), np.min(y))
1704
                    (bottomx, bottomy) = (np.max(x), np.max(y))
1705
                    out = out[topx:bottomx+1, topy:bottomy+1]
1706

  
1707
                    # Show the output image
1708
                    cv2.imshow('Output', out)
1709
                    cv2.waitKey(0)
1710
                    cv2.destroyAllWindows()
1711

  
1712
                    i += 1
1713
                    
1714
                    ##
1715
                    
1716

  
1686 1717
                for item in diffItems:
1687 1718
                    item.transfer.onRemoved.connect(self.itemRemoved)
1688 1719
                    #self.addUnknownItemToScene(item)

내보내기 Unified diff

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