前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >opencv cudacodec VideoReader 报错

opencv cudacodec VideoReader 报错

原创
作者头像
shirishiyue
修改2020-09-19 17:11:01
1.8K0
修改2020-09-19 17:11:01
举报
文章被收录于专栏:全栈码
代码语言:javascript
复制
#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:

  • Ubuntu 16.04
  • OpenCV 3.4.1
  • CUDA 9.1
  • CMake 3.5.1
  1. Copy 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 Toolkit
  2. Link CUDA library to your project
    • CMake

    include_directories(${CUDA_INCLUDE_DIRS}) target_link_libraries(project_name cuda)

    • gcc

    -lcuda

  3. Include CUDA headers in your project
代码语言:javascript
复制
#include <dynlink_nvcuvid.h>
#include <dynlink_cuviddec.h>
  1. Init the device before using cv::cuda stuff
代码语言:javascript
复制
// 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.

转到了 NVIDIA Video Codec SDK.

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档