简体   繁体   English

MJPEG流无法在OpenCV 2.4中打开

[英]MJPEG stream fails to open in OpenCV 2.4

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). 我在从Raspberry Pi的MJPEG流中捕获OpenCV 2.4时遇到问题,我已经在浏览器中检查了流URL,它似乎工作正常,但是当我尝试在OpenCV中打开它时,它似乎挂起了我尝试将其打开(终端上未显示错误或成功消息)。

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. 我正在使用MJPEG-Streamer提供流。 The same code works fine when capturing form a RTSP video stream. 从RTSP视频流捕获时,相同的代码可以正常工作。

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. 编辑:我试图更改raspistill在Pi上捕获的图像的JPEG质量和分辨率,现在我收到一条消息,指出流无法打开。

尝试添加一个虚拟参数,以提示mjpeg内容:

const string videoStreamAddress = "http://192.168.0.28:8080/?action=stream&amp;type=mjpg";

I found the answer, it is similar to what Hitesh suggested, I just needed to have a . 我找到了答案,它类似于Hitesh的建议,我只需要有一个. before mjpg to make OpenCV think it was a URI to a file. mjpg之前使OpenCV认为这是文件的URI。

I found this in this answer to a similar question. 我在类似问题的答案中找到了这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM