Accesing laptop camera with openCV
<p>I run the following code, according this page - <a href="http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html" rel="nofollow">http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html</a></p>

<pre><code>cap = cv2.VideoCapture(0)
print cap.read()
print cap.open()
cap.release()
</code></pre>

<p>the results I get are:</p>

<p>(False, None)</p>

<p>TypeError: Required argument 'device' (pos 1) not found</p>

<p>I use jupyter notebook, python 2.7, openCV 2.4. </p>

<p>How can I get the openCV to work with the cam?</p>

<p>For OpenCV 2.4, use the following code:</p>

<pre><code>import cv2
import cv
cap = cv2.VideoCapture(0)

while True: 

    ret,img=cap.read()

    cv2.imshow('Video', img)

    if(cv2.waitKey(10) &amp; 0xFF == ord('b')):
break
</code></pre>

<p>If you still can't get the camera input, replace VideoCapture(0) with VideoCapture(1). The issue could be because of a 3rd party camera driver installed on your machine.</p>

<p>If that doesn't work either, try VideoCapture("path/to/saved_video"). If you have entered the filePath correctly, and your openCV configuration has no issues, you should get saved video frames. This would imply that you need to check the camera drivers </p>

python opencv