I just would like to inform you that according to performance criteria i would like to transfer image processing algorithms from CPU to GPU.Therefore I will be able to run it faster in high resolution image(I hope)
But unfortunately ı get some errors using filters in cuda::filter
implementation.First of all I use videostream to get image continously by using normal Mat variable.Then I convert it to GpuMat using Gpumat.upload(Mat)
function and i call sobel filter function using GpuMat operations.
But unfortunately there is an error indicating after using apply function for filters(I found in Debug) : sobelxfilter->apply(gray_image, sobel_variables[0].Gradx);
The error is :
OpenCV Error: Gpu API call (invalid device symbol) in filter::linearRow, file c:\users\burak.dogancay\desktop\opencv\sources\modules\cudafilters\src\cuda\row_filter.hpp, line 365
I would like to share function that includes the sobel filter operation for clear understanding.
Code :
cuda::GpuMat Morphology::Sobel_operations(cuda::GpuMat& gray_image)
vector<Sobel_variables> sobel_variables(1);
//Sobel_variables sobel_variables;
sobel_variables[0].alpha = 1;
sobel_variables[0].beta = 0.9;
//Apply sobel filter to x
Ptr<cuda::Filter> sobelxfilter=cuda::createSobelFilter(gray_image.type(), sobel_variables[0].ddepth, 1, 0, 3);
sobelxfilter->apply(gray_image, sobel_variables[0].Gradx); **//error occurs after this operation**
//Apply sobel filter to y
Ptr<cuda::Filter> sobelyfilter = cuda::createSobelFilter(gray_image.type(),sobel_variables[0].ddepth, 0, 1, 3);
sobelyfilter->apply(gray_image, sobel_variables[0].Grady);
cuda::subtract(sobel_variables[0].Gradx, sobel_variables[0].Grady, sobel_variables[0].Gradient);
//normalize(sobel_variables[0].Gradient, sobel_variables[0].Gradient, 1, 0, NORM_MINMAX);
//convertScaleAbs(sobel_variables[0].Gradient, sobel_variables[0].Gradient);
cuda::add(sobel_variables[0].Grady, sobel_variables[0].Gradx, sobel_variables[0].Gradient1);
//convertScaleAbs(sobel_variables[0].Gradient1, sobel_variables[0].Gradient1);//It can be used but not necessary
cuda::addWeighted(sobel_variables[0].Gradient, sobel_variables[0].alpha, sobel_variables[0].Gradient1, sobel_variables[0].beta, 0, sobel_variables[0].Out_Image);
//Mat cpu_sobeloutimage=Mat(sobel_variables[0].Out_Image);
imshow("Sobel_operations", sobel_variables[0].Out_Image);
//------free memory of all unnecessarry images--------------------------
sobel_variables[0].Gradx.release();
sobel_variables[0].Grady.release();
gray_image.release();
sobel_variables[0].Gradient.release();
sobel_variables[0].Gradient1.release();
return sobel_variables[0].Out_Image;
}