From: Alexander Alekhin Date: Wed, 5 Sep 2018 13:16:53 +0000 (+0300) Subject: imgproc: fix Subdiv2D::getTriangleList() X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1^2~567^2~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e70526625f7c801a6876e6acc9598c626294282b;p=platform%2Fupstream%2Fopencv.git imgproc: fix Subdiv2D::getTriangleList() --- diff --git a/modules/imgproc/src/subdivision2d.cpp b/modules/imgproc/src/subdivision2d.cpp index 596806c..6014774 100644 --- a/modules/imgproc/src/subdivision2d.cpp +++ b/modules/imgproc/src/subdivision2d.cpp @@ -758,24 +758,30 @@ void Subdiv2D::getTriangleList(std::vector& triangleList) const triangleList.clear(); int i, total = (int)(qedges.size()*4); std::vector edgemask(total, false); - Rect2f rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); + const bool filterPoints = true; + Rect2f rect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); for( i = 4; i < total; i += 2 ) { if( edgemask[i] ) continue; Point2f a, b, c; - int edge = i; - edgeOrg(edge, &a); - edgemask[edge] = true; - edge = getEdge(edge, NEXT_AROUND_LEFT); - edgeOrg(edge, &b); - edgemask[edge] = true; - edge = getEdge(edge, NEXT_AROUND_LEFT); - edgeOrg(edge, &c); - edgemask[edge] = true; - if( rect.contains(a) && rect.contains(b) && rect.contains(c) ) - triangleList.push_back(Vec6f(a.x, a.y, b.x, b.y, c.x, c.y)); + int edge_a = i; + edgeOrg(edge_a, &a); + if (filterPoints && !rect.contains(a)) + continue; + int edge_b = getEdge(edge_a, NEXT_AROUND_LEFT); + edgeOrg(edge_b, &b); + if (filterPoints && !rect.contains(b)) + continue; + int edge_c = getEdge(edge_b, NEXT_AROUND_LEFT); + edgeOrg(edge_c, &c); + if (filterPoints && !rect.contains(c)) + continue; + edgemask[edge_a] = true; + edgemask[edge_b] = true; + edgemask[edge_c] = true; + triangleList.push_back(Vec6f(a.x, a.y, b.x, b.y, c.x, c.y)); } }