Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit192f0d6

Browse files
authored
Merge pull request#28149 from vrabaud:rotacli
Increase minAreaRect accuracy
2 parents5599da1 +4d7ce37 commit192f0d6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

‎modules/imgproc/src/rotcalipers.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ cv::RotatedRect cv::minAreaRect( InputArray _points )
365365
Mat hull;
366366
Point2f out[3];
367367
RotatedRect box;
368-
box.angle = -(float)CV_PI /2;// default angle for box without rotation and single point
368+
doubleangle = -CV_PI /2;// default angle for box without rotation and single point
369369

370370
staticconstbool clockwise =false;
371371
convexHull(_points, hull, clockwise,true);
@@ -390,7 +390,7 @@ cv::RotatedRect cv::minAreaRect( InputArray _points )
390390
if (out[1].x ==0.f && out[1].y >0.f)
391391
std::swap(box.size.width, box.size.height);
392392
else
393-
box.angle+= (float)atan2( (double)out[1].y, (double)out[1].x );
393+
angle= -atan2( (double)out[1].x, (double)out[1].y );
394394
}
395395
elseif( n ==2 )
396396
{
@@ -406,12 +406,12 @@ cv::RotatedRect cv::minAreaRect( InputArray _points )
406406
}
407407
elseif (dy <0)
408408
{
409-
box.angle =(float)atan2( dy, dx );
409+
angle =atan2( dy, dx );
410410
std::swap(box.size.width, box.size.height);
411411
}
412412
elseif (dy >0)
413413
{
414-
box.angle+= (float)atan2(dy, dx );
414+
angle= -atan2(dx, dy );
415415
}
416416
}
417417
else
@@ -420,7 +420,7 @@ cv::RotatedRect cv::minAreaRect( InputArray _points )
420420
box.center = hpoints[0];
421421
}
422422

423-
box.angle = (float)(box.angle*180/CV_PI);
423+
box.angle = (float)(angle*180/CV_PI);
424424
CV_DbgCheckGE(box.angle, -90.0f,"");
425425
CV_DbgCheckLT(box.angle,0.0f,"");
426426
return box;

‎modules/imgproc/test/test_convhull.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ INSTANTIATE_TEST_CASE_P(Imgproc, minAreaRect_of_line,
12791279
testing::Values(
12801280
std::make_tuple(Point2f(10,15), Point2f(10,25), Point2f(10,20), Size2f(10,0), -90.f),
12811281
std::make_tuple(Point2f(450,500), Point2f(508,500), Point2f(479,500), Size2f(0,58), -90.f),
1282-
std::make_tuple(Point2f(10,20), Point2f(13,16), Point2f(11.5,18), Size2f(5,0), -53.1301002f),
1282+
std::make_tuple(Point2f(10,20), Point2f(13,16), Point2f(11.5,18), Size2f(5,0), -53.1301041f),
12831283
std::make_tuple(Point2f(9,19), Point2f(4,7), Point2f(6.5,13), Size2f(0,13), -22.6198654f)
12841284
));
12851285

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp