
import cv2

cam_available = []

for i in range(10):  # Try indices from 0 to 9
    cap = cv2.VideoCapture(i)
    if cap.isOpened():
        print(f"Camera found at index {i}")
        cam_available.append(i)
        cap.release()
    if len(cam_available) > 2:
        break

if len(cam_available) > 2 and cam_available[0] == 0:
    cam1 = cam_available[1]
    cam2 = cam_available[2]
else:
    cam1 = cam_available[0]
    cam2 = cam_available[1]