프로젝트

일반

사용자정보

개정판 1fa8e5e5

ID1fa8e5e51bafb2c63bdf303eab36a8daf485f314
상위 7a6c7db7
하위 6c609196

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

issue 701: imp perform

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
1630 1630
        from QEngineeringFlowArrowItem import QEngineeringFlowArrowItem 
1631 1631
        from EngineeringLineItem import QEngineeringLineItem
1632 1632
        from EngineeringUnknownItem import QEngineeringUnknownItem
1633
        import math
1634 1633

  
1635 1634
        try:
1636 1635
            docData = AppDocData.instance()
......
1680 1679
                    for item in items:
1681 1680
                        diffItems.remove(item)
1682 1681
                    '''
1683

  
1684
                    if isLineNoIndicator(idx, contours):
1682
                    if self.isLineNoIndicator(idx, contours, imgNot):
1685 1683
                        idx += 1
1686 1684
                    else:
1685
                        idx += 1
1687 1686
                        # create unknown item
1688 1687
                        epsilon = cv2.arcLength(contour, True)*0.001
1689 1688
                        approx = cv2.approxPolyDP(contour, epsilon, True)
......
1711 1710
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1712 1711
            self.addMessage.emit(MessageType.Error, message)
1713 1712

  
1714
    def isLineNoIndicator(self, idx, con):
1713
    def isLineNoIndicator(self, idx, contours, imgNot):
1715 1714
        '''
1716 1715
            @brief      db update when save or recognition
1717 1716
            @author     euisung
1718 1717
            @date       2018.12.26
1719 1718
        '''
1719
        import math
1720
        [x, y, w, h] = cv2.boundingRect(contours[idx])
1721
        if (w < 100 and h < 100):
1722
            return False
1723

  
1720 1724
        fLines = []
1721 1725
        mask = np.zeros_like(imgNot)
1722 1726
        cv2.drawContours(mask, contours, idx, 123, -1) # Draw filled contour in mask
1723 1727
        out = np.zeros_like(imgNot) # Extract out the object and place into output image
1724
        out[mask == 123] = image[mask == 123]
1728
        out[mask == 123] = imgNot[mask == 123]
1725 1729

  
1726 1730
        # Now crop
1727 1731
        ##print(out)
......
1730 1734
        (bottomx, bottomy) = (np.max(x), np.max(y))
1731 1735
        out = out[topx:bottomx+1, topy:bottomy+1]
1732 1736
        h, w = out.shape[0], out.shape[1]
1733
        if h < 50 and w < 50:
1734
            idx += 1
1735
            continue
1736 1737
        maxDifH, maxDifW = math.ceil(math.tan(4 * math.pi / 180) / 2 * w), math.ceil(math.tan(4 * math.pi / 180) / 2 * h)
1737 1738

  
1738 1739
        edged2 = cv2.Canny(out, 100, 200)
1739
        lines = cv2.HoughLines(edged2, 1, np.pi/180, 60)
1740
        lines = cv2.HoughLines(edged2, 1, np.pi/180, 65)
1740 1741
        if lines is None:
1741
            idx += 1
1742
            continue
1742
            return False
1743 1743
        for line in lines:
1744 1744
            r, theta = line[0]
1745 1745
            a, b = np.cos(theta), np.sin(theta)
......
1763 1763
            else:
1764 1764
                otherLines.append(fLine)
1765 1765
        if (len(horLines) > 0 and len(verLines) > 0) or len(otherLines) is 0 or (len(horLines) == 0 and len(verLines) == 0):
1766
            idx += 1
1767
            continue
1766
            return False
1768 1767

  
1769 1768
        baseLines = []
1770 1769
        baseDifV = 0
......
1801 1800
                j += 1
1802 1801
            i += 1
1803 1802
        if not isSameLine:
1804
            idx += 1
1805
            continue
1803
            return False
1806 1804

  
1807 1805
        isSameLine = True
1808 1806
        i = 0
......
1827 1825
                j += 1
1828 1826
            i += 1
1829 1827
        if not isSameLine:
1830
            idx += 1
1831
            continue
1828
            return False
1832 1829
                
1833 1830
        isSameLine = True
1834 1831
        i = 0
......
1849 1846
                j += 1
1850 1847
            i += 1
1851 1848
        if not isSameLine:
1852
            idx += 1
1853
            continue
1849
            return False
1854 1850
                        
1855 1851
        # Show the output image
1856 1852
        print('line no indicator')
1857 1853
        #cv2.imshow('Output', out)
1858 1854
        #cv2.waitKey(0)
1859 1855
        #cv2.destroyAllWindows()
1860

  
1861
        idx += 1
1856
        return True
1862 1857

  
1863 1858
    '''
1864 1859
        @brief      load recognition result

내보내기 Unified diff