Unexpected result from cuda::histRange()

asked 2017-03-11 15:27:29 -0600

Flux gravatar image

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?

edit retag flag offensive close merge delete

Comments

I don't think it will solve your problem but you should write cv::cvtColor(image, image, CV_BGR2HSV); instead of cv::cvtColor(image, image, CV_RGB2HSV); and cv::imread("test.png",IMREAD_COLOR);

LBerger gravatar imageLBerger ( 2017-03-11 15:36:22 -0600 )edit