首页 > 解决方案 > 错误的数组新长度

问题描述

我正在尝试显示来自网络摄像机的视频,但是当我声明摄像机 ulr 时,程序显示错误的数组新长度。

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

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

    // This works on a D-Link CDS-932Lrtsp://<Admin:mmcc2019>@10.5.1.101/

    const std::string videoSt = "http://192.168.226.101:8080/video?x.mjpeg";
    std::cout <<"lenght og the cmera ulr is" <<videoSt.length() << std::endl;

    //open the video stream and make sure it's opened
    if (!vcap.open(videoSt)) {
        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;
    }
}

标签: c++opencv

解决方案


我刚遇到同样的问题,因为我是opencv_world412.lib在调试模式下使用的;切换到发布模式,或使用opencv_world412d.lib将解决此问题。


推荐阅读