cv2-enumerate-cameras
raw JSON → 1.3.3 verified Fri May 01 auth: no python
Enumeration of available OpenCV camera indices via VideoCapture. Version 1.3.3, stable. Provides cross-platform functions to list camera devices without trial-and-error. Released irregularly.
pip install cv2-enumerate-cameras Common errors
error ModuleNotFoundError: No module named 'cv2_enumerate_cameras' ↓
cause Library not installed or installed in a different environment.
fix
Run 'pip install cv2-enumerate-cameras' in the correct Python environment.
error ImportError: cannot import name 'enumerate_cameras' from 'cv2_enumerate_cameras' ↓
cause Using an older version of the library that does not have this function.
fix
Upgrade to the latest version: 'pip install --upgrade cv2-enumerate-cameras'.
error AttributeError: 'NoneType' object has no attribute 'read' ↓
cause The function returned a camera index that is actually invalid or busy.
fix
Verify the camera is available and not used elsewhere. Consider using error handling: cap = cv2.VideoCapture(index); if not cap.isOpened(): continue.
Warnings
gotcha Function may return indices that fail to open if the camera is already in use by another process. ↓
fix Always attempt cv2.VideoCapture(index) to verify the camera is usable.
gotcha On some systems (e.g., Linux with V4L), the enumeration might not detect all cameras if permissions are insufficient. ↓
fix Ensure user has read/write access to /dev/video*.
deprecated The function 'list_cameras()' (if imported from older versions) is deprecated; use 'enumerate_cameras()'. ↓
fix Replace 'list_cameras()' with 'enumerate_cameras()'.
Imports
- enumerate_cameras
from cv2_enumerate_cameras import enumerate_cameras
Quickstart
from cv2_enumerate_cameras import enumerate_cameras
cameras = enumerate_cameras()
print(cameras) # e.g., [0, 1]