obvious bug in structured edge_detection.cpp , ximgproc,opencv_contrib,opencv 3.0beta
Hello,
There is a access violation bug in gradientHist function of structured edge_detection.cpp in line 184.The specify issue appears when the input Mat src.rows is odd and the specify access violation triggers in line 243. Detai in soure code link:link text
//funtion entry. default pSize =2
static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histogram,
const int nBins, const int pSize, const int gnrmRad)
//leave out some code.
//allocate memory.note the potential bug here when the input Mat src.rows is odd.
phase.create( src.size(), cv::DataType<float>::type );
histogram.create( cv::Size( cvRound(src.size().width/float(pSize)),
cvRound(src.size().height/float(pSize)) ),
CV_MAKETYPE(cv::DataType<float>::type, nBins) );
//leave out some code.....
for (int i = 0; i < phase.rows; ++i)
{
const float *pPhase = phase.ptr<float>(i);
const float *pMagn = magnitude.ptr<float>(i);
float *pHist = histogram.ptr<float>(i/pSize);//specify position of access violation
for (int j = 0; j < phase.cols; ++j)
pHist[cvRound((j/pSize + pPhase[j])*nBins)] += pMagn[j] / CV_SQR(pSize);
}
As to my case.I fixed the bug by modifying the step of allocate memory as follow.
phase.create( src.size(), cv::DataType<float>::type );
histogram.create( cv::Size( cvCeil(src.size().width/float(pSize)),
cvCeil(src.size().height/float(pSize)) ),
CV_MAKETYPE(cv::DataType<float>::type, nBins) );
Hope it helps.
oh, a bug.
now someone has to go and fx it