我试图显示来自网络摄像机的视频,但是当我声明摄像机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;
}
}
最佳答案
我只是遇到了同样的问题,这是因为我在 Debug模式下使用了opencv_world412.lib
。切换到 Release模式或使用opencv_world412d.lib
将解决此问题。
关于c++ - 数组新长度错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57247416/