Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without

报错原因:未获得摄像机权限

This app has crashed because it attempted to access privacy-sensitive data without a usage description.

解决办法很简单,照着下面?一步一步来

1.新建一个文件

Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without_第1张图片

2.文件类型为Property List,文件名为Info.plist

Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without_第2张图片

Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without_第3张图片

3.加入键Privacy - Camera Usage Description,值不能为空,随便填个值就行

 4.在该文件上右键 show in folder

5.将刚才新建的 Info.plist 移动到第 4 步show in folder打开的文件夹里

Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without_第4张图片 

6. 打开摄像头代码:

  Mat frame;
    //读取视频或摄像头
    VideoCapture capture(0);
    while (true)
    {
        capture >> frame;
        if(!frame.empty()){
            imshow("window",frame);
        }
        // imshow("读取视频", frame);
        if(waitKey(30) == 27)   //延时30
           {break;}
    }
    return 0;

7.效果展示:

Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without_第5张图片 

 Mac Opencv 调用摄像头报错This app has crashed because it attempted to access privacy-sensitive data without_第6张图片

你可能感兴趣的:(OpenCV)