Fastest way to get webcam footage

I have a little problem developing one of my C ++ programs (Visual studio). Now I am struggling with connecting multiple webcams (connected via USB cables), creating a separate stream for each of them to capture frames, and a separate frame for image processing.

I am using OpenCV to handle frames, but the problem is I am not getting the peak of the webcam capabilities (it supports 25 frames per second, I only get 18) is there some library I could use to get the frames, how to handle them with OpenCV, which would make the frames be captured faster?

I've been digging a bit and the most popular way is to use directshow to get frames and OpenCV to process them.

Do you agree? Or do you have another solution? I wouldn't mind some links :)

+3


source to share


2 answers


  • DirectShow is only used if you open a capture using the CV_CAP_DSHOW Flag, for example:

    VideoCapture capture( CV_CAP_DSHOW + 0 );  // 0,1,2, your cam id there
    
          

    (without it, vfw is used by default)

  • the capture is already done on a separate thread, so wrapping it with more threads won't give you any gain.

  • Another hurdle with multiple cams is USB bandwidth, so if you have ports on the back and front of your computer, don't plug all your cameras into the same port / controller, or you'll just saturate it.



+5


source


OpenCV uses DirectShow. Using DirectShow (the primary video capture API on Windows) directly will obviously give you a pair or better performance (and even more likely if OpenCV is tuned to use Windows video). USB cameras generally use USB bandwidth and therefore frame rate limiting, using DirectShow to capture compressed formats or formats with fewer bits / pixels is a way to achieve higher frame rates within the same USB bandwidth limit.



Another common problem that causes low frame rates is slow synchronous processing delaying capture. You usually identify this by putting trivial processing in the same capture loop and seeing a higher FPS compared to assisted processing.

+3


source







All Articles