Created
September 16, 2012 15:05
-
-
Save candycode/3732772 to your computer and use it in GitHub Desktop.
Python - OpenCV: Grab frame from webcam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if opencv was installed through home-brew on mac | |
#sys.path.append('/usr/local/lib/python2.7/site-packages') | |
import cv2 | |
#open window "Window" | |
cam = cv2.VideoCapture(0) | |
while True: | |
img = cam.read()[1] | |
cv2.imshow("Window",img) | |
if cv2.waitKey(5) == 32: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traceback (most recent call last):
File "/Users/you/PycharmProjects/openCV/webcam.py", line 10, in
cv2.imshow("Window",img)
cv2.error: OpenCV(3.4.2) /opt/concourse/worker/volumes/live/9523d527-1b9e-48e0-7ed0-a36adde286f0/volume/opencv-suite_1535558719691/work/modules/highgui/src/window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'