I 开发者_运维百科need to retrieve the number of webcams instaled in my system and the brand, manufacturer, device id, etc., of the webcam. Is there any way to do that in Python, and independent of the operating system?
There's no truly cross-platform solution, but on Linux you can use os.popen('lsusb')
(or something along those lines) and then just scrape the screen (using grep or something else). For finding out on Windows, you can try using a TWAIN binding for Python (it's the Windows webcam protocol, a Python binding exists here, but it's not actively maintained). VideoCapture might have what you need.
I found a partial solution, which is to use the command:
v4l2-ctl --list-devices
But only works on Linux, but on Windows I have no way of detecting the amount and the name of the installed webcams.
精彩评论