- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个 CvSeq*,其中包含通过在黑白输入图像上运行 cvFindContors 创建的 CvSeq* 上运行 cvApproxPoly() 创建的多边形。我想访问从 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; 的值得出结论),但我不知道如何访问各个点。请帮忙?
最佳答案
您可以使用 cvGetSeqElem 遍历多边形的顶点。samples/c 中的 squares.c 实现了这个东西。
关于c++ - 检索由 cvApproxPoly() 创建的多边形的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4316952/
我有以下代码片段: int count = (int)sizes.size(); CvPoint2D32f p; CvSeq* seq = cvCreateSeq(CV_SEQ_KIND_GENERI
我有一个 CvSeq*,其中包含通过在黑白输入图像上运行 cvFindContors 创建的 CvSeq* 上运行 cvApproxPoly() 创建的多边形。我想访问从 CvSeq* 返回的每个多边
我正在编写 C(不是 C++)代码来在矩形的轮廓上运行凸包。其(大大简化的)代码如下所示: CvSeq* contours; CvSeq* hull; cvFindContours( img, &co
我是一名优秀的程序员,十分优秀!