数组新长度错误

Ali*_*Ali 1 c++ opencv

我正在尝试显示来自网络摄像机的视频,但当我声明摄像机 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;
    }
}
Run Code Online (Sandbox Code Playgroud)

Lam*_*amp 5

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