Skip to content

Instantly share code, notes, and snippets.

@saiccoumar
Created January 5, 2024 05:14
Show Gist options
  • Save saiccoumar/937bb53d01c39359e5659f8f35d0f9c9 to your computer and use it in GitHub Desktop.
Save saiccoumar/937bb53d01c39359e5659f8f35d0f9c9 to your computer and use it in GitHub Desktop.
available cameras
import cv2
def get_available_cameras():
available_cameras = []
# Check for 5 cameras
for i in range(5):
cap = cv2.VideoCapture(i)
if cap.isOpened():
available_cameras.append(i)
cap.release()
return available_cameras
cameras = get_available_cameras()
if cameras:
print("Available Cameras:", cameras)
else:
print("No cameras found.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment