프로젝트

일반

사용자정보

개정판 0a5f5fa3

ID0a5f5fa39781b11ec74f570f756e24c2f7712483
상위 df052b57
하위 6830e470

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

issue #480: prepare diagonal line

Change-Id: I16a2d28ab7ed64c29af91ff8ab1ccf5338964fa9

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
1745 1745
                    epsilon = cv2.arcLength(contour, True)*0.001
1746 1746
                    approx = cv2.approxPolyDP(contour, epsilon, True)
1747 1747
                    approx = [pt[0] for pt in approx]
1748
                    resultStr, isVH, otherLine = self.determineRemainObject(idx, contours, imgNot)
1748
                    resultStr, resultList = self.determineRemainObject(idx, contours, imgNot)
1749 1749
                    if resultStr == 'LineIndicator':
1750
                        item = QEngineeringUnknownItem(approx, 'True', isVH, otherLine)
1750
                        item = QEngineeringUnknownItem(approx, 'True', resultList[0], resultList[1])
1751 1751
                        docData.lineIndicators.append(item)
1752
                    else:
1752
                    elif resultStr == 'MissingLine':
1753
                        pass
1754
                    elif resultStr == 'Unknown':
1753 1755
                        item = QEngineeringUnknownItem(approx, 'False')
1754 1756
                        docData.unknowns.append(item)
1755 1757
                    item.area = 'Drawing'
......
1779 1781
        '''
1780 1782
        import math
1781 1783
        [x, y, w, h] = cv2.boundingRect(contours[idx])
1782
        if (w < 250 and h < 250):
1783
            return ('False', None, None)
1784

  
1784
        
1785 1785
        fLines = []
1786 1786
        maxDifAngle = 3
1787 1787
        mask = np.zeros_like(imgNot)
......
1798 1798
        h, w = out.shape[0], out.shape[1]
1799 1799
        maxDifH, maxDifW = math.ceil(math.tan(4 * math.pi / 180) / 2 * w), math.ceil(math.tan(4 * math.pi / 180) / 2 * h)
1800 1800

  
1801
        # detection lines
1801 1802
        edged2 = cv2.Canny(out, 100, 200)
1802 1803
        lines = cv2.HoughLines(edged2, 1, np.pi/180, 60)
1803 1804
        if lines is None:
1804
            return ('False', None, None)
1805
            return ('Unknown', [])
1805 1806
        for line in lines:
1806 1807
            r, theta = line[0]
1807 1808
            a, b = np.cos(theta), np.sin(theta)
......
1812 1813
            degree = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
1813 1814
            fLine = [x1, y1, x2, y2, degree]
1814 1815
            fLines.append(fLine)
1815
                        
1816
        result, isVH, mergedOtherLine = self.isLineNoIndicator(w, h, maxDifAngle, maxDifH, maxDifW, fLines)
1817
        if result:
1818
            return ('LineIndicator', isVH, mergedOtherLine)
1819

  
1820
    def isLineNoIndicator(self, w, h, maxDifAngle, maxDifH, maxDifW, fLines):
1821
        '''
1822
            @brief      determine remain objects -> line no indicator, missing line or unknown
1823
            @author     euisung
1824
            @date       2019.03.25
1825
        '''
1826
        import math
1827

  
1816
        
1828 1817
        horLines = []
1829 1818
        verLines = []
1830 1819
        otherLines = []
......
1837 1826
                horLines.append(fLine)
1838 1827
            else:
1839 1828
                otherLines.append(fLine)
1829

  
1830
        # determine line no indicator       
1831
        result, isVH, mergedOtherLine = self.isLineNoIndicator(w, h, maxDifAngle, maxDifH, maxDifW, horLines, verLines, otherLines)
1832
        if result:
1833
            return ('LineIndicator', [isVH, mergedOtherLine])
1834

  
1835
        # determine missing line
1836
        result = self.isMissingLine(w, h, fLines, horLines, verLines, otherLines)
1837
        if result:
1838
            return ('MissingLine', [])
1839

  
1840
        return ('Unknown', [])
1841

  
1842
    def isMissingLine(w, h, fLines):
1843
        '''
1844
            @brief      determine lines that LineDetector can not catch
1845
            @author     euisung
1846
            @date       2019.03.25
1847
        '''
1848
        return False
1849

  
1850
    def isLineNoIndicator(self, w, h, maxDifAngle, maxDifH, maxDifW, horLines, verLines, otherLines):
1851
        '''
1852
            @brief      determine remain objects -> line no indicator, missing line or unknown
1853
            @author     euisung
1854
            @date       2019.03.25
1855
        '''
1856
        import math
1857

  
1858
        if (w < 250 and h < 250):
1859
            return (False, None, None)
1860

  
1840 1861
        if (len(horLines) > 0 and len(verLines) > 0) or len(otherLines) is 0 or (len(horLines) == 0 and len(verLines) == 0):
1841 1862
            return (False, None, None)
1842 1863

  

내보내기 Unified diff