Ask Your Question

Flux's profile - activity

2017-03-11 15:32:58 -0600 asked a question Unexpected result from cuda::histRange()

I want to calculate a histogram on GPU with the hue channel and 8 bins. This is my code so far:

auto image = cv::imread("test.png");
cv::cvtColor(image, image, CV_RGB2HSV);

cv::cuda::GpuMat d_image;
d_image.upload(image);

cv::cuda::GpuMat d_levels(1, 9, CV_32SC1);
cv::cuda::GpuMat d_hist(1, 8, CV_32SC1);
cv::cuda::Stream histStream;

std::vector<cv::cuda::GpuMat> d_channels;
cv::cuda::split(d_image, d_channels);

cv::cuda::histRange(d_channels[0], d_hist, d_levels, histStream);
histStream.waitForCompletion();

cv::Mat hist;
d_hist.download(hist);
std::cout << "M = " << std::endl << " " << hist << std::endl << std::endl;

The output is: M = [0, 0, 0, 0, 0, 0, 0, 0]. What do I wrong?