https://blog.csdn.net/renzibei/article/details/82998933
参考了上面博主的例子,才明白。
Mac macOS 10.14 Mojave Xcode opencv 调用摄像头权限错误 This app has crashed because it attempted to access privacy-sensitive data without a usage description.
更新了macOS 10.14 Mojave之后,使用opencv调用摄像头会产生权限错误,报错This app has crashed because it attempted to access privacy-sensitive data without a usage description.
原因是macOS 10.14加入了对所有程序的隐私权限管理,如果要涉及隐私权限,要在可执行程序旁边加入Info.plist且在里面注册摄像头权限。
不过,我的是python
python 的解决办法是将,Info.plist文件复制后,放到了python的 文件夹下。我的电脑是路径是
/Users/mac/anaconda3/bin
我修改后的文件是
<?xml version="1.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>BuildMachineOSBuild</key>
<string>17A405001</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>python</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>PhotoBoothLibrary.icns</string>
<key>CFBundleTypeName</key>
<string>python</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>PBLb</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSTypeIsPackage</key>
<true/>
<key>NSDocumentClass</key>
<string>ArchiveDocument</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>python</string>
<key>CFBundleHelpBookFolder</key>
<string>PhotoBooth.help</string>
<key>CFBundleHelpBookName</key>
<string>com.apple.PhotoBooth.help</string>
<key>CFBundleIconFile</key>
<string>PhotoBoothIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.apple.PhotoBooth</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>10.0</string>
<key>CFBundleName</key>
<string>python</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>10.0</string>
<key>CFBundleSignature</key>
<string>PhBo</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1009</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>10L213p</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>10.14</string>
<key>DTSDKBuild</key>
<string>18C29</string>
<key>DTSDKName</key>
<string>macosx10.14internal</string>
<key>DTXcode</key>
<string>1000</string>
<key>DTXcodeBuild</key>
<string>10L213p</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.entertainment</string>
<key>LSMinimumSystemVersion</key>
<string>10.14</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2005–2018 Apple Inc. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>PBApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<string>YES</string>
<key>Privacy - Camera Usage Description</key>
<string>YES</string>
</dict>
</plist>
最后总算能把摄像头调出来了。