Sublime Forum

Camera access

#1

Hello,

Having an issue with OpenCV on Sublime 4 right now (please help, because I hate using Pycharm), running MacOS 11.5.2.

Code:
import cv2

cap = cv2.VideoCapture(0)

while cap.isOpened():
** success, img = cap.read()**

** cv2.imshow(“Image”, img)**
** if cv2.waitKey(1) & 0xFF == ord(‘q’):**
** break**

cap.release()
cv2.destroyAllWindows()

Console:
“OpenCV: not authorized to capture video (status 0), requesting…”

When using Pycharm/Terminal and executing this code, MacOS will first ask me for camera permission for Pycharm/Terminal. This does not happen when I run this on Sublime.

Would appreciate any help, as I love to use Sublime for all my Python programming.

Regards,
Liam

0 Likes

#2

IIRC, it’s a question of granding ST or its plugin_host permission to camera interface.

0 Likes

#3

Right, but I can’t get ST to prompt me with the permission request?

0 Likes

#4

I don’t think an imported python library has any function to inform the host app about the functions included. So ST doesn’t / can’t know about the required permissions and so can’t create a prompt.

Not sure how MacOS handles such prompts, but other OSs require apps to include the set of required perminssions in statically linked manifest files. As ST itself doesn’t require that information, it doesn’t request it.

I personally wouldn’t feel good if a text editor would ask for camera or microphone permissions without an obvious reason.

0 Likes

#5

I see what you mean.

The only reason I suspected it was a “misconfiguration” in ST is because all other python IDEs I use ask for camera access when I run this OpenCV script.

0 Likes