Skip to content

Commit

Permalink
FaceTime Camera Index to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
KRSHH committed Dec 23, 2024
1 parent 5ce9916 commit 77c19d1
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,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"]
Expand Down

0 comments on commit 77c19d1

Please sign in to comment.