C++ OpenCV中的VideoReader已被弃用。OpenCV是否有任何更新或任何替代?
我正在做视频解码,以获取一些后期视频处理帧。我正在使用opencv Cuda,所以我真的需要opencv Cuda的视频阅读器。然而,我意识到: 在NVIDIA视频编解码器SDK 8.2.15中,它说 在将来的SDK版本中,将从解码器API中删除对CUvideosource和相关API的支持,包括cuvidCreateVideoSource、cuvidCreateVideoSourceW、CUVIDDesDestroyVideoSourceState、cuvidGetVideoSourceState、cuvidGetSourceVideoFormat、cuvidGetSourceAudioFormat。请注意,SDK中的新解码示例应用程序不使用这些API,而是使用FFmpeg 但要在OpenCV Cuda中使用“createVideoReader”,我们需要链接包含C++ OpenCV中的VideoReader已被弃用。OpenCV是否有任何更新或任何替代?,c++,opencv,nvidia,video-processing,C++,Opencv,Nvidia,Video Processing,我正在做视频解码,以获取一些后期视频处理帧。我正在使用opencv Cuda,所以我真的需要opencv Cuda的视频阅读器。然而,我意识到: 在NVIDIA视频编解码器SDK 8.2.15中,它说 在将来的SDK版本中,将从解码器API中删除对CUvideosource和相关API的支持,包括cuvidCreateVideoSource、cuvidCreateVideoSourceW、CUVIDDesDestroyVideoSourceState、cuvidGetVideoSourceSta
tcuvidCreateVideoSource *cuvidCreateVideoSource;
tcuvidCreateVideoSourceW *cuvidCreateVideoSourceW;
tcuvidDestroyVideoSource *cuvidDestroyVideoSource;
tcuvidSetVideoSourceState *cuvidSetVideoSourceState;
tcuvidGetVideoSourceState *cuvidGetVideoSourceState;
tcuvidGetSourceVideoFormat *cuvidGetSourceVideoFormat;
tcuvidGetSourceAudioFormat *cuvidGetSourceAudioFormat;
opencv是否更新了视频解码?我们如何在OpenCV中使用FFmpeg替换“dynlink\u nvcuvid.h”?我正在尝试使用NVIDIA视频解码,但我在将视频帧转换为GpuMat时遇到了困难
我正在使用
Ubuntu 18
Cuda 9.2
OpenCV 3.4.2
对于Cuda部分,为了解码,我使用了以下代码:
FFmpegDemuxer demuxer(szInFilePath);
NvDecoder dec(cuContext, demuxer.GetWidth(), demuxer.GetHeight(), true, FFmpeg2NvCodecId(demuxer.GetVideoCodec()));
FramePresenterGL presenter(cuContext, demuxer.GetWidth(), demuxer.GetHeight());
uint8_t *dpFrame = 0;
int nPitch = 0;
int nVideoBytes = 0, nFrameReturned = 0, nFrame = 0;
uint8_t *pVideo = NULL;
uint8_t **ppFrame;
do {
demuxer.Demux(&pVideo, &nVideoBytes);
dec.Decode(pVideo, nVideoBytes, &ppFrame, &nFrameReturned);
if (!nFrame && nFrameReturned)
LOG(INFO) << dec.GetVideoInfo();
for (int i = 0; i < nFrameReturned; i++) {
presenter.GetDeviceFrameBuffer(&dpFrame, &nPitch);
if (dec.GetBitDepth() == 8)
Nv12ToBgra32((uint8_t *)ppFrame[i], dec.GetWidth(), (uint8_t *)dpFrame, nPitch, dec.GetWidth(), dec.GetHeight());
else
P016ToBgra32((uint8_t *)ppFrame[i], 2 * dec.GetWidth(), (uint8_t *)dpFrame, nPitch, dec.GetWidth(), dec.GetHeight());
cv::Size sz(dec.GetWidth(),dec.GetHeight());
cv::Mat mat1(sz,CV_8UC3, ppFrame);
cv::imshow ("test", mat1);
cv::waitKey(0);
}
nFrame += nFrameReturned;
} while (nVideoBytes);
FFmpegDemuxer解复用器(szInFilePath);
NVDEC(cuContext,demuxer.GetWidth(),demuxer.GetHeight(),true,FFmpeg2NvCodecId(demuxer.GetVideoCodec());
FramePresenterGL演示器(cuContext、demuxer.GetWidth()、demuxer.GetHeight());
uint8_t*dpFrame=0;
int-nPitch=0;
int nVideoBytes=0,nFrameReturned=0,nFrame=0;
uint8_t*pVideo=NULL;
uint8\u t**ppFrame;
做{
demuxer.Demux(&pVideo,&nVideoBytes);
dec.Decode(返回pVideo、nVideoBytes、ppFrame和NFFrame);
如果(!nFrame&&nFrame返回)
LOG(INFO)我发现了一种简单的c方式,可以在没有任何第三方的情况下读取图像
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int read_image(FILE *rfile, void *buf, int width, int height, int stride, int elem_size)
{
char *byte_ptr = buf;
int i;
int ret = 1;
if (width <= 0 || height <= 0 || elem_size <= 0)
{
goto fail_or_end;
}
for (i = 0; i < height; ++i)
{
if (fread(byte_ptr, elem_size, width, rfile) != (size_t)width)
{
goto fail_or_end;
}
byte_ptr += stride;
}
ret = 0;
fail_or_end:
return ret;
}
#包括
#包括
#包括
整数读取图像(文件*rfile,无效*buf,整数宽度,整数高度,整数跨步,整数元素大小)
{
char*byte_ptr=buf;
int i;
int-ret=1;
如果也许你可以写自己的图书馆,就像这个家伙做的那样,你可以停止从我的帖子中删除CUDA标签。我使用CUDA的FFMPEGDEMUXER,NvDecoder和所有与CUDA相关的东西。我把它删除了一次,就像它最初写的一样。这个帖子与CUDA PrAgMatg无关。OpenCV不是CUDA。英伟达视频解码SD。K不是CUDA。FFMPEG不是CUDACUresult是一个状态码。你无法将其转换为矩阵。当帧存储在uint8_t中时,甚至建议它都没有意义?我只是一个CUDA初学者。
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int read_image(FILE *rfile, void *buf, int width, int height, int stride, int elem_size)
{
char *byte_ptr = buf;
int i;
int ret = 1;
if (width <= 0 || height <= 0 || elem_size <= 0)
{
goto fail_or_end;
}
for (i = 0; i < height; ++i)
{
if (fread(byte_ptr, elem_size, width, rfile) != (size_t)width)
{
goto fail_or_end;
}
byte_ptr += stride;
}
ret = 0;
fail_or_end:
return ret;
}