Gstreamer error while trying to input video stream using opencv c++

asked 2017-11-20 08:21:46 -0600

r@opencv gravatar image

updated 2017-11-20 08:24:00 -0600

I am a beginner and I am using uv4l for streaming video from raspberry pi cm3 to my laptop running ubuntu. I have been getting the video stream in 'http://10.x.x.x:port/stream'. I want to input this video in my opencv c++ program using the following code.

#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main(int, char**)
    VideoCapture cap("http://10.x.x.x:port/stream"); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
       cout<<"Cap is not opened";
       return -1;

    Mat frame;
        cap >> frame; // get a new frame from camera
        imshow("video", frame);
        if(waitKey(30) >= 0) break;
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;

And I get the following error,

$ ./output
[http @ 0x1839c60] Stream ends prematurely at 406, should be 18446744073709551615
OpenCV Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
) in handlemessage, file /opt/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1866
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

/opt/opencv/modules/videoio/src/cap_gstreamer.cpp:1866: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
 in function handlemessage 
 Cap is not opened

I tried to manually install the gstreamer add-ons but still it doesn't work. Can someone please help me?

edit retag flag offensive close merge delete