contour coordinate??

82 views
Skip to first unread message

Heba

unread,
Aug 1, 2012, 2:26:11 PM8/1/12
to cvb...@googlegroups.com
 how to get contour coordinate  not the rectangle coordinate
as i have found it->second->contour.startingPoint.x which get only 1 corner 
and i want the 4 corners 

,can any one help me??





Message has been deleted

Cristóbal

unread,
Aug 4, 2012, 6:22:08 AM8/4/12
to cvb...@googlegroups.com
Hi,

When the blobs are extracted the contours are stored in chain codes format. So, firstly you must use "cvConvertChainCodesToPolygon" to convert to a list of vertex. The problem is this polygon will be a lot of vertex so you will need to simplify, for example:

      CvContourPolygon *polygon = cvConvertChainCodesToPolygon(it->second->contour);
      CvContourPolygon *sPolygon = cvSimplifyPolygon(polygon, 5.);

Then, you can iterate trough the vertex:

      CvContourPolygon::const_iterator it=sPolygon->begin();

      if (it!=contour->end())
      {
        x = it->x;
        y = it->y;         // ...
      }

I hope the code is almost right ;)

Best,

Cristóbal
Reply all
Reply to author
Forward
0 new messages