【记录一个问题】cv::cuda::BufferPool发生assert错误

cv::cuda::setBufferPoolUsage(true);

const int width = 512;

const int height = 848;

const int channel = 4;

const int BATCH_COUNT = 30;

cv::cuda::setBufferPoolConfig(cuda_device, width*height*channel*BATCH_COUNT*2, 1);

cv::cuda::Stream stream1;

cv::cuda::BufferPool pool1(stream1);

//....

cv::cuda::GpuMat d_frame = pool1.getBuffer(848, 512, CV_8UC4);  //这里发生了assert断言错误

cv::cuda::GpuMat d_hvs = pool1.getBuffer(848, 512, CV_8UC4);

我猜测cv::cuda::BufferPool是一个定长的内存池,而图像解码的时候需要的实际空间与我以为的空间不一致,导致断言错误!

那么:在解码一帧图像以前,如何得知这一帧图像需要多少GPU内存呢?

原文地址:https://www.cnblogs.com/ahfuzhang/p/10860797.html