import cv2
cam=cv2.VideoCapture(0)
while True:
_,frame=cam.read()
if frame is not None:
cv2.imshow("frame",frame)
cam.release()
This is my code running for camera capture. I have runned an ubuntu image in which i have installed opencv using apt install python3-opencv.
It gives an error:
global ../modules/videoio/src/cap_v4l.cpp (887) open VIDEOIO(V4L2:/dev/video0): can't open camera by index