Skip to content

VideoCapture crashes on MacOS Mojave due to privacy protection #14258

@jeroen

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?

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