Ask Your Question

Revision history [back]

Gpu API call <misaligned adress="">

Hi erverybody, I have a little question, which I hope you can help me with:

I just started working with Cuda over OpenCV. As a part of my algorithm I need to calculate the Histogram of a certain region around each pixel.

So, I upload my image (1600*1600) to the gpu memory via

gpu_MainImage = new GpuMat();
gpu_MainImage->upload(*m_myImageStruct->mainImage);

Then, for every Pixel, that is far away from the border to have enough space around him, I call:

inline vector<float>* m_Histogram(const GpuMat *tmpGpuMat, const Range *myRowRange, const Range *myColRange)
{
    GpuMat GpuDest;
    GpuMat pgu_partImage(*tmpGpuMat, *myRowRange,*myColRange);

    cv::cuda::calcHist(pgu_partImage,GpuDest);

    Mat* tmpMat = new Mat();
    GpuDest.download(*tmpMat);
    vector<float> *returnVector = new vector<float>(*tmpMat);
    normalize(*returnVector, *returnVector, 0, 1, NORM_MINMAX);

    return returnVector;
}

This works fine for the first pixel, but crashes for the second pixel, saying:

OpenCV Error: Gpu API call <misaligned adress=""> in hist::histogram256, file E:/....../src/cuda/hist.cu, line 106

Now, I kind of understand, that the adress of every object has to be a multiple of 8, but I dont know how to make sure of that. Can someone explain to me why the error occurses and how I can fix it?