1.首先编译了opencv + cuda
编译选项中使用了以下关于cuvid库的内容:
//"nvcuvid" library
CUDA_nvcuvid_LIBRARY:FILEPATH=/usr/local/lib/libnvcuvid.so
//Path to a library.
CUDA_rt_LIBRARY:FILEPATH=/usr/local/cuda-9.0/lib64/libcudart_static.a
//Include NVidia Video Decoding library support
WITH_NVCUVID:BOOL=ON
2.下载了这个opencv + cuvid视频解码例子:
https://github.com/opencv/opencv/blob/master/samples/gpu/video_reader.cpp
编译和链接命令行:
g++ -c video_reader.cpp -o video_reader.o -g -I"/home/admin/opencv/2019-05-09_cuda/include/opencv4/" -std=c++11
g++ -o video_reader video_reader.o -L"/home/admin/opencv/2019-05-09_cuda/lib64/" -lopencv_core -lopencv_videoio -lopencv_cudacodec -lopencv_imgproc -lopencv_imgcodecs -lopencv_flann -lopencv_img_hash -lopencv_photo -L"/usr/local/cuda/lib64/stubs" -lcuda -lcublas -L"/usr/local/cuda/lib64" -lcudart -L"/usr/local/lib/" -lnvcuvid -lz -ldl -lpthread -lopencv_imgcodecs -lopencv_core -lopencv_imgcodecs -L"/home/admin/opencv/2019-05-09_cuda/lib64/opencv4/3rdparty" -lIlmImf -lopencv_core -lopencv_imgproc
3. 运行程序,出现coredump,GPU驱动的版本是 384.81
./video_reader stand_input.mp4
Program received signal SIGSEGV, Segmentation fault.
堆栈信息如下:
(gdb) bt
#0 0x00000000007eb4aa in cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource (
this=0x1731810, fname=…)
at /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuvid_video_source.cpp:63
#1 0x00000000007e6943 in cv::cudacodec::createVideoReader (filename=…)
at /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/video_reader.cpp:206
#2 0x000000000040e0cb in main (argc=2, argv=0x7fffffffe5a8) at video_reader.cpp:33
(gdb) f 0
#0 0x00000000007eb4aa in cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource (
this=0x1731810, fname=…)
at /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuvid_video_source.cpp:63
63 CUresult cuRes = cuvidCreateVideoSource(&videoSource_, fname.c_str(), ¶ms);
4. 搜索了一下,这篇帖子貌似提供了解决办法:
https://github.com/opencv/opencv/issues/10201
下一步尝试自己下载一个 Video_Codec_SDK 库来替换系统自带的版本。
====================
2019-05-12补充:
按照以上帖子的提示,下载 Video_Codec_SDK_8.0.14.zip
unzip Video_Codec_SDK_8.0.14.zip
/home/admin/cuvid/Video_Codec_SDK_8.0.14/Samples
make
# make 出现错误,没关系, dynlink_nvcuvid.o生成就好了
代码的头文件中include Video_Codec_SDK_8.0.14/Samples/common/inc/dynlink_nvcuvid.h
然后代码中加上:cuda_res = cuvidInit(0);
最后,链接的路径中加上: "Video_Codec_SDK_8.0.14/Samples/NvDecodeGL/dynlink_nvcuvid.o" -L"/usr/local/nvidia/lib64/" -lnvcuvid
运行成功
然后又遇到了GpuMat的格式问题,请看下一篇!
手机扫一扫
移动阅读更方便
你可能感兴趣的文章