Hey. I need to capture video from the camera. But cv2 on python2.7 returns None. Tell me.

 # -*- coding: utf-8 -*- import cv2 print cv2.__version__ # cap = cv2.VideoCapture(-1) cap = cv2.VideoCapture(0) while(True): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break 

At the moment I am trying to find a function that would return the list of cameras, see if openCV sees my camera or not. But while attempts are vain. Capturing video is not necessary with openCV, so any other ones are welcome.

    2 answers 2

    1. make sure the camera is visible as a V4L device
    2. connect numpy:

      import numpy as np

      Type ls /dev there will be the names of the connected devices you are interested in video0 , video1 , etc.