A vector reference instead of single value?

Hello,

I have a C++ code in which a helper function is called having four arguments of one value each, the first argument being a reference of the type GpuMat. Most of these arguments are passed to the second helper function as arguments, which is called from the first helper function, and its first argument is accepted as a reference to some other type, DevMem2Df, in this second helper function. From this second helper function, a kernel function is called. The code compiles fine, runs fine.

To make lesser number of calls to the kernel function, the first helper function needs to be taken out of the loop, in which, it is called, thereby the second, and thereby to the actual kernel function.

For this, I need to gather all values of the first argument into a vector. So, I have a vector of the type GpuMat. But in the second helper function, if I try to create a reference to the vector of a different data type, it throws an error saying,

“error: invalid initialization of reference of type const std::vector<cv::gpu::DevMem2D_ >& from expression of type const std::vectorcv::gpu::GpuMat

I do not understand how to get over this problem. Please help.

can you show the helper function code?

The original code is as follows:

getResponse(const gpu::GpuMat &gFeatures, const GpuMat &gKernel, gpu::GpuMat &gResp_final, const Size &kernelDim)
{
getRespMap(gFeatures,gKernel,gResp,…);
}

void getRespMap(const DevMem2Df &gFeatures, const DevMem2Df &gKernel, DevMem2Df gResp,const int kernelDim_x,const int kernelDim_y, const int featDim_x)
{}

The above code compiles and runs fine.


Now, my approach is below:

void getResponse(const vectorgpu::GpuMat &gFeatures, const vectorgpu::GpuMat &gKernel,
vectorgpu::GpuMat &gResp_final, const vector &gkernelDim, int & RespVecSize)
{
getRespMap(gFeatures, gKernel, gResp_final, …);
}

void getRespMap(const vector & hFeatures,
const vector & hKernel,
vector & hResp,
vector & hkernelDim_x,
vector & hkernelDim_y,
vector & hfeatDim_x,
int & RespVecSize)
{}

Here, look at the first 3 parameters, particularly. And please give me the solution.

Thanks,

the error is likely because the function parameters passed to the called function are perceived to be wrong, or incompatible

if const gpu::GpuMat &gFeatures == const DevMem2Df &gFeatures works, and

const gpu::GpuMat &gFeatures is not a array/ vector,

but, const vectorgpu::GpuMat &gFeatures is seen as != const vector & hFeatures

then you probably should pass to the function const vectorgpu::GpuMat &gFeatures,

and dereference the former within the function to get to

const gpu::GpuMat &gFeatures == const DevMem2Df &gFeatures works again

just check