1 | initial version |
aww, you're looking at outdated c-api code from pre 2010 (which is not using numpy arrays to store images or generic matrices)
take a close look at the python tutorials and, ofc, the sample codes
but here's the nutshell:
import cv2
import numpy as np
cam = cv2.VideoCapture(0)
while cam.isOpened():
ok,img = cam.read()
if (not ok):
continue # maybe you got an oldish webcam, that needs some 'warmup'
# if you had a video **file** instead, you want to break here instead (reached last frame)
#
# your img processing would go here ;)
#
cv2.imshow("lalala", img)
k = cv2.waitKey(10) & 0xff
if k==27:
break
2 | No.2 Revision |
aww, you're looking at outdated c-api code from pre 2010 (which is not using numpy arrays to store images or generic matrices)
take a close look at the python tutorials and, ofc, the sample codes
but here's the nutshell:
import cv2
import numpy as np
cam = cv2.VideoCapture(0)
while cam.isOpened():
ok,img = cam.read()
if (not ok):
continue # maybe you got an oldish webcam, that needs some 'warmup'
# if you had a video **file** instead, you want to break here instead (reached last frame)
#
# your img processing would go here ;)
#
cv2.imshow("lalala", img)
k = cv2.waitKey(10) & 0xff
if k==27:
break