I am getting a strange result while calculating histogram using cv::cuda::calcHist(). The result what I am getting is an array 256 zeros. This problem is persisting when using CUDA version of calcHist() but not in CPU version cv::calcHist(). Following is the code snap I am utilising.
cv::cuda::GpuMat input_g, gray_img_g, hist_gray_g; // GPU Mat variables
cv::Mat hist_gray_c; // CPU Mat variables
cv::cuda::cvtColor(input_g, gray_img_g, cv::COLOR_BGR2GRAY); // getting gray-scale image
cv::cuda::calcHist(gray_img_g, hist_gray_g); // calculating histogram on GPU
hist_gray_g.download(hist_gray_c); // downloading the histogram to CPU memory
// checking the histogram values
for (int i = 0; i < 256; i++){
std::cout<<hist_gray_c.at<float>(i)<<std::endl;
}