asked 2013-09-29 18:28:55 -0600

lordtchofo gravatar image

i'm trying to compare the computation of histogram on cpu and gpu using gpucv but there's something i don't understand. The results are differents and i don't understand why. this is the code i'm using for gpucv

cv::Mat histImage;

histImage = cvLoadImage(img.toStdString().c_str(), CV_8UC1);

gpu::GpuMat devImage, result;


gpu::calcHist(devImage, result);

Thanks for helping

edit retag flag offensive close merge delete


Could you add your CPU code? And what the difference?

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-09-30 04:20:45 -0600 )edit

Hi. the output of the CPU and the GPU are differents, GPUCV output matrice is full of zeros and i don't understand where my error comes from while using the gpu calcHist

This's the CPU code

selectedImage1 = image;

vector<Mat> bgr_planes1;

split (selectedImage1, bgr_planes1);

int histSize1 = 256;

float range1[] = {0, 256};

const float* histRange1 = {range1};

bool uniform = true; bool accumulate = false;

cv::calcHist(&bgr_planes1[0], 1, 0, Mat(), b_hist1, 1, &histSize1, &histRange1, uniform, accumulate);

cv::calcHist(&bgr_planes1[1], 1, 0, Mat(), g_hist1, 1, &histSize1, &histRange1, uniform, accumulate);

cv::calcHist(&bgr_planes1[2], 1, 0, Mat(), r_hist1, 1, &histSize1, &histRange1, uniform, accumulate);

Thx for helping

lordtchofo gravatar imagelordtchofo ( 2013-09-30 06:51:14 -0600 )edit

Did you check that your image was loaded correctly : assert( !histImage.empty() )?

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-10-01 02:31:18 -0600 )edit

my image is loaded correctly after checking

lordtchofo gravatar imagelordtchofo ( 2013-10-01 17:36:45 -0600 )edit

I am trying the same histCalc on GPU using opencv3.0 so the namespace is cuda::calcHist() rest of the code is same as above but I am getting a runtime error OpenCV Error: The function/feature is not implemented (getGpuMat is available only for cuda::GpuMat and cuda::HostMem) in getGpuMat, file /home/ubuntu/cv/modules/core/src/matrix.cpp, line 1419 terminate called after throwing an instance of 'cv::Exception' what(): /home/ubuntu/cv/modules/core/src/matrix.cpp:1419: error: (-213) getGpuMat is available only for cuda::GpuMat and cuda::HostMem in function getGpuMat

abhiguru gravatar imageabhiguru ( 2015-05-30 09:47:17 -0600 )edit