Python opencv库出错:AttributeError:';非类型';对象没有属性';形状';

Python opencv库出错:AttributeError:';非类型';对象没有属性';形状';,python,opencv,Python,Opencv,我将对图像的引用作为参数传递到函数中。应该可以将引用列表传递给图像,因此使用该列表。代码如下所示 def cleanOCR(borders): detectedOCR = [] print(f'Borders = {borders}') for i, image in enumerate(borders): image = cv2.imread(image) assert not isinstance(image,type(None)),

我将对图像的引用作为参数传递到函数中。应该可以将引用列表传递给图像,因此使用该列表。代码如下所示

def cleanOCR(borders):
    detectedOCR = []
    print(f'Borders = {borders}')
    for i, image in enumerate(borders):
        image = cv2.imread(image)
        assert not isinstance(image,type(None)), 'image not found'
        edges = cv2.Canny(image, 50, 150, apertureSize=3)
        lines = cv2.HoughLinesP(image=edges, rho=1, theta=np.pi / 180, threshold=100, lines=np.array([]), minLineLength=100, maxLineGap=80)    
        a, b, c = lines.shape
但我犯了个错误

  File "platesOCR.py", line 66, in cleanOCR
    a, b, c = lines.shape
AttributeError: 'NoneType' object has no attribute 'shape'
Im使用cv2版本“4.1.1” 代码不是我的,我刚刚开始处理OpenCV

print(f'Borders = {borders}') give me right file path

它本质上意味着在图像中没有检测到线条

要检查这一点,只需打印行。我猜它会是空的

要不获取空np数组,请尝试减小minLineLength值。图像中短于此值的线段将被拒绝。所以我建议降低这个值

还有maxLineGap。它是连接同一直线上的点之间允许的最大间隙。所以你的价值似乎更高