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.0.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for pyusbcameraindex-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 103ce6df36125335cedf50a5a730de4f56c21188a5e43ed9407016429d08763c |
|
MD5 | 2a59b7752044514340261df242cea169 |
|
BLAKE2b-256 | 7eceb46741291afe4435ad9dabf993b014a8e94bd495b040732a52a577f74f3c |