#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    // 打开视频流
    VideoCapture cap("your_video_stream_url");

    // 检查视频流是否成功打开
    if (!cap.isOpened())
    {
        cout << "Error opening video stream or file" << endl;
        return -1;
    }

    // 循环读取视频流中的每一帧
    while (true)
    {
        Mat frame;

        // 读取一帧
        if (!cap.read(frame))
        {
            cout << "End of video stream" << endl;
            break;
        }

        // 显示当前帧
        imshow("Frame", frame);

        // 等待按键,按下 q 键退出循环
        if (waitKey(25) == 'q')
            break;
    }

    // 释放视频流并关闭窗口
    cap.release();
    destroyAllWindows();

    return 0;
}
请注意,您需要将 "your_video_stream_url" 替换为您要解码的实际视频流 URL。此外,您还需要安装 OpenCV 库并将其包含在您的项目中。

04-06 09:52