How does VideoCapture with CUDA work?


Hi everyone,

I quite new to OpenCV and Python, now I am trying to use GPU to process my Image.

I am not trying yet, but is it method cv2.cuda.VideoCapture(0) exist? I already looking in the documentation but not found.

Also, if anyone have a link tutorial in using CUDA+OpenCV+Python, hope can share the link here.

Thank you. :slight_smile:

No it doesnโ€™t exist, if you are reading from device 0 your only option is to use cv2.VideoCapture().

My advice would be to find the function in C++ and then use the tab autocomplete or help() in python to get the order of the input arguments as they can be different to the C++ ones. Then you can use any C++ tutorials.

Additionally you can find examples of how to call the python CUDA functions by examining the tests for each CUDA module (opencv_contrib/modules/cudaxxx/misc/python/test/test_xxx.py) e.g. cudafilters.

Finally I wrote a toy example to verify that I could get the same perfomance in python as in C++ using CUDA streams which you may find useful

https://jamesbowley.co.uk/accelerating-opencv-with-cuda-streams-in-python/

Thanks for the explanation sir, appreciated it. :slight_smile: