fixed compile warnings and opencv_perf_imgproc failures

pull/482/head
Vadim Pisarevsky 12 years ago
parent 944588e732
commit 16d825adbc
  1. 7
      modules/imgproc/perf/perf_houghLines.cpp
  2. 2
      modules/imgproc/src/distransform.cpp
  3. 24
      modules/imgproc/src/hough.cpp
  4. 2
      modules/imgproc/src/samplers.cpp

@ -31,11 +31,12 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
Canny(image, image, 0, 0); Canny(image, image, 0, 0);
Mat lines; Mat lines_t, lines;
declare.time(60); declare.time(60);
TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, threshold); TEST_CYCLE() HoughLines(image, lines_t, rhoStep, thetaStep, threshold);
transpose(lines, lines); if( !lines_t.empty() )
transpose(lines_t, lines);
SANITY_CHECK(lines); SANITY_CHECK(lines);
} }

@ -766,7 +766,7 @@ icvDistanceATS_L1_8u( const cv::Mat& src, cv::Mat& dst )
CV_IMPL void CV_IMPL void
cvDistTransform( const void* srcarr, void* dstarr, cvDistTransform( const void* srcarr, void* dstarr,
int distType, int maskSize, int distType, int maskSize,
const float *mask, const float * /*mask*/,
void* labelsarr, int labelType ) void* labelsarr, int labelType )
{ {
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr); cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);

@ -88,10 +88,10 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
int numrho = cvRound(((width + height) * 2 + 1) / rho); int numrho = cvRound(((width + height) * 2 + 1) / rho);
AutoBuffer<int> _accum((numangle+2) * (numrho+2)); AutoBuffer<int> _accum((numangle+2) * (numrho+2));
AutoBuffer<int> _sort_buf(numangle * numrho); vector<int> _sort_buf;
AutoBuffer<float> _tabSin(numangle); AutoBuffer<float> _tabSin(numangle);
AutoBuffer<float> _tabCos(numangle); AutoBuffer<float> _tabCos(numangle);
int *accum = _accum, *sort_buf = _sort_buf; int *accum = _accum;
float *tabSin = _tabSin, *tabCos = _tabCos; float *tabSin = _tabSin, *tabCos = _tabCos;
memset( accum, 0, sizeof(accum[0]) * (numangle+2) * (numrho+2) ); memset( accum, 0, sizeof(accum[0]) * (numangle+2) * (numrho+2) );
@ -124,19 +124,19 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
if( accum[base] > threshold && if( accum[base] > threshold &&
accum[base] > accum[base - 1] && accum[base] >= accum[base + 1] && accum[base] > accum[base - 1] && accum[base] >= accum[base + 1] &&
accum[base] > accum[base - numrho - 2] && accum[base] >= accum[base + numrho + 2] ) accum[base] > accum[base - numrho - 2] && accum[base] >= accum[base + numrho + 2] )
sort_buf[total++] = base; _sort_buf.push_back(base);
} }
// stage 3. sort the detected lines by accumulator value // stage 3. sort the detected lines by accumulator value
std::sort( sort_buf, sort_buf + total, hough_cmp_gt(accum)); cv::sort(_sort_buf, hough_cmp_gt(accum));
// stage 4. store the first min(total,linesMax) lines to the output buffer // stage 4. store the first min(total,linesMax) lines to the output buffer
linesMax = MIN(linesMax, total); linesMax = min(linesMax, (int)_sort_buf.size());
double scale = 1./(numrho+2); double scale = 1./(numrho+2);
for( i = 0; i < linesMax; i++ ) for( i = 0; i < linesMax; i++ )
{ {
LinePolar line; LinePolar line;
int idx = sort_buf[i]; int idx = _sort_buf[i];
int n = cvFloor(idx*scale) - 1; int n = cvFloor(idx*scale) - 1;
int r = idx - (n+1)*(numrho+2) - 1; int r = idx - (n+1)*(numrho+2) - 1;
line.rho = (r - (numrho - 1)*0.5f) * rho; line.rho = (r - (numrho - 1)*0.5f) * rho;
@ -362,11 +362,11 @@ HoughLinesSDiv( const Mat& img,
} }
} }
for( size_t i = 0; i < lst.size(); i++ ) for( size_t idx = 0; idx < lst.size(); idx++ )
{ {
if( lst[i].rho < 0 ) if( lst[idx].rho < 0 )
continue; continue;
lines.push_back(Vec2f(lst[i].rho, lst[i].theta)); lines.push_back(Vec2f(lst[idx].rho, lst[idx].theta));
} }
} }
@ -604,9 +604,9 @@ void cv::HoughLines( InputArray _image, OutputArray _lines,
vector<Vec2f> lines; vector<Vec2f> lines;
if( srn == 0 && stn == 0 ) if( srn == 0 && stn == 0 )
HoughLinesStandard(image, rho, theta, threshold, lines, INT_MAX); HoughLinesStandard(image, (float)rho, (float)theta, threshold, lines, INT_MAX);
else else
HoughLinesSDiv(image, rho, theta, threshold, srn, stn, lines, INT_MAX); HoughLinesSDiv(image, (float)rho, (float)theta, threshold, (float)srn, (float)stn, lines, INT_MAX);
Mat(lines).copyTo(_lines); Mat(lines).copyTo(_lines);
} }
@ -618,7 +618,7 @@ void cv::HoughLinesP(InputArray _image, OutputArray _lines,
{ {
Mat image = _image.getMat(); Mat image = _image.getMat();
vector<Vec4i> lines; vector<Vec4i> lines;
HoughLinesProbabilistic(image, rho, theta, threshold, minLineLength, maxGap, lines, INT_MAX); HoughLinesProbabilistic(image, (float)rho, (float)theta, threshold, cvRound(minLineLength), cvRound(maxGap), lines, INT_MAX);
Mat(lines).copyTo(_lines); Mat(lines).copyTo(_lines);
} }

@ -205,7 +205,7 @@ void getRectSubPix_Cn_(const _Tp* src, int src_step, Size src_size,
for( j = r.x*cn; j < r.width*cn; j++ ) for( j = r.x*cn; j < r.width*cn; j++ )
{ {
_WTp s0 = src[j]*a11 + src[j+cn]*a12 + src2[j]*a21 + src2[j+cn]*a22; s0 = src[j]*a11 + src[j+cn]*a12 + src2[j]*a21 + src2[j+cn]*a22;
dst[j] = cast_op(s0); dst[j] = cast_op(s0);
} }

Loading…
Cancel
Save