hello guy, I write program in c++, and on this program I use cv::fillConvexPoly . Sometimes fillConvexPoly draw a good polygone sometimes he don't finsh filling my polygone, and I do not understand why... I put below an example with the algorithm I use

Part of code draw a red poly:

for(int i=0;i<tabVerse.size();i++)
{
//..code..
Point tabPointZone[tabVerse[i].getNbSommet()];
for(int j=0; j<tabVerse[i].getNbSommet(); j++)
{
tabPointZone[j]=tabVerse[i].getTabpt()[j];
}
fillConvexPoly(drawPatern2,tabPointZone,tabVerse[i].getNbSommet(),Scalar(0,0,255));
}

and result: Thank if you can help me =D

[OpenCV 2.4.9.0]

edit retag close merge delete

Sort by » oldest newest most voted

The polygons you draw are not convex...

more

i agree with you but the objetc "sometimes GOOD" isn't convex too, But it's good, you think is lucky?

I guess(!) they use a rather simple and fast algorithm to divide the polygon into triangles which relies on some assumptions that are fulfilled by every convex area, but also by some non-convex areas like the "sometimes Good" one. So, yes, I'd bet on luck.

ok, now to test, I add FillPoly function after FillConvexPoly

for(int i=0;i<polyZoneVerse.size();i++)
{
Point rook_points[polyZoneVerse[i].getNbSommet()];
//..code..
for(int j=0; j<polyZoneVerse[i].getNbSommet(); j++)
{//..code..}
fillConvexPoly(drawPatern2,tabPointZone,polyZoneVerse[i].getNbSommet(),Scalar(255,0,0));
int npt[] = { polyZoneVerse[i].getNbSommet() };
const Point* ppt = { rook_points };
fillPoly(drawPatern2,ppt,npt,1,Scalar(255,0,0));
}

I just add the last line (+parameters required) and I always have poor filling. So i don't think is about convex or non-convex ( I can't show you a result because I'm a new member, so I can't put new comment with photo ^^ must apparently wait 1day)

more