相关疑难解决方法(0)

Xcode for MacOS Mojave中的C ++项目需要NSCameraUsageDescription

我试图在Xcode中运行OpenCV项目,似乎有新的需要为C ++应用程序NSCameraUsageDescription提供info.plist。

2018-09-28 00:03:15.181948+0800 k_nearest_detector_v2[23505:710470] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
Program ended with exit code: 9
Run Code Online (Sandbox Code Playgroud)

我该如何为C ++项目创建.plist文件,因为以前从未需要过它。

c++ xcode macos-mojave

6
推荐指数
2
解决办法
1953
查看次数

OpenCV命令行应用程序无法在macOS Mojave下访问相机

我无法从命令行OpenCV程序访问iMac相机。(我正在CodeRunner而不是Xcode下编译和运行程序。)我已经读过Mojave NSCameraUsageDescription在Info.plist中需要的内容,并且我认为我已经将它正确地嵌入了二进制文件中。我在编译标志中添加了-sectcreate __TEXT __info_plist Info.plist我在这里学到的),当我运行时otool -X -s __TEXT __info_plist videotest | xxd -r(从同一博客文章)它输出:

-?<?xml ve.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSCameraUsageDescription</key>
    <string>Uses camera to see vision targets</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>This app requires to access your microphone in order to access the camera</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

(我添加了NSMicrophoneUsageDescription,以防它试图与相机一起打开麦克风。)

这是我运行程序时的输出:

OpenCV version 4.1.0-dev
[ INFO:0] global /Users/steve/Documents/GitHub/ssteve-opencv/modules/videoio/src/videoio_registry.cpp (185) VideoBackendRegistry VIDEOIO: Enabled backends(5, sorted by priority): FFMPEG(1000); GSTREAMER(990); AVFOUNDATION(980); CV_IMAGES(970); CV_MJPEG(960)
[ INFO:0] …
Run Code Online (Sandbox Code Playgroud)

macos opencv macos-mojave

6
推荐指数
2
解决办法
2923
查看次数

使用OpenCV(C ++)访问Xcode中的网络摄像头

我正在尝试打开网络摄像头,并使用OpenCV显示简短的截图。我目前正在使用C ++语言开发Xcode。

代码很简单:

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main(int argc, const char * argv[]) {

    // variable initialization
    Mat frame;
    VideoCapture cap;            // 0 is the webcam

    // try to open camera
    cap.open(0);
    if (!cap.isOpened()) return -1;  // check if there is no video or no way to display it

    // create a window and display the video capture
    namedWindow("Video Capture", CV_WINDOW_AUTOSIZE);
    for (int i=0; i<100; i++) {
        cap >> frame;
        imshow("Video Capture", frame); …
Run Code Online (Sandbox Code Playgroud)

c++ permissions webcam xcode opencv

5
推荐指数
1
解决办法
1708
查看次数

标签 统计

c++ ×2

macos-mojave ×2

opencv ×2

xcode ×2

macos ×1

permissions ×1

webcam ×1