Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS 10.14+ Media Capture Authorization #291

Open
nick-hunter opened this issue Feb 10, 2020 · 2 comments
Open

macOS 10.14+ Media Capture Authorization #291

nick-hunter opened this issue Feb 10, 2020 · 2 comments

Comments

@nick-hunter
Copy link

Actual Behaviour

I'm currently trying to package a (windowed) Kivy app with PyInstaller and have spent a decent amount of time trying to track down this bug. I believe the issue I'm running into is not with any of those libraries or with OpenCV. I'm pretty sure the issue is with how your wheels are generated.

When using opencv-python in the Terminal, the Terminal requests camera permissions and everything seems ok. However when running a packaged version of the same app it crashes.

For MacOS 10.14 and above OpenCV should request camera permissions. I've been through Apple's documentation and nothing there has helped.

Running a packaged app (using opencv-python version 4.1.2.30 from PyPi) in Xcode Instruments I'm getting this error:
OpenCV: Cannot use FaceTime HD Camera (Built-in) OpenCV: camera failed to properly initialize!

Expected Behaviour

When camera access is not authorized the following should be printed:
OpenCV: not authorized to capture video (status 0), requesting... OpenCV: camera failed to properly initialize!

If camera access has been rejected:
OpenCV: camera access has been denied. Either run 'tccutil reset Camera' command in same terminal to reset application authorization status, either modify 'System Preferences -> Security & Privacy -> Camera' settings for your application. OpenCV: camera failed to properly initialize!

The Issue

OpenCV uses compiler flags to determine whether or not media capture needs to be authorized (see here). When the opencv-python wheels are built, it seems like xcode9.4 is the only version used. I'm guessing xcode10.2 or newer would satisfy #if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 but I'm not totally sure.

Using your repo I built a wheel locally, and verified that I am getting the behavior I expect. However the version I built is having some issues with Qt. Would it be possible to have a 10.14+ wheel in addition to the 10.9 one to ensure this code is run on the correct machines? I understand this is a bit of an edge case but I think it would be an improvement if its not a lot of work for you.

I can provide more info or a more concrete example if needed.

Steps to reproduce

  • For sample code I've been using code from here
  • macOS 10.15.3
  • architecture x86_64
  • opencv-python version 4.1.2.30
@skvark
Copy link
Member

skvark commented Feb 10, 2020

It indeed seems that OpenCV does a build-time check for that flag. As you suggested, most likely the only solution is to provide separately built wheels for 10.14+. I'll have a look into this.

@letmaik
Copy link

letmaik commented May 16, 2021

Just stumbled upon this in opencv/opencv#20094, though in the opposite (expected?) way. Starting with 4.5.2 the wheels are built with 10.15 as target, whereas 4.5.1 used 10.13. So the checks are enabled now, but the weird thing is that in GitHub Actions during testing of the OBS virtual camera in my repo it worked fine with 4.5.1 but then broke with permission error in 4.5.2. EDIT: I opened an issue for that at actions/runner-images#3396. I think this issue here in opencv-python can probably be closed since everything is as expected since 4.5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants