Using cv::cudacodec::createVideoReader()

asked 2017-02-09 06:18:31 -0500

ThorbjornSomod gravatar image

updated 2017-02-09 06:56:33 -0500

Hi!

I've decided to start using the OpenCV 3.2 CUDA interface and I want to use the cv::cudacodec::createVideoWriter() function and writer->write(gpu_frame) to write directly from the GPU memory. I've successfully built OpenCV 3.2 with CUDA 8.0 and the flags WITH_CUBLAS, WITH_CUDA and WITH_NCUVID. I have also successfully read directly into the GPU memory using the cv::cudacodec::createVideoReader() function and reader->nextFrame(gpu_frame).

My problem arises when I try to create a writer to the GPU memory using cv::cudacodec::createVideoWriter(). I then get an unhandled exception and an OpenCV Error saying:

OpenCV Error: The function/feature is not implemented (The called functionality is disabled for current build or platform) in throw_no_cuda, file C;\opencv\source\modules\core\include\opencv2/core/private.cuda.hpp, line 101

To me this sounds as if I am missing a package in my build of OpenCV, but I thought that cv::cudacodec:createVideoWriter() was included in NCUVID. This seems pretty strange to me, but maybe some of you guys know more about this? Any help at all is appreciated!

PS: I have also overwritten the version of CUDA 8.0 to include cuDNN. I dont know if this makes any difference, but I thought I'd mention it.

EDIT: Added the OpenCV 3.2 buildlog output.

General configuration for OpenCV 3.2.0-dev ===================================== Version control: 3.2.0-131-gece3fac-dirty

Extra modules: Location (extra): C:/opencv/opencv_contrib/modules Version control (extra): 3.2.0-54-gd879ea4

Platform: Timestamp: 2017-02-09T09:54:34Z Host: Windows 10.0.14393 AMD64 CMake: 3.7.2 CMake generator: Visual Studio 14 2015 Win64 CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe MSVC: 1900

C/C++: Built as dynamic libs?: YES C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe (ver 19.0.24210.0) C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4324 /wd4275 /wd4589 /MP4 /MD /O2 /Ob2 /DNDEBUG /Zi C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4324 /wd4275 /wd4589 /MP4 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MP4 /MD /O2 /Ob2 /DNDEBUG /Zi C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MP4 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 Linker flags (Release): /machine:x64 /INCREMENTAL:NO /debug Linker flags (Debug): /machine:x64 /debug /INCREMENTAL ccache: NO Precompiled headers: NO Extra dependencies: vfw32 C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cuda.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/nvcuvid.lib comctl32 gdi32 ole32 setupapi ws2_32 glu32 opengl32 cudart nppc nppi npps cublas cufft -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8 ... (more)

edit retag flag offensive close merge delete

Comments

Have you clone opencv ? ICan post getBuildInformation results ?

LBerger gravatar imageLBerger ( 2017-02-09 06:30:09 -0500 )edit

I cloned OpenCV 3.2 from the git repo yes :) I added the output from getBuildInformation to the original post!

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-09 06:57:52 -0500 )edit

try to build with BUILD_TESTS on in cmake . there is a test about video with cuda

LBerger gravatar imageLBerger ( 2017-02-09 07:08:20 -0500 )edit

Hmmm i'll try to do that. But earlier when I tried to build OpenCV with CUDA 8.0 I got a lot of errors when building with BUILD_PERF_TESTS and BUILD_TESTS on. I'll get back to this once I rebuild. Oh btw, another quick question. When I rebuild the solution, do I need to clear the build directory of the previous build? If I have to rebuild the entire solution it's going to take a couple of hours.

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-09 07:20:39 -0500 )edit

About cuda 8.0 there is this issue

you need only BUILD_TESTS. You don't need to clean your build directory (but cmake sometimes cmake will do it). I know with opencl you need to clean build directory because ocl are not build. For cuda I don't know.

'to take a couple of hours" have you build CUDA with only one architecture?

LBerger gravatar imageLBerger ( 2017-02-09 07:28:47 -0500 )edit

Alright, I'll try it! Thanks :) And also yeah I am only building the Maxwell architecture for compute compatibility 5.2 (+ 5.0 which comes automatically) since im running on a GTX970

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-09 07:31:57 -0500 )edit

Hmm I rebuilt the solution with BUILD_TESTS = ON but the problem persists. I still can't use cv::cudacodec::createVideoWriter() =/

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-09 09:28:30 -0500 )edit

Yes test change nothing but now you can try to run program opencv_test_video

LBerger gravatar imageLBerger ( 2017-02-09 09:36:14 -0500 )edit

I'll try the test project as soon as I get back to the office tomorrow morning! Although I don't think it's a compatibility issue...

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-09 15:20:02 -0500 )edit

Hmm when running opencv_test_video I'm getting a lot of errors, but most of them are related to the optical flow module, and not the cudacodec module. Do you want the output from opencv_test_video and opencv_test_videod?

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-10 04:08:56 -0500 )edit