Skip to content

VideoCapture crashes on MacOS Mojave due to privacy protection #14258

Closed

Description

@jeroen
System information (version)
  • OpenCV => 3.4.5 and 4.0.1
  • Operating System / Platform => MacOS 10.14 (Mojave)
  • Compiler => xcode
Detailed description

MacOS Mojave has tightened privacy protection, and now applications need to prompt the user before they can access the camera. Once the user has approved to do so, the application will be permanently added to the list in MacOS privacy settings.

However when VideoCapture cap(0); in C++, the application immediately crashes instead of prompting the user for camera access. This only happens for opencv; if I access the camera via ffmpeg, then it does not crash and get prompted.

Same issue in python: #12763

One theory is that opencv might be trying to do this from within a TBB thread, and therefore the access prompt does not work.

Steps to reproduce

In MacOS mojave, run C++ application with:

VideoCapture cap(0);
Possible solution

Perhaps there should be a way to safely test if VideoCapture(0) is available from the main thread?

Activity

  1. zipzit commented on May 8, 2019

    @zipzit

    Questions: why would there even be a prompt for camera access from the native MacOS Terminal App? Isn't that triggered by Info.plist which must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data?

    Or is the developer required to create a Info.plist file in support of a build package?

    I'm not totally sure how this new authentication stuff works on the Mac.

    ref: /Applications/Utilities/Terminal.app/Contents/info.plist

  2. klich3 commented on Jan 20, 2023

    @klich3

    Solution

    I found only one existing way:

    1. First you need allow Terminal to access to your Camera (*1)
    2. Run Blender from Terminal shell /Applications/Blender.app/Contents/MacOS/Blender

    Check your permisses in System Properties > Privacy and policy > Camera
    enter image description here

    *1 : create simply code sample code name it as sample.py and run it in your terminal python ./sample.py -> allow Camera access.

    and thats it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions