Compare commits

...

5 Commits

Author SHA1 Message Date
Bryn Whyman 449af3bbc4
Merge c1a6dc693d into 8d4a386a27 2025-06-16 01:29:34 +08:00
KRSHH 8d4a386a27
Upgrade prebuilt to 2.1 2025-06-15 22:19:49 +05:30
Chittimalla Krish b98c5234d8
Revert 8bdc14a 2025-06-15 20:08:43 +05:30
Chittimalla Krish 8bdc14a789
Update prebuilt version 2025-06-15 17:50:38 +05:30
Bryn Whyman c1a6dc693d Fix: Safe camera detection for macOS (M1/M2) to prevent OpenCV AVX/thread crashes 2025-05-08 20:40:22 +12:00
2 changed files with 23 additions and 57 deletions

View File

@ -30,11 +30,11 @@ By using this software, you agree to these terms and commit to using it in a man
Users are expected to use this software responsibly and legally. If using a real person's face, obtain their consent and clearly label any output as a deepfake when sharing online. We are not responsible for end-user actions. Users are expected to use this software responsibly and legally. If using a real person's face, obtain their consent and clearly label any output as a deepfake when sharing online. We are not responsible for end-user actions.
## Exclusive v2.0 Quick Start - Pre-built (Windows) ## Exclusive v2.1 Quick Start - Pre-built (Windows/Mac Silicon)
<a href="https://deeplivecam.net/index.php/quickstart"> <img src="media/Download.png" width="285" height="77" /> <a href="https://deeplivecam.net/index.php/quickstart"> <img src="media/Download.png" width="285" height="77" />
##### This is the fastest build you can get if you have a discrete NVIDIA or AMD GPU. ##### This is the fastest build you can get if you have a discrete NVIDIA or AMD GPU or Mac Silicon, And you'll receive special priority support.
###### These Pre-builts are perfect for non-technical users or those who don't have time to, or can't manually install all the requirements. Just a heads-up: this is an open-source project, so you can also install it manually. This will be 60 days ahead on the open source version. ###### These Pre-builts are perfect for non-technical users or those who don't have time to, or can't manually install all the requirements. Just a heads-up: this is an open-source project, so you can also install it manually. This will be 60 days ahead on the open source version.

View File

@ -799,73 +799,39 @@ def webcam_preview(root: ctk.CTk, camera_index: int):
def get_available_cameras(): def get_available_cameras():
"""Returns a list of available camera names and indices.""" """
Safe camera detection for macOS and Unix-like systems that avoids threading and AVX crashes.
Returns a tuple of (camera_indices, camera_names).
"""
import cv2
import platform
if platform.system() == "Windows": if platform.system() == "Windows":
try: try:
from pygrabber.dshow_graph import FilterGraph
graph = FilterGraph() graph = FilterGraph()
devices = graph.get_input_devices() devices = graph.get_input_devices()
# Create list of indices and names
camera_indices = list(range(len(devices))) camera_indices = list(range(len(devices)))
camera_names = devices camera_names = devices
# If no cameras found through DirectShow, try OpenCV fallback
if not camera_names:
# Try to open camera with index -1 and 0
test_indices = [-1, 0]
working_cameras = []
for idx in test_indices:
cap = cv2.VideoCapture(idx)
if cap.isOpened():
working_cameras.append(f"Camera {idx}")
cap.release()
if working_cameras:
return test_indices[: len(working_cameras)], working_cameras
# If still no cameras found, return empty lists
if not camera_names: if not camera_names:
return [], ["No cameras found"] return [], ["No cameras found"]
return camera_indices, camera_names return camera_indices, camera_names
except Exception as e: except Exception as e:
print(f"Error detecting cameras: {str(e)}") print(f"[Camera Detection Error - Windows]: {e}")
return [], ["No cameras found"]
else:
# Unix-like systems (Linux/Mac) camera detection
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()
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"] return [], ["No cameras found"]
return camera_indices, camera_names # macOS or Linux
try:
print("[Info] Safely checking for available cameras...")
cap = cv2.VideoCapture(0)
if cap is None or not cap.isOpened():
print("[Warning] Default camera (index 0) not available.")
return [], ["No cameras found"]
cap.release()
return [0], ["Default Camera (Index 0)"]
except Exception as e:
print(f"[Camera Detection Error - Unix]: {e}")
return [], ["No cameras found"]
def create_webcam_preview(camera_index: int): def create_webcam_preview(camera_index: int):