Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV CUDA - method that works like inRange()

I have a image in BGR color space and I convert it in HSV color space. I want to find a method that works on GPU like inRange works on CPU to binarize my image and obtain a threshold. Afer the conversion in HSV colorspace I make a split in three channels. After that I apply threshold() on every channel and finaly call function merge().

The problem is that in the last step i don't get the binary image. The image is colored.

Here is my code

gpu::cvtColor(myFrame_device, myFrameHSV_device, COLOR_BGR2HSV);
gpu::GpuMat channels_device[3];
gpu::GpuMat channels_device_dest[3];
gpu::split(myFrameHSV_device, channels_device);
//Mat myFrameEqualizedHSV(myFrameHSV_device);
//threshold HSV
gpu::threshold(channels_device[0], channels_device_dest[0], 0, 225, THRESH_BINARY);
gpu::threshold(channels_device[1], channels_device_dest[1], 75, 225, THRESH_BINARY);
gpu::threshold(channels_device[2], channels_device_dest[2], 0, 225, THRESH_BINARY);
gpu::merge(channels_device_dest,3, threshold_device);
click to hide/show revision 2
retagged

updated 2016-04-01 03:03:01 -0600

berak gravatar image

OpenCV CUDA - method that works like inRange()

I have a image in BGR color space and I convert it in HSV color space. I want to find a method that works on GPU like inRange works on CPU to binarize my image and obtain a threshold. Afer the conversion in HSV colorspace I make a split in three channels. After that I apply threshold() on every channel and finaly call function merge().

The problem is that in the last step i don't get the binary image. The image is colored.

Here is my code

gpu::cvtColor(myFrame_device, myFrameHSV_device, COLOR_BGR2HSV);
gpu::GpuMat channels_device[3];
gpu::GpuMat channels_device_dest[3];
gpu::split(myFrameHSV_device, channels_device);
//Mat myFrameEqualizedHSV(myFrameHSV_device);
//threshold HSV
gpu::threshold(channels_device[0], channels_device_dest[0], 0, 225, THRESH_BINARY);
gpu::threshold(channels_device[1], channels_device_dest[1], 75, 225, THRESH_BINARY);
gpu::threshold(channels_device[2], channels_device_dest[2], 0, 225, THRESH_BINARY);
gpu::merge(channels_device_dest,3, threshold_device);