MJPEG stream fails to open in OpenCV 2.4

女生的网名这么多〃 提交于 2019-12-06 12:00:35

问题


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.


回答1:


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";



回答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.



来源:https://stackoverflow.com/questions/18077652/mjpeg-stream-fails-to-open-in-opencv-2-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!