Using cv::cudacodec::createVideoReader()
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 ...
Have you clone opencv ? ICan post getBuildInformation results ?
I cloned OpenCV 3.2 from the git repo yes :) I added the output from getBuildInformation to the original post!
try to build with BUILD_TESTS on in cmake . there is a test about video with cuda
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.
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?
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
Hmm I rebuilt the solution with BUILD_TESTS = ON but the problem persists. I still can't use cv::cudacodec::createVideoWriter() =/
Yes test change nothing but now you can try to run program opencv_test_video
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...
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?
I ve just finished compilation using vs 2015 and cuda 8.0. Results of opencv are here It is not opencv_video but opencv_test_cudacodecd.exe
Yeah I noticed that aswell! Very weird that it is not working with my GTX970 though? Doesnt seem to find the CUDA device
Cuda device is found That's not the problem Problem is here :
Video.reader is found and not video.writer. I can say that there is no error in your program
Hmm maybe it is not supported anymore and they have forgot to remove it from the documentation then. Well, that sucks, as there are no other ways of writing directly from the GPU to disk as far as I know :( Thanks for you help anyways!