sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

[Mac] Sublime does not ask for permission to use Webcamera or Microphone.

Open lazer-dinosaur opened this issue 3 years ago • 8 comments
trafficstars

Description of the bug

I'm writing some software in python that requires access to both the webcam and the microphone. When running very simple test scripts that use the camera and/or microphone in VSC or from iterm2 it works fine - on the first occasion a prompt appears asking for permission, and then the code runs successfully. However Sublime Text does not trigger asking for permission, and it seems impossible to grant ST permission.

Steps to reproduce

install opencv and pyaudio

execute this code, normally a window should appear and show the webcam output (works fine in VSC or from terminal):

import cv2

vid = cv2.VideoCapture(0)
while 1:
    ret, frame = vid.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
  
vid.release()
cv2.destroyAllWindows()

Try this code for the microphone, (the code runs but the saved .wav is empty, ie. microphone is not used):

import pyaudio
import wave

CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
                channels=CHANNELS,
                rate=RATE,
                input=True,
                frames_per_buffer=CHUNK)

print("* recording")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    frames.append(data)

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()

Expected behavior

A window should pop up asking for permission for Sublime to use the Camera and/or microphone. After granting permission the code should then run, and a window showing the camera image should appear (or audio is recorded).

Actual behavior

Nothing happens, the video code exits silently with no error. The audio-code runs, but as it cannot access the microphone, nothing is recorded.

Sublime Text build number

4129

Operating system & version

MacOS 12.4

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

lazer-dinosaur avatar Oct 09 '22 22:10 lazer-dinosaur

VSCode and others have had similar problems due to Apple's permission changes: https://github.com/microsoft/vscode/issues/95062

BenjaminSchaaf avatar Nov 14 '22 04:11 BenjaminSchaaf

Should be fixed in build 4144.

BenjaminSchaaf avatar Dec 14 '22 06:12 BenjaminSchaaf

Has this been solved? I found it was solved in previous versions, but when It desert seems like to work.

ST version: 4169 MacOS: 14.2.1

Use opencv-python: ` import cv2 as cv cap = cv.VideoCapture(0)

while True:

ret, frame = cap.read()
cv.imshow(window_name, frame)

`

and that gives: OpenCV: not authorized to capture video (status 0), requesting... OpenCV: camera failed to properly initialize!

With no window pops up ask for permissions.

I have tried re-install and tccutil reset Camera

Thanks

moooooo16 avatar Jan 16 '24 05:01 moooooo16

Does it work outside of Sublime Text @moooooo16 ?

BenjaminSchaaf avatar Jan 16 '24 05:01 BenjaminSchaaf

Does it work outside of Sublime Text @moooooo16 ?

Yes. It worked on cml and vscode.

moooooo16 avatar Jan 16 '24 06:01 moooooo16

Can confirm this doesn't seem fixed.

BenjaminSchaaf avatar Feb 09 '24 03:02 BenjaminSchaaf

This should be fixed in build 4170.

BenjaminSchaaf avatar Feb 20 '24 05:02 BenjaminSchaaf

Unfortunately, this still does not work for me. Im on build 4173.

lazer-dinosaur avatar Mar 04 '24 20:03 lazer-dinosaur