Skip to content

sapus/python-capture-device-list

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

List Capture Devices for Python OpenCV on Windows

OpenCV does not have an API for listing capture devices. The sample shows how to create a Python extension to invoke DirectShow C++ APIs for enumerating capture devices.

Environment

How to Run

  1. Configure Visual Studio environment:

    • Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%
    • Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%
    • Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%
    • Visual Studio 2015 (VS14): SET VS90COMNTOOLS=%VS140COMNTOOLS%

    If you are using Visual Studio 2015, use the following command:

    SET VS90COMNTOOLS=%VS140COMNTOOLS%
    
  2. Add your Windows SDK lib path to setup.py:

    from distutils.core import setup, Extension
    
    module_device = Extension('device',
                            sources = ['device.cpp'], 
                            library_dirs=['G:\Program Files\Microsoft SDKs\Windows\v6.1\Lib']
                        )
    
    setup (name = 'WindowsDevices',
            version = '1.0',
            description = 'Get device list with DirectShow',
            ext_modules = [module_device])
  3. Build the Python extension

    Python 2

    python setup.py build install
    

    Python 3

    python3 setup.py build install
    
  4. Run the app and select a capture device:

    Python 2

    python test.py

    Python 3

    python3 test.py

    camera list in Python

Blog

Listing Multiple Cameras for OpenCV-Python on Windows

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 70.2%
  • Python 29.8%