1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Fix pointPolygonTest for large coordinate values (#10222)

* Add test that fails

* Fix integer pointPolygonTest for large coordinate values

* Review fixes:
- change type from long long to int64
- move test code to test_contours.cpp, and make it C++98 compliant

* Hopefully fix compiler error by using push_back instead of emplace_back
This commit is contained in:
Juha Reunanen
2017-12-05 14:49:44 +02:00
committed by Vadim Pisarevsky
parent 5ce38e516e
commit 5b41599911
2 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -119,7 +119,6 @@ double cv::pointPolygonTest( InputArray _contour, Point2f pt, bool measureDist )
for( i = 0; i < total; i++ )
{
int dist;
v0 = v;
v = cnt[i];
@@ -133,7 +132,8 @@ double cv::pointPolygonTest( InputArray _contour, Point2f pt, bool measureDist )
continue;
}
dist = (ip.y - v0.y)*(v.x - v0.x) - (ip.x - v0.x)*(v.y - v0.y);
int64 dist = static_cast<int64>(ip.y - v0.y)*(v.x - v0.x)
- static_cast<int64>(ip.x - v0.x)*(v.y - v0.y);
if( dist == 0 )
return 0;
if( v.y < v0.y )