Ask Your Question

Revision history [back]

crash in Mat::release()

Hi, i have a function that create histogram double median_(const cv::Mat& channel) { double m = (channel.rows*channel.cols) / 2; int bin = 0; double med = -1.0;

int histSize = 256;
float range[] = { 0, 256 };
const float* histRange = { range };
bool uniform = true;
bool accumulate = false;
cv::Mat hist;
cv::calcHist(&channel, 1, 0, cv::Mat(), hist, 1, &histSize, &histRange, uniform, accumulate);

for (int i = 0; i < histSize && med < 0.0; ++i)
{
    bin += cvRound(hist.at< float >(i));
    if (bin > m && med < 0.0)
        med = i;
}

hist.release();
return med;

}

Calling hist.release() is crashing. Can someone help please?

crash in Mat::release()

Hi, i I have a function that create histogram creates a histogram:

double median_(const cv::Mat& channel)
{
    double m = (channel.rows*channel.cols) / 2;
    int bin = 0;
    double med = -1.0;

-1.0;

    int histSize = 256;
 float range[] = { 0, 256 };
 const float* histRange = { range };
 bool uniform = true;
 bool accumulate = false;
 cv::Mat hist;
 cv::calcHist(&channel, 1, 0, cv::Mat(), hist, 1, &histSize, &histRange, uniform, accumulate);

 for (int i = 0; i < histSize && med < 0.0; ++i)
 {
     bin += cvRound(hist.at< float >(i));
     if (bin > m && med < 0.0)
         med = i;
 }

 hist.release();
 return med;
}

}

Calling hist.release() is crashing. Can someone help please?