Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
857 views
in Technique[技术] by (71.8m points)

macos - Cannot access camera with opencv on Mac Mojave

I tried running some basic code from OpenCV that opens the webcam. I was able to run this code before I updated to Mac Mojave, but afterwards I get this error when I build and run.

`[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.`

I followed steps on other posts and created the Info.plist in the project(same directory as main.cpp) , however it says it has a problem parsing the contents on the Info.plist.

Info.plist:

   <?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>NSCameraUsageDescription</key>
    <string>uses camera to see vision targets</string>
</dict>

How can I fix this problem and have it read the Info.plist?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're missing the closing </plist> tag. Just add that as the last line of the file and it should work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...