robot_face_rec/002查看摄像头id.py
2025-12-05 12:01:20 +08:00

15 lines
327 B
Python

import cv2
def list_cameras():
index = 0
cameras = []
while True:
cap = cv2.VideoCapture(index)
if not cap.read()[0]:
break
cameras.append(f"Camera {index}: {cap.getBackendName()}")
cap.release()
index += 1
return cameras
print(list_cameras())