Using OpenCV APIs to capture video from a camera is convenient. However, OpenCV does not provide an API for listing all available devices. If you have multiple cameras connected to your PC, you have no idea how to choose the right one. To get device information on Windows, you need to invoke DirectShow APIs. In this post, I will share how to create a Python extension that lists camera devices for OpenCV-Python on Windows.
Previously I shared how to use Touchless, which wraps the win32 APIs of DirectShow, to control webcam in C#. In this article, let’s take a further step to see how to use the more complicated DirectShow.NET APIs to capture the video stream and read barcode from preview frames on Windows.