gpu video decode with openCV

I’m using TensorRT for inference execution of deep learning.
Eventually, I want to real time(over 30FPS) object recognition from the camera image.

I tried object recognition with a video file, but in the CPU decode using the OpenCV function cv::VideoCapture, the decode processing became a bottleneck.

I think that this problem improved by executing decode processing with GPU, I tried GPU decode using function cv::cudacodec::VideoReader.
But, the opencv report the following error:


OpenCV Error: The function/feature is not implemented (The called functionality is disabled for current build or platform) in throw_no_cuda, file /home/nvidia/src/opencv-3.4.0/modules/core/include/opencv2/core/private.cuda.hpp, line 111
terminate called after throwing an instance of ‘cv::Exception’
what(): /home/nvidia/src/opencv-3.4.0/modules/core/include/opencv2/core/private.cuda.hpp:111: error: (-213) The called functionality is disabled for current build or platform in function throw_no_cuda

Is there any solution?
Is there another GPU decoding method?

The environment used is below.
Jetson TX2
Cuda 9.0
opencv-3.4.0

tomoki.k1201,

If you want to use cuda in opencv, you need to build it from source with -DWITH_CUDA.

You can also refer to our MMAPI sample for video decode.

Hi,

I have exactly the same problem.
Even if Opencv is build with Cuda, it will not work.
I’ve done some research and I found this : https://github.com/opencv/opencv/issues/11220

Thanks WayneWWW,

I generated OpenCV libraries with the following options.
But I could not solve this problem.

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_CUDA=ON -D CUDA_ARCH_BIN=“6.2” -D CUDA_ARCH_PTX=""
-D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON
-D ENABLE_NEON=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF
-D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF
-D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_opencv_cudacodec=ON
-D BUILD_opencv_cudev=ON -D WITH_NVCUVID=ON …

Thanks qperret,

Could you solve this problem?
If you could solve this, please show me how to do it.

Hi tomoki.k1201,

Unfortunately, the solution I found yesterday will not work for jetson TX2.
However, I found this: https://devtalk.nvidia.com/default/topic/1022543/jetson-tx2/gstreamer-nvmm-lt-gt-opencv-gpumat/
I didn’t have the time to try it, but we have the same problem.