problem with gpu::convolve (image type)

asked 2014-06-25 20:35:52 -0600

madaegam gravatar image

updated 2014-06-25 20:36:20 -0600

Hello! I've just started to use OpenCV for GPU computation.

I'm trying to use GPU for convolution but have an issue with image type.

This is the message I got. I think my code is fine but cannot figure out the reason. (I currently have no problem with GaussianBlur or Sobel in GPU.) image description

Please let me know how to resolve this issue! I really need your help! Thank you!!!

However, when I int a=image.type(); the value of a is 21. not CV_32F.

using namespace cv; using namespace std; int main(void) {

// read kernel from text file
int kernel_size=15;
ifstream fin;
fin.open ("PSF00.txt"); 

float kernel0[15][15];
for (int i=0; i<kernel_size; i++)
{
    for (int j=0; j<kernel_size; j++)
    {
        fin >> kernel0[i][j];
    }
}       

// Save 2D Kernel array into MAT format
Mat kernel = Mat(kernel_size, kernel_size, CV_32F, kernel0);    

// load image
Mat image = imread("blurry_00.jpg");        
image.convertTo(image, CV_32F);         

// GPU
gpu::GpuMat gpu_input, gpu_input1, gpu_output, gpu_kernel;

gpu_input.upload(image);
gpu_kernel.upload(kernel);

gpu_input.convertTo(gpu_input1, CV_32F);    

gpu::convolve(gpu_input1, gpu_kernel, gpu_output);  

// Download image from GPU to CPU
Mat dst(gpu_output);                
dst.convertTo(dst, CV_8U);

// Create a window for display.
namedWindow( "Display window (GPU)", WINDOW_AUTOSIZE );
imshow( "Display window (GPU)", dst );

waitKey(0);
return 0;

}

edit retag flag offensive close merge delete