OpenCV Python HoughLinesP给出错误<unknown>不是numpy数组</unknown>

时间:2015-02-16 23:47:41

标签: python opencv numpy

我几乎完全复制了Hough变换documented here,但使用了视频捕捉。这是我的完整代码:

import cv2
import numpy as np

cap = cv2.VideoCapture(0)
while(True):
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    edges = cv2.Canny(gray,50,150,apertureSize = 3)

    minLineLength = 100
    maxLineGap = 10

    if edges is not None and edges.size > 0:
        lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)

    frame.show()
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()

使用此代码会给我错误

追踪(最近一次呼叫最后一次):

File "houghTransform.py", line 14, in <module>
    lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
TypeError: <unknown> is not a numpy array

为什么我收到此错误?

0 个答案:

没有答案