【发布时间】:2010-11-30 18:07:32
【问题描述】:
我有一个 CvSeq*,其中包含通过在 CvSeq* 上运行 cvApproxPoly() 创建的多边形,该 CvSeq* 是通过在黑白输入图像上运行 cvFindContors 创建的。我想访问从 CvSeq* 返回的每个多边形的 CvPoints。到目前为止的代码如下(outlines 是一个包含黑白输入图像的 IplImage):
//create pointers to store data we're going to be calculating
CvMemStorage* storage = cvCreateMemStorage();
CvSeq* first_contour = NULL;
CvSeq* first_polygon = NULL;
//find the contours (edges) of the silhouette, in terms of pixels.
cvFindContours( &outlines,
storage,
&first_contour,
sizeof(CvContour),
CV_RETR_LIST );
//convert the pixel contours to line segments in a polygon.
first_polygon = cvApproxPoly(first_contour,
sizeof(CvContour),
storage,
CV_POLY_APPROX_DP,
2,
1);
我可以使用 cvDrawContour 将多边形绘制到图像上,但我想遍历定义每个轮廓的每个 2D 点。看起来 CvSeq* first_polygon 的每个元素都包含单个多边形的点集(根据 first_polygon->total 的值得出结论;但我不知道如何访问各个点。请帮忙?
【问题讨论】:
标签: c++ opencv computer-vision