11/05/2014

Opencv gpu 3 channel blur example

There is no 3 channel blur in gpu function.

gpu::blur is support CV_8UC1 and CV_8UC4  channel only.
gpu::gaussianblur is also not suitable often.

So one of idea is split channel.
split 3 channel and perform blur function for each channel.
and then merge to a blur 3channel image.

this is faster than cpu code(lager image will be faster).

In my case, the process takes cpu :0.0126sec gpu:0.0035sec in 800x600 image.

refer to example source code.


...
//gpu case
gpu::resize(o_frame_gpu, r_frame_gpu, Size(RWIDTH, RHEIGHT) );
vector< gpu::GpuMat> gpurgb(3);
vector< gpu::GpuMat> gpurgb2(3);
gpu::split(r_frame_gpu, gpurgb);
gpu::blur(gpurgb[0], gpurgb2[0], Size(3,3) );
gpu::blur(gpurgb[1], gpurgb2[1], Size(3,3) );
gpu::blur(gpurgb[2], gpurgb2[2], Size(3,3) );
gpu::merge(gpurgb2, r_frame_blur_gpu);

//cpu case
resize(o_frame, rFrame, Size(RWIDTH, RHEIGHT) );
blur(rFrame, blurFrame, Size(3,3));



...


No comments:

Post a Comment