Skip to main content

cv2_enumerate_cameras

PyPI - Version Python Version from PEP 621 TOML PyPI - Downloads

Retrieve camera names, VID/PID information, device paths, and the corresponding OpenCV indices.

Installation

Install from PyPI

pip install cv2-enumerate-cameras

Quick Start

Run as a Script

A simple command-line script is provided to enumerate all cameras:

lscam

Or run the module directly:

python -m cv2_enumerate_cameras

Integrate into Your Project

To enumerate cameras inside your code:

from cv2_enumerate_cameras import enumerate_cameras

for camera_info in enumerate_cameras():
    print(camera_info)

By default, enumerate_cameras() is called with the parameter CAP_ANY, which instructs cv2_enumerate_cameras to probe all supported backends when enumerating cameras. Example output:

1400: 2K USB Camera (2BDF:02A5)
700: 2K USB Camera (2BDF:02A5)
701: OBS Virtual Camera

These seemingly unusual indices are intentional: OpenCV encodes the backend ID into the high digits of the index. For example, 701 indicates the second camera (1) on the DSHOW backend (700).

To explicitly use a specific backend:

import cv2
from cv2_enumerate_cameras import enumerate_cameras

for camera_info in enumerate_cameras(cv2.CAP_MSMF):
    print(camera_info)

Output:

0: 2K USB Camera (2BDF:02A5)
1: ...
2: ...

Once you have found the target camera, you can create a cv2.VideoCapture by its index and backend properties.

cap = cv2.VideoCapture(camera_info.index, camera_info.backend)

When using CAP_ANY, the backend argument can be omitted. But for robust behavior, explicitly passing it is strongly recommended.

Supported Backends

Not all OpenCV backends support camera enumeration. Use the following snippet to print the names of the supported backends:

from cv2.videoio_registry import getBackendName
from cv2_enumerate_cameras import supported_backends

for backend in supported_backends:
    print(getBackendName(backend))

Windows:

  • Microsoft Media Foundation (CAP_MSMF)
  • DirectShow (CAP_DSHOW)

Linux:

  • GStreamer (CAP_GSTREAMER)
  • V4L/V4L2 (CAP_V4L2)

macOS:

  • AVFoundation (CAP_AVFOUNDATION)

CameraInfo Object

enumerate_cameras() returns a list of CameraInfo objects:

def enumerate_cameras(apiPreference: int = CAP_ANY) -> list[CameraInfo]:
    ...
  • CameraInfo.index: Camera index for the selected backend
  • CameraInfo.name: Human-readable device name
  • CameraInfo.path: Device path (macOS: uniqueID);
  • CameraInfo.vid: USB Vendor ID (if available);
  • CameraInfo.pid: USB Product ID (if available);
  • CameraInfo.backend: OpenCV backend used for enumeration.

Examples

Automatically Select a Camera by VID/PID

This example finds a camera using VID/PID and creates a VideoCapture:

import cv2
from cv2_enumerate_cameras import enumerate_cameras

# Search for a specific camera by VID and PID
def find_camera(vid, pid, apiPreference=cv2.CAP_ANY):
    for i in enumerate_cameras(apiPreference):
        if i.vid == vid and i.pid == pid:
            return cv2.VideoCapture(i.index, i.backend)
    raise RuntimeError('Camera not found!')

# Example: Find the camera with VID 0x04F2 and PID 0xB711
cap = find_camera(0x04F2, 0xB711)

# Capture and display frames
while True:
    ok, frame = cap.read()
    if not ok:
        break
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) == ord('q'):
        break

Metadata

Release files for cv2-enumerate-cameras 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cv2-enumerate-cameras 1.4.0
File Size Uploaded
cv2_enumerate_cameras-1.4.0.tar.gz 12.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cv2-enumerate-cameras 1.4.0
File
cv2_enumerate_cameras-1.4.0-py3-none-any.whl Python 3 none any Details
cv2_enumerate_cameras-1.4.0-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details
cv2_enumerate_cameras-1.4.0-cp315-cp315t-win32.whl CPython 3.15 CPython 3.15 free-threading Windows x86-32 Details
cv2_enumerate_cameras-1.4.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details
cv2_enumerate_cameras-1.4.0-cp314-cp314t-win32.whl CPython 3.14 CPython 3.14 free-threading Windows x86-32 Details
cv2_enumerate_cameras-1.4.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
cv2_enumerate_cameras-1.4.0-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details

Total release size: 1.3 MB

Release files / cv2_enumerate_cameras-1.4.0.tar.gz

Download URL cv2_enumerate_cameras-1.4.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d6f39a236e15cc1bddf00e852a4c6bdfea94d3eebb2d3213848bb5c4036b0689
BLAKE2b-256 checksum
How to use checksums
de6165ea4f16f211b6bd90c18384296a6a79e7d5f49f56082ee36a2185a8f5d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-py3-none-any.whl

Download URL cv2_enumerate_cameras-1.4.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef3db06a004ada2e82b62efaac69f37223f1505b64954bf0f838d21f4cf237cc
BLAKE2b-256 checksum
How to use checksums
5f99e7ab30db5eb4f2f87be9f419eda101ba1cdba6192c5cfdc7ef60305866e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-cp315-cp315t-win_amd64.whl

Download URL cv2_enumerate_cameras-1.4.0-cp315-cp315t-win_amd64.whl
Size 216.4 kB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
791e7f68c5d62c3c22861c53f87b1174f6aa663eeceef8a43fab17ca80fb099c
BLAKE2b-256 checksum
How to use checksums
024ebd22f6430faea2f47b11fd92c18a847b4d60cd707712cd913bd5df9b681a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-cp315-cp315t-win32.whl

Download URL cv2_enumerate_cameras-1.4.0-cp315-cp315t-win32.whl
Size 217.2 kB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-32
SHA-256 checksum
How to use checksums
c6bb01c203813ad3009f504a1bd914efb691174fecd9e99b42e21b8b9d522039
BLAKE2b-256 checksum
How to use checksums
414cb2b96a9f88d0b406d36cf5d20af8137f1cb2c271cb13ec5b5e9df82714c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-cp314-cp314t-win_amd64.whl

Download URL cv2_enumerate_cameras-1.4.0-cp314-cp314t-win_amd64.whl
Size 216.4 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
d7282a37bd340bd63b65950b9fb8e6c2fc7dd5b9141f6cfbb77bf37507932bbe
BLAKE2b-256 checksum
How to use checksums
e6be933593c37b616a63df1491250b7b999bc0297399a69ac616c019a01d5e4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-cp314-cp314t-win32.whl

Download URL cv2_enumerate_cameras-1.4.0-cp314-cp314t-win32.whl
Size 217.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-32
SHA-256 checksum
How to use checksums
fb6312124060093227ff82f0c4a0ff4161b576e9bfcd6bbbafc63b5b0c4788c3
BLAKE2b-256 checksum
How to use checksums
74e696981e59cd724bad4155949b14bbb67d45d0502c15b3cf5cc522a4cedb8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-cp310-abi3-win_amd64.whl

Download URL cv2_enumerate_cameras-1.4.0-cp310-abi3-win_amd64.whl
Size 209.2 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0dcc60c0cc1638bbfb381d0430391d3aabb70324e5eef338d018831207813060
BLAKE2b-256 checksum
How to use checksums
e86d15b6f504b79749a45a53304310c1665044f03d1b79ec2b00598924fc0d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / cv2_enumerate_cameras-1.4.0-cp310-abi3-win32.whl

Download URL cv2_enumerate_cameras-1.4.0-cp310-abi3-win32.whl
Size 211.3 kB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
9c5cd79dd6e8d2b6450e40bb208d968f50976cf15f276c5e10c9880498e23b25
BLAKE2b-256 checksum
How to use checksums
482f5277bcabd62e675b85f00825d8ebc3ceaa23c7fd6362a4dc09f3accc716e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page