I am trying to open a video stream with the OpenCV VideoCapture class in OpenCV version 3.1, Windows x64. On my raspberry pi I have mjpg_streamer running, and I can see the output through http://192.168.1.245:8080/?action=stream , however when I try to open the video stream in OpenCV, it fails to open the stream.
This is the code I'm using to debug that apparently worked for someone else who was having connection issues also.
#include <opencv2\core.hpp>
#include <opencv2\videoio.hpp>
#include <string>
#include <iostream>
using namespace std;
int main()
{
cv::VideoCapture vcap;
cv::Mat raw_image;
const string videoStreamAddress = "http://192.168.1.245:8080/?action=stream";
if (!vcap.open(videoStreamAddress))
{
cout << "Error opening video stream" << endl;
system("pause");
return -1;
}
cout << "Stream opened" << endl;
system("pause");
return 0;
}
Online, people are saying that OpenCV must have the video extension in the link. I have tried to use the extension trick that other people are using, like http://192.168.1.245:8080/?action=stream?dummy=param.mjpg, http://192.168.1.245:8080/?action=stream&type=.mjpg, &channel=0&.mjpg, and &type=.mjpeg but that is not working. Also, I have enabled ffmpeg in cmake and built with it. It seems like at this point it works for other people, and there doesn't seem to be anything else on the topic. What is the solution to this?