|
|
@ -301,9 +301,7 @@ double cv::arcLength( InputArray _curve, bool is_closed ) |
|
|
|
CV_Assert( count >= 0 && (depth == CV_32F || depth == CV_32S)); |
|
|
|
CV_Assert( count >= 0 && (depth == CV_32F || depth == CV_32S)); |
|
|
|
double perimeter = 0; |
|
|
|
double perimeter = 0; |
|
|
|
|
|
|
|
|
|
|
|
int i, j = 0; |
|
|
|
int i; |
|
|
|
const int N = 16; |
|
|
|
|
|
|
|
float buf[N]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( count <= 1 ) |
|
|
|
if( count <= 1 ) |
|
|
|
return 0.; |
|
|
|
return 0.; |
|
|
@ -319,15 +317,8 @@ double cv::arcLength( InputArray _curve, bool is_closed ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Point2f p = is_float ? ptf[i] : Point2f((float)pti[i].x,(float)pti[i].y); |
|
|
|
Point2f p = is_float ? ptf[i] : Point2f((float)pti[i].x,(float)pti[i].y); |
|
|
|
float dx = p.x - prev.x, dy = p.y - prev.y; |
|
|
|
float dx = p.x - prev.x, dy = p.y - prev.y; |
|
|
|
buf[j] = dx*dx + dy*dy; |
|
|
|
perimeter += std::sqrt(dx*dx + dy*dy); |
|
|
|
|
|
|
|
|
|
|
|
if( ++j == N || i == count-1 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Mat bufmat(1, j, CV_32F, buf); |
|
|
|
|
|
|
|
sqrt(bufmat, bufmat); |
|
|
|
|
|
|
|
for( ; j > 0; j-- ) |
|
|
|
|
|
|
|
perimeter += buf[j-1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
prev = p; |
|
|
|
prev = p; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|