#include <opencv2\cudacodec.hpp>
这篇文章 https://blog.csdn.net/zijin0802034/article/details/83825081 提供了一个办法,复用例子里的代码,可以运行,但是测的性能还比不上cpu版本的!!
找了可能原因 : https://github.com/opencv/opencv/issues/10201
Hello, I've just walked through all the same issues and can share my experience.
Here is how I've successfully compiled my project with cv::cudacodec::VideoReader
My setup:
dynlink_nvcuvid.cpp
somewhere inside your project. File itself located in /usr/local/cuda/samples/3_Imaging/cudaDecodeGL/dynlink_nvcuvid.cpp
if you've properly installed CUDA Toolkitinclude_directories(${CUDA_INCLUDE_DIRS}) target_link_libraries(project_name cuda)
-lcuda
#include <dynlink_nvcuvid.h>
#include <dynlink_cuviddec.h>
cv::cuda
stuff// Init CUDA
void* hHandleDriver = nullptr;
CUresult cuda_res = cuInit(0, __CUDA_API_VERSION, hHandleDriver);
if (cuda_res != CUDA_SUCCESS) {
throw exception();
}
cuda_res = cuvidInit(0);
if (cuda_res != CUDA_SUCCESS) {
throw exception();
}
std::cout << "CUDA init: SUCCESS" << endl;
cv::cuda::printCudaDeviceInfo(cv::cuda::getDevice());
但是去源码里搜一下,并没有 dynlink_nvcuvid 相关的文件。
看来需要重编一下?
NVCUVID was enabled in opencv cmake with-D WITH_NVCUVID=ON -D CUDA_nvcuvid_LIBRARY=/usr/lib/nvidia-384/libnvcuvid.so
但是cmake里没有 WITH_NVCUVID选项。。。。。
我用的CUDA11和opencv4.4,,,,
原来,新版本的去掉了这个功能。。。。https://github.com/opencv/opencv_contrib/issues/1786
Seems like cuda video decoder is deprecated.
https://docs.nvidia.com/cuda/video-decoder/index.html
That's why -DBUILD_opencv_cudacodec=OFF fixes the issue.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。