Ask Your Question
0

Nvdia Cuda gpu implementation and filters with opencv

asked 2018-01-11 01:09:28 -0500

esconda gravatar image

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;

}

edit retag flag offensive close merge delete

Comments

Have you read this post ?

LBerger gravatar imageLBerger ( 2018-01-11 01:46:34 -0500 )edit

I read this before but unfortunately I don't know how to make these gpu configurations for VS 2015

esconda gravatar imageesconda ( 2018-01-11 01:57:53 -0500 )edit

I think it is in cmake variable CUDA_ARCH_BIN. You should use cmake_gui to set this variables

LBerger gravatar imageLBerger ( 2018-01-11 02:04:22 -0500 )edit
2

I will try to find it out and inform you here, Thank you.

esconda gravatar imageesconda ( 2018-01-11 02:22:37 -0500 )edit
2

LBerger, I solved it using Cuda 8.0 according to architecture compability of my graphic card.Thank you so much.

esconda gravatar imageesconda ( 2018-01-15 07:20:46 -0500 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2018-01-15 07:09:50 -0500

esconda gravatar image

According to my research the problem was on the architecture version of cuda.Thanks to LBerger, he directed me to find the solution checking version of the architecture.My Nvdia graphic card was "Nvdia Geforce gtx 550m" and I checked directly compatibility of this graphic card from the list which is avaliable in https://en.wikipedia.org/wiki/CUDA

According to the list, my Nvdia graphic was compatable on fermi version 2.1 and it was available on CUDA 8.0

CUDA SDK 8.0 support for compute capability 2.0 – 6.x (Fermi, Kepler, Maxwell, Pascal), last version with support for Compute Capability 2.x (Fermi)

Then I direcly removed Cuda 9.1 version from my computer and installed Cuda 8.0 . I was able to run my cuda implementation After building Cmake documents with Cuda 8.0.All algorithms and Cuda filters are working correctly now.

Thank you for your interest,

edit flag offensive delete link more

Comments

there is @mshabunincomment too : here

LBerger gravatar imageLBerger ( 2018-01-15 07:19:50 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-01-11 01:09:28 -0500

Seen: 384 times

Last updated: Jan 15