VideoCamera.list#

classmethod VideoCamera.list() list[dict][source]#

Enumerate available local video cameras

Returns:

list of dicts, one per camera, each with keys id, width, height, fps, and name (best-effort). On macOS, width, height, and fps are None if the process has not yet been granted camera authorisation.

Return type:

list[dict]

Probes integer indices 0, 1, 2, … until no camera responds, and returns a list describing each one. Camera names are obtained by a platform-specific method:

  • macOSsystem_profiler SPCameraDataType -json (no camera authorisation required)

  • Linux/sys/class/video4linux/videoN/name sysfs entry

  • Windows — not available; name is None

The name mapping is best-effort: if the platform query fails the name key is None.

Example:

$ python
>>> from machinevisiontoolbox import VideoCamera
>>> for cam in VideoCamera.list():
...     print(cam)
{'id': 0, 'width': 1280, 'height': 720, 'fps': 30, 'name': 'FaceTime HD Camera'}
{'id': 1, 'width': 1920, 'height': 1080, 'fps': 30, 'name': 'iPhone Camera'}
Seealso:

VideoCamera