opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
77.99k stars 55.69k forks source link

Python: Get the VideoDevice's name #23537

Open Avasam opened 1 year ago

Avasam commented 1 year ago

Describe the feature and motivation

Some part of my code creates a VideoDevice with the ID. Some other part of my code receives that VideoDevice, but needs to special case some devices to work around device-specific bugs.

I also would like to like all available cameras names, but can't do that with OpenCV, so I'm using pygrabber for it.

For now my best workaround is to keep a mapping of name to id somewhere (names obtained thanks to pygrabber), but that mapping could change at any time if the user unplugs any device.

It does seem to be part of the videoDevice class, can this be exposed in Python? https://github.com/opencv/opencv/blob/master/modules/videoio/src/cap_dshow.cpp#L445-L446

Additional context

Using cv2 (OpenCV-Python) 4.7.0

mediba123 commented 1 year ago

it can be exposed in python , the device information is in the cv::VideoCapture class of OpenCV c++ API and this can be use by Opencv-python's cv2.VideoCapture function and this class uses Directshow API on windows to query infomations to check device name in OpenCv-python , create a new python class that covers the cv2.VideoCapture class and add more to bring the information.