Hi,
I want to work with images in a kernel without changing their format. Currently I am facing the following problem:
main.cpp
//forward declaration of functions in kernels.cu
void do_test(const cv::gpu::PtrStepSz<float>& src, cv::gpu::PtrStepSz<float>& dst);
main(){
// img_in and img_out are both with CV_32FC1 format
do_test(img_in, img_out);
}
kernels.cu
__global__ void do_test_kernel(cv::gpu::PtrStepSz<float> src, cv::gpu::PtrStepSz<float> dst)
{
int x = threadIdx.x + blockIdx.x * blockDim.x;
int y = threadIdx.y + blockIdx.y * blockDim.y;
if(x < dst.cols && y < dst.rows) {
dst.ptr(y)[x] = src.ptr(y)[x];
}
}
void do_test(const cv::gpu::PtrStepSz<float>& src, cv::gpu::PtrStepSz<float>& dst)
{
dim3 block(32,8);
dim3 grid(dst.cols/block.x, dst.rows/block.y);
do_test_kernel<<<grid,block>>>(src,dst);
}
When compiling, the error at the forward declaration is:
in passing argument 2 of ‘void do_test(const cv::gpu::PtrStepSz&, cv::gpu::PtrStepSz&)’
and at the function call in the main() function the error is:
invalid initialization of reference of type ‘cv::gpu::PtrStepSz&’ from expression of type ‘cv::gpu::GpuMat’
What am I doing wrong? Thanks for your answers.
Greetings
ManuKlause