OpenCV getWindowProperty()引发异常,如何解决?(语言-c++)

问题遇到的现象和发生背景

opencv 退出摄像头if (getWindowProperty("Video", WND_PROP_AUTOSIZE) != 1) break;
引发异常

img

问题相关代码,请勿粘贴截图
#include <iostream>
#include <string>
#include <sstream>
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) 
using namespace std;

// OpenCV includes
#include "opencv2/highgui.hpp"
#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc,char** argv)
{
    //视频采集对象;
    VideoCapture cap;

    //打开默认相机
    cap.open(0);

    if (!cap.isOpened())
        return -1;

    while (true)
    {
        Mat frame;
        cap >> frame;
        if (frame.empty())
            return 0;

        // 视频窗口
        namedWindow("Video", WINDOW_AUTOSIZE);

        // 显示
        imshow("Video", frame);

        // 空格暂停
        int keyS = waitKey(30);
        if (keyS == 32)
            waitKey(0);
        // 退出
        if (getWindowProperty("Video", WND_PROP_AUTOSIZE) != 1)
            break;
    }

    cap.release();
    destroyAllWindows();
    return 0;
}


    
运行结果及报错内容

img

设置项目使用多字节字符集