How to authorize the camera on MacBook?
I am learning a bit of OpenCV and have a simple program that grabs images off the Macbook camera and does simple motion detection. I can run it in iTerm2 fine and it works but it fails as "not authorized" when run under Wing debug.
Is there a way to authorize the Wing debug to acess the camera? [OS=Big Sur (11.3 Beta (20E5196f))]
Here is what I see in the Debug I/O window:
OpenCV: not authorized to capture video (status 0), requesting...
/Applications/WingPro.app/Contents/Resources/bootstrap/launch-env.sh: line 10: 44258 Abort trap: 6 ${WING_ACTIVATE_PYTHON} "$@"
Comments
If you open macOS System Preferences and go to Security & Privacy and then under the Privacy tab select Camera, is anything listed as having requested access? Usually a dialog should pop up but if you denied access then I think it lists the app here. Note that it may list Python and not OpenCV but I'm not sure.
No, that's the first place I looked and there is nothing requested. Neither python nor Wing is listed, checked or unchecked. However, iTerm2 IS listed and checked because when I first ran the app it did request access to the camera with a pop-up dialog.
When I
import cv2
andcap=cv2.VideoCapture(0)
in the Python Shell window I also get the failure:Python 3.9.2 (default, Feb 24 2021, 13:26:09) [Clang 12.0.0 (clang-1200.0.32.29)] Type "help", "copyright", "credits" or "license" for more information. import cv2 cap = cv2.VideoCapture(0) OpenCV: not authorized to capture video (status 0), requesting... aborted (disconnected)
That fails and I get a python crash notifiecation:
``` Process: Python [22125] Path: /usr/local/Cellar/python@3.9/3.9.2_1/... Identifier: Python Version: 3.9.2 (3.9.2) Code Type: X86-64 (Native) Parent Process: WingPro [21954] Responsible ... (more)
macOS uses the .app that launches your script as the application that needs permission, so it would be iTerm2 when laughing from it and Wing when debugging (or executing) from Wing. A dialog asking for permission should be displayed the first time the .app tries to use the camera, but apparently this doesn't always work. A way to reset the permissions is explained at https://apple.stackexchange.com/quest...
Well, that didn't change anything. I used
tccutil
to resetCamera
forcom.wingware.wingpro
and it reported success. But I still get the python failure and no prompt for authorizing the Camera. I did restart Wing after doing the reset ...Does it work if you use an external console? The OS may determine that the requesting app is the terminal in this case.