我是 Python opencv 的新手。谁能帮我解决错误
import cv
cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 1
capture = cv.CaptureFromCAM(camera_index)
def repeat():
global capture #declare as globals since we are assigning to them now global camera_index
frame = cv.QueryFrame(capture)
cv.ShowImage("w1", frame)
c = cv.WaitKey(100)
if(c=="n"): #in "n" key is pressed while the popup window is in focus
camera_index += 1 #try the next camera index
capture = cv.CaptureFromCAM(camera_index)
if not capture: #if the next camera index didn't work, reset to 0.
camera_index =1
capture = cv.CaptureFromCAM(camera_index)
while True:
repeat()
这是我得到的错误 -
OpenCV Error: Null pointer (NULL array pointer is passed) in cvGetMat, file /home/paraste/OpenCV-2.3.1/modules/core/src/array.cpp, line 2382
Traceback (most recent call last):
File "dualcamara.py", line 10, in <module>
img = cv.GetMat(cv.QueryFrame(capture), 500)
cv2.error: NULL array pointer is passed