mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2026-06-06 12:33:54 +02:00
Merge pull request #1671 from laurigates/pr/fix-macos-camera-enum
fix(macos): replace cv2_enumerate_cameras with safe bounded loop
This commit is contained in:
+7
-16
@@ -3,7 +3,6 @@ import webbrowser
|
||||
import customtkinter as ctk
|
||||
from typing import Callable, Tuple
|
||||
import cv2
|
||||
from cv2_enumerate_cameras import enumerate_cameras # Add this import
|
||||
from modules.gpu_processing import gpu_cvt_color, gpu_resize, gpu_flip
|
||||
from PIL import Image, ImageOps
|
||||
import time
|
||||
@@ -971,21 +970,13 @@ def get_available_cameras():
|
||||
camera_indices = []
|
||||
camera_names = []
|
||||
|
||||
if platform.system() == "Darwin": # macOS specific handling
|
||||
# Try to open the default FaceTime camera first
|
||||
cap = cv2.VideoCapture(0)
|
||||
if cap.isOpened():
|
||||
camera_indices.append(0)
|
||||
camera_names.append("FaceTime Camera")
|
||||
cap.release()
|
||||
|
||||
# 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()
|
||||
if platform.system() == "Darwin":
|
||||
# Do NOT probe cameras with cv2.VideoCapture on macOS — probing
|
||||
# invalid indices triggers the OBSENSOR backend and causes SIGSEGV.
|
||||
# Default to indices 0 and 1 (covers FaceTime + one USB camera).
|
||||
# The user can select the correct index from the UI dropdown.
|
||||
camera_indices = [0, 1]
|
||||
camera_names = ["Camera 0", "Camera 1"]
|
||||
else:
|
||||
# Linux camera detection - test first 10 indices
|
||||
for i in range(10):
|
||||
|
||||
Reference in New Issue
Block a user