Ask Your Question
0

Problem whit fillConvexPoly bad fill

asked 2015-03-06 03:03:40 -0500

tonyNoel gravatar image

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: image description

Thank if you can help me =D

[OpenCV 2.4.9.0]

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-03-06 03:32:37 -0500

The polygons you draw are not convex...

edit flag offensive delete link more

Comments

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

tonyNoel gravatar imagetonyNoel ( 2015-03-06 04:30:49 -0500 )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.

FooBar gravatar imageFooBar ( 2015-03-06 04:55:32 -0500 )edit
0

answered 2015-03-06 07:49:04 -0500

tonyNoel gravatar image

updated 2015-03-06 08:02:36 -0500

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)

edit flag offensive delete link more

Comments

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

tonyNoel gravatar imagetonyNoel ( 2015-03-06 09:38:40 -0500 )edit

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

tonyNoel gravatar imagetonyNoel ( 2015-03-09 03:55:08 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-03-06 03:03:40 -0500

Seen: 640 times

Last updated: Mar 06 '15