Identify and select your USB cameras in Python for use with OpenCV.
Project description
pyusbcameraindex
Identify and select your USB cameras in Python for use with OpenCV.
🚀🤯 Stop guessing the camera index in OpenCV! 🤯🚀
The pyusbcameraindex package enumerates USB video devices on Windows using DirectShow APIs.
Linux and Mac are not supported, but pull requests are welcome.
Usage:
import cv2
from pyusbcameraindex import enumerate_usb_video_devices_windows
# List the devices.
devices = enumerate_usb_video_devices_windows()
for device in devices:
print(f"{device.index} == {device.name} (VID: {device.vid}, PID: {device.pid}, Path: {device.path}")
# Show a frame from each.
for device in devices:
cap = cv2.VideoCapture(device.index, cv2.CAP_DSHOW)
ret, frame = cap.read()
cv2.imshow(f"Device={device.name}", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyusbcameraindex-1.0.1.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for pyusbcameraindex-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3fe457bf6085466912f952b7b9338ae5aed99684cb144fc7b1e591beb83dee8 |
|
MD5 | df35c8da770f7549e685093f8f8f0c15 |
|
BLAKE2b-256 | 24fbac5b6197953f21b785b910905906278cfc0b286fda279987a47b03ae30cd |