OpenCV程序中的数组新长度错误

时间:2019-02-02 16:39:35

标签: visual-c++ opencv3.0

我正在尝试从网络摄像头获取提要,并使用VideoWriter将其存储在文件夹中,但是在可视化条件下运行代码后,它弹出此错误,提示新数组长度错误。执行未传递(isWriterOpened)语句。该程序在Visual Studio->调试模式->窗口控制台应用程序(x64)中完成。

 //create matrix to store image
Mat image;

//initialize the camera
VideoCapture cap;
cap.open(0);

if (!cap.isOpened()) {
    std::cout << "Cant get the feed from camera.";
    return -1;
}

//filename string
std::string filename = "C:/Users/Guru/Videos/OpenCV_Feed/myVideo.avi";

//fourcc integer
int fcc = VideoWriter::fourcc('M', 'J', 'P', 'G');

//frames size
cv::Size frameSize((int)cap.get(CAP_PROP_FRAME_WIDTH),(int)cap.get(CAP_PROP_FRAME_HEIGHT));

//frame per second
int fps = 20;


VideoWriter writer("outcpp.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), 10, frameSize);

if (!writer.isOpened()) {
    std::cout << "Writer is not opened";
    getchar();

    return -1;

}

错误我 :错误:0] VIDEOIO(cvCreateVideoWriter_MSMF(文件名,FOURCC,帧,框架尺寸,isColor)):凸起C ++异常:坏阵列新长度

0 个答案:

没有答案