MJPEG 网络流到 OpenCV 2

发布于 2025-01-03 21:23:12 字数 1006 浏览 1 评论 0原文

谁能向我解释为什么下面的代码不起作用?

#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>

int main(int, char**) {
    cv::VideoCapture vcap;
    cv::Mat image;

    const std::string videoStreamAddress = "http://hg55.no-ip.org/mjpg/video.mjpg";
    //Yes, this stream does work! Try to paste it into your browser...

    //open the video stream and make sure it's opened
    if(!vcap.open(videoStreamAddress)) {
        std::cout << "Error opening video stream or file" << std::endl;
        return -1;
    }

    for(;;) {
        if(!vcap.read(image)) {
            std::cout << "No frame" << std::endl;
            cv::waitKey();
        }
        cv::imshow("Output Window", image);
        if(cv::waitKey(1) >= 0) break;
    }   
}

此代码确实无法打开流...

该代码基于此线程中的一些代码:OpenCV with Network相机

这里的 OpenCV 1 代码对我来说没有任何问题。

预先非常感谢

Can anyone explain to me why this code below does not work?

#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>

int main(int, char**) {
    cv::VideoCapture vcap;
    cv::Mat image;

    const std::string videoStreamAddress = "http://hg55.no-ip.org/mjpg/video.mjpg";
    //Yes, this stream does work! Try to paste it into your browser...

    //open the video stream and make sure it's opened
    if(!vcap.open(videoStreamAddress)) {
        std::cout << "Error opening video stream or file" << std::endl;
        return -1;
    }

    for(;;) {
        if(!vcap.read(image)) {
            std::cout << "No frame" << std::endl;
            cv::waitKey();
        }
        cv::imshow("Output Window", image);
        if(cv::waitKey(1) >= 0) break;
    }   
}

This code does cannot open the stream...

The code is based on some code in this thread: OpenCV with Network Cameras

The OpenCV 1 code here works without any problem for me.

Thank you very much in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒与心事 2025-01-10 21:23:12

我尝试使用 Visual Studio 2010 和 OpenCV 2.2 创建一个新项目,而不是 OpenCV 2.3.1。

这解决了我所有的问题!

I tried to create a new project with Visual Studio 2010 and OpenCV 2.2, instead of OpenCV 2.3.1.

This solved all my problems!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文