Skip to main content

No project description provided

Project description

cv2_enumerate_cameras

Installation

Online

pip install git+https://github.com/chinaheyu/cv2_enumerate_cameras.git

Local

python setup.py install

Example

Camera Info

The cv2_enumerate_cameras.enumerate_cameras() function will return a list of CameraInfo objects.

  • CameraInfo.index: Camera index for creating cv2.VideoCapture
  • CameraInfo.name: Camera name
  • CameraInfo.path: Camera device path
  • CameraInfo.vid: Vendor identifier
  • CameraInfo.pid: Product identifier

Enumerate Cameras

import cv2
from cv2_enumerate_cameras import enumerate_cameras

for camera_info in enumerate_cameras(cv2.CAP_MSMF):
    print(f'{camera_info.index}: {camera_info.name}')

Output:

0: HD Webcam
...

Find Camera by Vendor and Product Identifier

import cv2
from cv2_enumerate_cameras import enumerate_cameras

def find_camera(vid, pid, apiPreference=cv2.CAP_MSMF):
    for i in enumerate_cameras(apiPreference):
        if i.vid == vid and i.pid == pid:
            return cv2.VideoCapture(i.index, apiPreference)
    return None

cap = find_camera(0x04F2, 0xB711)
while True:
    result, frame = cap.read()
    if not result:
        break
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) == ord('q'):
        break

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

cv2_enumerate_cameras-1.0-cp312-cp312-win_amd64.whl (24.4 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

cv2_enumerate_cameras-1.0-cp311-cp311-win_amd64.whl (24.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

cv2_enumerate_cameras-1.0-cp310-cp310-win_amd64.whl (24.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page