mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2025-03-17 21:31:51 +01:00
Mac Webcam Serial No. Management
This commit is contained in:
commit
b17e52dea2
@ -7,7 +7,6 @@ from cv2_enumerate_cameras import enumerate_cameras # Add this import
|
||||
from PIL import Image, ImageOps
|
||||
import time
|
||||
import json
|
||||
from pygrabber.dshow_graph import FilterGraph
|
||||
import modules.globals
|
||||
import modules.metadata
|
||||
from modules.face_analyser import (
|
||||
@ -29,6 +28,9 @@ from modules.utilities import (
|
||||
from modules.video_capture import VideoCapturer
|
||||
import platform
|
||||
|
||||
if platform.system() == "Windows":
|
||||
from pygrabber.dshow_graph import FilterGraph
|
||||
|
||||
ROOT = None
|
||||
POPUP = None
|
||||
POPUP_LIVE = None
|
||||
@ -810,13 +812,29 @@ def get_available_cameras():
|
||||
camera_indices = []
|
||||
camera_names = []
|
||||
|
||||
# Test the first 10 indices
|
||||
for i in range(10):
|
||||
cap = cv2.VideoCapture(i)
|
||||
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(i)
|
||||
camera_names.append(f"Camera {i}")
|
||||
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()
|
||||
else:
|
||||
# Linux camera detection - test first 10 indices
|
||||
for i in range(10):
|
||||
cap = cv2.VideoCapture(i)
|
||||
if cap.isOpened():
|
||||
camera_indices.append(i)
|
||||
camera_names.append(f"Camera {i}")
|
||||
cap.release()
|
||||
|
||||
if not camera_names:
|
||||
return [], ["No cameras found"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user