我想做一个循环的图像缓冲区但是当我尝试使用该数组时会弹出一个访问冲突。
这是我的代码:
uint8_t **u8_CircularBufferOfImages_; ///< Circular buffer with the data
uint8_t *u8_FilterResultImage_; ///< The result of the temporal filter
uint8_t u8_Head_, u8_Queue_; ///< Indicate where the images are in the circular buffer
uint8_t u8_CBSize_; ///< Size if the circular buffer
uint8_t u8_KSize_; ///< Size of the kernel to apply
checkCudaErrors(cudaMalloc(&u8_FilterResultImage_, iheight_*iwidth_ * sizeof(u_int8_t)));
cudaMemset(u8_FilterResultImage_, 0, iheight_*iwidth_ * sizeof(u_int8_t));
// Allocate the 2D pointer
checkCudaErrors(cudaMalloc(&u8_CircularBufferOfImages_, u8_CBSize_ * sizeof(u_int8_t*)));
for (int i = 0; i < u8_CBSize_; i++)
{
// Create the 1D pointer
uint8_t * u8pt;
checkCudaErrors(cudaMalloc(&u8pt, iheight_*iwidth_ * sizeof(u_int8_t)));
checkCudaErrors(cudaMemcpy(&u8_CircularBufferOfImages_[i], &u8pt, sizeof(u_int8_t *), cudaMemcpyHostToDevice));
}
当我尝试使用它时:
checkCudaErrors(cudaMemcpy(u8_CircularBufferOfImages_[0],u8_ptSrc_Device, iheight_*iwidth_ * sizeof(u_int8_t), cudaMemcpyHostToDevice));
以下是Visual Studio上的错误:
Exception thrown at 0x00007FF671812D2C in Test.exe: 0xC0000005: Access violation reading location 0x0000000704400000.
如果存在此异常的处理程序,则可以安全地继续该程序。
我认为我在指针上犯了一个错误,但我不知道在哪里。