Ask Your Question

Cannot identify device '/dev/video0' - video reading OpenCV 3.1

asked 2016-04-25 08:17:11 -0600

Florence gravatar image

updated 2016-04-25 08:22:58 -0600


I'm trying read the video from a camera connected to my computer using OpenCV.

I tried this first test, and I got the following error message :

"GStreamer Plugin: Embedded video playback halted; module v4l2src0 reported: Cannot identify device '/dev/video0'. OpenCV Error: Unspecified error (GStreamer: unable to start pipeline ) in cvCaptureFromCAM_GStreamer, file 'file_location'/opencv-3.1.0/modules/videoio/src/cap_gstreamer.cpp, line 818 terminate called after throwing an instance of 'cv::Exception' what(): 'file_location'/opencv-3.1.0/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline in function cvCaptureFromCAM_GStreamer


Here is the code :

   #include "opencv2/opencv.hpp"
#include <stdio.h>

using namespace cv;

int main(int, char**)
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        std::cout << " Cannot open video" << std::endl;
        return -1;

    Mat edges;
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, COLOR_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
        Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if(waitKey(30) >= 0) break;
    // the camera will be deinitialized automatically in VideoCapture destructorcd ,,
    return 0;

If someone has an idea that would be very helpful !

Thank you very much in advance.


edit retag flag offensive close merge delete


Make sure, your video0 device exists. Use this command: ls -ltr /dev/video* to list the connected video devices

takahashi gravatar imagetakahashi ( 2016-04-25 09:28:22 -0600 )edit

Oh you're right, it actually doesn't exist. But I'm sure the camera is connected and recognized by the computer. I've also tried to replace VideoCapture cap(0) by VideoCapture cap(CV_CAP_XIAPI) which actually works better as it doesn't crach, but the video cannot be opened...

Florence gravatar imageFlorence ( 2016-04-26 01:59:15 -0600 )edit

if you list the connected video devices, is there any device listed? (e.g. video1 or so). Also, are you using a virtual machine by any chance?

takahashi gravatar imagetakahashi ( 2016-04-26 02:31:15 -0600 )edit

No there are no new devices when I plug the camera... But when I type dmesg then I see that the usb device is connected and recognized. And no, no virtual machine.

Florence gravatar imageFlorence ( 2016-04-26 02:47:06 -0600 )edit

1 answer

Sort by » oldest newest most voted

answered 2016-05-23 08:25:13 -0600

Florence gravatar image

Problem solved : It was a special camera, and it needed a particular software (ximea in my case) to work. It didn´t appear as a video device.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-04-25 08:17:11 -0600

Seen: 17,160 times

Last updated: May 23 '16