2

I am having an issue getting OpenCV 2.4 to capture from an MJPEG stream from a Raspberry Pi, I have checked the stream URL in a browser and it seems to be working fine, however when I try to open it in OpenCV it seems to hang when I attempt to open it (I get neither the error or success messages on the terminal).

cv::VideoCapture vcap;
cv::Mat raw_image;

const string videoStreamAddress = "http://192.168.0.28:8080/?action=stream";

if(!vcap.open(videoStreamAddress))
{
    cout<<"Error opening video stream"<<endl;
    return -1;
}

cout<<"Stream opened"<<endl;

I am using MJPEG-Streamer to provide the stream. The same code works fine when capturing form a RTSP video stream.

EDIT: I tried changing the JPEG quality and resolution of the images captured by raspistill on the Pi and I now get the message saying the stream failed to open.

2 Answers2

2

Try adding a dummy param, that hints at the mjpeg content:

const string videoStreamAddress = "http://192.168.0.28:8080/?action=stream&amp;type=mjpg";
Hitesh Vaghani
  • 1,342
  • 12
  • 31
  • Didn't seem to help, could still view it in the browser like this but still no luck in OpenCV. –  Aug 06 '13 at 11:08
  • Got this to work, just needed to make it look like a file extension. –  Aug 11 '13 at 09:34
2

I found the answer, it is similar to what Hitesh suggested, I just needed to have a . before mjpg to make OpenCV think it was a URI to a file.

I found this in this answer to a similar question.

Community
  • 1
  • 1