Capturing video from two cameras in OpenCV at once

前端 未结 7 1172
别跟我提以往
别跟我提以往 2020-11-30 04:27

How do you capture video from two or more cameras at once (or nearly) with OpenCV, using the Python API?

I have three webcams, all capable of video streaming, locate

7条回答
  •  猫巷女王i
    2020-11-30 04:46

    This has been a pain for me for a long time, so I made a library on top of OpenCV to handle multiple cameras and viewports. I ran into a bunch of problems like videos not compressing by default, or windows only displaying in the main thread. I'm able to display two 720p webcams in real time on Windows so far.

    Try:

    pip install CVPubSubs
    

    Then, in python:

    import cvpubsubs.webcam_pub as w
    from cvpubsubs.window_sub import SubscriberWindows
    
    t1 = w.VideoHandlerThread(0)
    t2 = w.VideoHandlerThread(1)
    
    t1.start()
    t2.start()
    
    SubscriberWindows(window_names=['cammy', 'cammy2'],
                  video_sources=[0,1]
                  ).loop()
    
    t1.join()
    t1.join()
    

    It's relatively new though, so tell me about any bugs or unoptimized code.

提交回复
热议问题