Neeraj Sharma
Neeraj Sharma

Reputation: 194

VIDEOIO ERROR: V4L: can't find camera device

I am using ubuntu16.04 and trying to run opencv script. when i use:

video_capture = cv2.VideoCapture(-1)

it gives me error VIDEOIO ERROR: V4L: can't find camera device No video window opens But when i run

video_capture = cv2.VideoCapture('test.jpg')

It opens window shows the picture and close the window. Please tell me why it is not streaming video directly from camera.

Upvotes: 8

Views: 23931

Answers (2)

Callum
Callum

Reputation: 1

Late, but to get mine working i put in terminal:

-ltrh /dev/video*

To get a list of the video devices that are plugged into my computer. Then for each one I did:

sudo chmod 777 /dev/videox

Where x was one of the video files that were listed, giving everything access to them. Probaly not the most secure solution, but it got my code working.

Upvotes: -1

Ulrich Stern
Ulrich Stern

Reputation: 11301

The suggestion api55 gave in his comment

video_capture = cv2.VideoCapture(0)

is what I would try first.

Generally, you can list the available cameras with ls /dev/video* or v4l2-ctl --list-devices. Here sample output:

NZXT-U:rt-trx> v4l2-ctl --list-devices
Microsoft® LifeCam Cinema(TM): (usb-0000:00:14.0-1):
    /dev/video1

Microsoft® LifeCam Cinema(TM): (usb-0000:00:1a.0-1.3):
    /dev/video0

/dev/video0 corresponds to device id 0, etc.

PS: v4l2-ctl is quite useful for solving camera issues and can do much more than --list-devices. I installed it via packagev4l-utils on a 16.04 machine.

Upvotes: 4

Related Questions