# Problem whit fillConvexPoly bad fill

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:

//...Blue poly already draw...
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?

( 2015-03-06 04:30:49 -0600 )edit

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.

( 2015-03-06 04:55:32 -0600 )edit

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

for(int i=0;i<polyZoneVerse.size();i++)
{
Point rook_points[1][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[1] = { rook_points[0] };
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

my fonction FillPoly dont drow for the moment --' I'll fix that..

( 2015-03-06 09:38:40 -0600 )edit

OK , problem is relsolved . I change fillConvexPoly by FillPoly , its work.

( 2015-03-09 03:55:08 -0600 )edit

Official site

GitHub

Wiki

Documentation