Deep-Live-Cam icon indicating copy to clipboard operation
Deep-Live-Cam copied to clipboard

Webcams not detected on Apple Silicon even though Privacy permits

Open phillips321 opened this issue 9 months ago • 7 comments

└─(12:27:%)── python -V ──(Fri,Mar21)─┘ Python 3.10.2

`└─(12:26:%)── python run.py --execution-provider coreml ──(Fri,Mar21)─┘ Frame processor face_enhancer not found DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning. OpenCV: out device of bound (0-0): 1 OpenCV: camera failed to properly initialize! [03/21 12:26:30.371477][info][313282][Context.cpp:69] Context created with config: default config! [03/21 12:26:30.371512][info][313282][Context.cpp:74] Context work_dir=/Users/phillips321/Deep-Live-Cam [03/21 12:26:30.371514][info][313282][Context.cpp:77] - SDK version: 1.9.4 [03/21 12:26:30.371515][info][313282][Context.cpp:78] - SDK stage version: main [03/21 12:26:30.371518][info][313282][Context.cpp:82] get config EnumerateNetDevice:false [03/21 12:26:30.371520][info][313282][MacPal.cpp:36] createObPal: create MacPal! [03/21 12:26:30.387380][info][313282][MacPal.cpp:104] Create PollingDeviceWatcher! [03/21 12:26:30.387413][info][313282][DeviceManager.cpp:15] Current found device(s): (0) [03/21 12:26:30.387420][info][313282][Pipeline.cpp:15] Try to create pipeline with default device. [03/21 12:26:30.387426][warning][313282][ObException.cpp:5] No device found, fail to create pipeline! [03/21 12:26:30.400578][info][313282][Context.cpp:90] Context destroyed [ WARN:[email protected]] global cap.cpp:323 open VIDEOIO(OBSENSOR): raised unknown C++ exception!

OpenCV: out device of bound (0-0): 2 OpenCV: camera failed to properly initialize! [03/21 12:26:30.418192][info][313282][Context.cpp:69] Context created with config: default config! [03/21 12:26:30.418239][info][313282][Context.cpp:74] Context work_dir=/Users/phillips321/Deep-Live-Cam [03/21 12:26:30.418244][info][313282][Context.cpp:77] - SDK version: 1.9.4 [03/21 12:26:30.418247][info][313282][Context.cpp:78] - SDK stage version: main [03/21 12:26:30.418253][info][313282][Context.cpp:82] get config EnumerateNetDevice:false [03/21 12:26:30.418256][info][313282][MacPal.cpp:36] createObPal: create MacPal! [03/21 12:26:30.483252][info][313282][MacPal.cpp:104] Create PollingDeviceWatcher! [03/21 12:26:30.483269][info][313282][DeviceManager.cpp:15] Current found device(s): (0) [03/21 12:26:30.483273][info][313282][Pipeline.cpp:15] Try to create pipeline with default device. [03/21 12:26:30.483276][warning][313282][ObException.cpp:5] No device found, fail to create pipeline! [03/21 12:26:30.503519][info][313282][Context.cpp:90] Context destroyed [ WARN:[email protected]] global cap.cpp:323 open VIDEOIO(OBSENSOR): raised unknown C++ exception!

OpenCV: out device of bound (0-0): 3 OpenCV: camera failed to properly initialize! [03/21 12:26:30.532560][info][313282][Context.cpp:69] Context created with config: default config! [03/21 12:26:30.532577][info][313282][Context.cpp:74] Context work_dir=/Users/phillips321/Deep-Live-Cam [03/21 12:26:30.532578][info][313282][Context.cpp:77] - SDK version: 1.9.4 [03/21 12:26:30.532580][info][313282][Context.cpp:78] - SDK stage version: main [03/21 12:26:30.532582][info][313282][Context.cpp:82] get config EnumerateNetDevice:false [03/21 12:26:30.532584][info][313282][MacPal.cpp:36] createObPal: create MacPal! [03/21 12:26:30.638747][info][313282][MacPal.cpp:104] Create PollingDeviceWatcher! [03/21 12:26:30.638761][info][313282][DeviceManager.cpp:15] Current found device(s): (0) [03/21 12:26:30.638765][info][313282][Pipeline.cpp:15] Try to create pipeline with default device. [03/21 12:26:30.638768][warning][313282][ObException.cpp:5] No device found, fail to create pipeline! [03/21 12:26:30.641985][info][313282][Context.cpp:90] Context destroyed [ WARN:[email protected]] global cap.cpp:323 open VIDEOIO(OBSENSOR): raised unknown C++ exception!

OpenCV: out device of bound (0-0): 4 OpenCV: camera failed to properly initialize! [03/21 12:26:30.664923][info][313282][Context.cpp:69] Context created with config: default config! [03/21 12:26:30.664978][info][313282][Context.cpp:74] Context work_dir=/Users/phillips321/Deep-Live-Cam [03/21 12:26:30.664981][info][313282][Context.cpp:77] - SDK version: 1.9.4 [03/21 12:26:30.664983][info][313282][Context.cpp:78] - SDK stage version: main [03/21 12:26:30.664987][info][313282][Context.cpp:82] get config EnumerateNetDevice:false [03/21 12:26:30.664990][info][313282][MacPal.cpp:36] createObPal: create MacPal! [03/21 12:26:30.667072][info][313282][MacPal.cpp:104] Create PollingDeviceWatcher! [03/21 12:26:30.667086][info][313282][DeviceManager.cpp:15] Current found device(s): (0) [03/21 12:26:30.667091][info][313282][Pipeline.cpp:15] Try to create pipeline with default device. [03/21 12:26:30.667093][warning][313282][ObException.cpp:5] No device found, fail to create pipeline! [03/21 12:26:30.667704][info][313282][Context.cpp:90] Context destroyed [ WARN:[email protected]] global cap.cpp:323 open VIDEOIO(OBSENSOR): raised unknown C++ exception!

`

phillips321 avatar Mar 21 '25 12:03 phillips321

hey probably you are not setting right! I'm using M3 and so far so good! however the documentation it was not so intuitive! I create a PR that I don't know if will be approved, but maybe you can check that out and help y https://github.com/hacksider/Deep-Live-Cam/pull/990.

info: locally I'm using Python 3.10.16 and not 3.10.2

wpoPR avatar Mar 21 '25 17:03 wpoPR

Hi @wpoPR , I just followed up with your updates to the Readme but still having the same issue.

`└─(21:35:%)── python3.10 run.py --execution-provider coreml ──(Fri,Mar21)─┘ Frame processor face_enhancer not found DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning. OpenCV: out device of bound (0-0): 1 OpenCV: camera failed to properly initialize! [03/21 21:37:14.602011][info][5278598][Context.cpp:69] Context created with config: default config! [03/21 21:37:14.602031][info][5278598][Context.cpp:74] Context work_dir=/Users/phillips321/Deep-Live-Cam [03/21 21:37:14.602033][info][5278598][Context.cpp:77] - SDK version: 1.9.4 [03/21 21:37:14.602034][info][5278598][Context.cpp:78] - SDK stage version: main [03/21 21:37:14.602037][info][5278598][Context.cpp:82] get config EnumerateNetDevice:false [03/21 21:37:14.602039][info][5278598][MacPal.cpp:36] createObPal: create MacPal! [03/21 21:37:14.602296][info][5278598][MacPal.cpp:104] Create PollingDeviceWatcher! [03/21 21:37:14.602305][info][5278598][DeviceManager.cpp:15] Current found device(s): (0) [03/21 21:37:14.602308][info][5278598][Pipeline.cpp:15] Try to create pipeline with default device. [03/21 21:37:14.602310][warning][5278598][ObException.cpp:5] No device found, fail to create pipeline! [03/21 21:37:14.602550][info][5278598][Context.cpp:90] Context destroyed [ WARN:[email protected]] global cap.cpp:323 open VIDEOIO(OBSENSOR): raised unknown C++ exception!

OpenCV: out device of bound (0-0): 2 OpenCV: camera failed to properly initialize! [03/21 21:37:14.607320][info][5278598][Context.cpp:69] Context created with config: default config! [03/21 21:37:14.607334][info][5278598][Context.cpp:74] Context work_dir=/Users/phillips321/Deep-Live-Cam [03/21 21:37:14.607336][info][5278598][Context.cpp:77] - SDK version: 1.9.4 [03/21 21:37:14.607337][info][5278598][Context.cpp:78] - SDK stage version: main [03/21 21:37:14.607340][info][5278598][Context.cpp:82] get config EnumerateNetDevice:false [03/21 21:37:14.607341][info][5278598][MacPal.cpp:36] createObPal: create MacPal! [03/21 21:37:14.607496][info][5278598][MacPal.cpp:104] Create PollingDeviceWatcher! [03/21 21:37:14.607502][info][5278598][DeviceManager.cpp:15] Current found device(s): (0) [03/21 21:37:14.607504][info][5278598][Pipeline.cpp:15] Try to create pipeline with default device. [03/21 21:37:14.607505][warning][5278598][ObException.cpp:5] No device found, fail to create pipeline! [03/21 21:37:14.607637][info][5278598][Context.cpp:90] Context destroyed [ WARN:[email protected]] global cap.cpp:323 open VIDEOIO(OBSENSOR): raised unknown C++ exception!

2025-03-21 21:37:31.543 python3.10[70699:5278598] +[IMKClient subclass]: chose IMKClient_Modern 2025-03-21 21:37:31.543 python3.10[70699:5278598] +[IMKInputSession subclass]: chose IMKInputSession_Modern (venv) ┌─(phillips321@MacBookPro)────────────────────────────────────────────────────────────(~/Deep-Live-Cam)─┐ └─(21:38:%)── which python ──(Fri,Mar21)─┘ /Users/phillips321/Deep-Live-Cam/venv/bin/python (venv) ┌─(phillips321@MacBookPro)────────────────────────────────────────────────────────────(~/Deep-Live-Cam)─┐ └─(21:39:%)── python -V ──(Fri,Mar21)─┘ Python 3.10.16 (venv) ┌─(phillips321@MacBookPro)────────────────────────────────────────────────────────────(~/Deep-Live-Cam)─┐ └─(21:39:%)── which [email protected] ──(Fri,Mar21)─┘ [email protected] not found (venv) ┌─(phillips321@MacBookPro)────────────────────────────────────────────────────────────(~/Deep-Live-Cam)─┐ └─(1:21:39:%)── which python3.10 ──(Fri,Mar21)─┘ /Users/phillips321/Deep-Live-Cam/venv/bin/python3.10 (venv) ┌─(phillips321@MacBookPro)────────────────────────────────────────────────────────────(~/Deep-Live-Cam)─┐ └─(21:39:%)── `

Im having this same problem on two MacOS machines (M1 and M1Pro).

phillips321 avatar Mar 21 '25 21:03 phillips321

However, I can tell python to open and display my webcam using this quick test script: `└─(130:21:42:%)── cat test.py ──(Fri,Mar21)─┘ import cv2

frameWidth = 640 frameHeight = 480 cap = cv2.VideoCapture(0) cap.set(3, frameWidth) cap.set(4, frameHeight) cap.set(10,150)

while cap.isOpened(): success, img = cap.read() if success: cv2.imshow("Result", img) if cv2.waitKey(1) & 0xFF == ord('q'): break`

Running that works fine with device id 0

phillips321 avatar Mar 21 '25 21:03 phillips321

I should also note that the Deep Live Cam window opens but is completely blank (no buttons or regions within window)

phillips321 avatar Mar 21 '25 21:03 phillips321

Reinstall OpenCV with Video Support

Ensure OpenCV was installed with video support:

pip uninstall opencv-python opencv-python-headless
pip install opencv-python

The headless version does not include video support.

Full output what, GPT said to me... Potential Fixes

  1. Check Camera Availability Run the following command in a terminal to list connected cameras: ls /dev/video*

If no devices are found, the system isn’t recognizing a camera.

  1. Check Camera Permissions

On macOS, OpenCV might not have permission to access your camera. Go to: • System Preferences → Security & Privacy → Camera • Ensure Python (or your application) has permission to access the camera.

If needed, reset permissions using:

tccutil reset Camera

  1. Manually Specify Camera ID

If OpenCV is failing to detect the correct camera, manually specify a different device ID in run.py:

import cv2

cap = cv2.VideoCapture(0) # Change 0 to 1 or 2 if needed if not cap.isOpened(): print("Error: Camera could not be opened.")

Try different numbers (0, 1, 2) until one works.

  1. Reinstall OpenCV with Video Support

Ensure OpenCV was installed with video support:

pip uninstall opencv-python opencv-python-headless
pip install opencv-python

The headless version does not include video support.

Final Steps

If none of these fixes work, try running your script with debugging enabled: python -m trace --trace run.py This will print out every executed line to help pinpoint the exact failure.

scottnzuk avatar Mar 22 '25 05:03 scottnzuk

@scottnzuk ui.py already has logic to manually pick all possible cameras in MacOS

# On macOS, additional cameras typically use indices 1 and 2 for i in [1, 2]: cap = cv2.VideoCapture(i) if cap.isOpened(): camera_indices.append(i) camera_names.append(f"Camera {i}") cap.release()

Not sure what else needs to be done but it's throwing the same error:

Frame processor face_enhancer not found OpenCV: out device of bound (0-0): 1 OpenCV: camera failed to properly initialize! OpenCV: out device of bound (0-0): 2

I'm on MacBook Pro - M3.

felipevegaaraujo avatar Mar 26 '25 06:03 felipevegaaraujo

@scottnzuk ui.py already has logic to manually pick all possible cameras in MacOS

# On macOS, additional cameras typically use indices 1 and 2 for i in [1, 2]: cap = cv2.VideoCapture(i) if cap.isOpened(): camera_indices.append(i) camera_names.append(f"Camera {i}") cap.release()

Not sure what else needs to be done but it's throwing the same error:

Frame processor face_enhancer not found OpenCV: out device of bound (0-0): 1 OpenCV: camera failed to properly initialize! OpenCV: out device of bound (0-0): 2

I'm on MacBook Pro - M3.

I had a very similar issue and the steps above fixed my fault, but I also this year default my Terminal (.zshrc) to setup Virtual Environment.

`# Open their .zshrc file nano ~/.zshrc

Add this at the end of the file (customize the path if necessary):

if [[ "$PWD" == "path-to-your-project" ]]; then source ~/path-to-your-project/.venv/bin/activate fi

Apply changes

source ~/.zshrc`

just helps keep things seperate from host, there is probably better ways but yea.

scottnzuk avatar Mar 26 '25 06:03 scottnzuk