OpenCV Resize is very slow

Reading from video using video = cv.VideoCapture("video.mp4") gives about ~110 FPS. However, just by adding img = cv.resize(img, (320, 512)), the program runs at ~85 FPS. Any idea what caused the slow down?


i guess cv.resize needs some time to perform treatment.

I think cv.resize use CPU so it won’t be as fast as GPU, even if OpenCV is quite fast on CPU.

If you want fastest result, you could try to write your own resize routine using CUDA but you must consider that even if CUDA can speed up the treatment, the result will be not so ggod because of the memory transferts between CPU and GPU.

Maybe GStreamer can resize the video ? I don’t know much things about GStreamer.


The nvvidconv GStreamer element can do hardware resizing, which would be ideal to do as the video is decoded/captured in GStreamer.

You can use the jetson.utils.videoSource API from jetson-inference library which makes use of hardware-accelerated GStreamer and CUDA (see Camera Streaming and Multimedia page. You can test your video with the video-viewer or example:

$ python3 --input-width=512 --input-height=320 video.mp4

Thanks for the info! Also, I’ll be running on multi-stream in the end so DeepStream would be preferred from jertson-inference from what I understand?

Yea, for production multi-stream applications I would recommend going with DeepStream for the best performance.