我通过以下方式检测到一个矩形:
- 寻找轮廓
- 近似多边形
然后我试着找到矩形的角:
imgPoints[0]=contours_poly[i][0];
imgPoints[1]=contours_poly[i][1];
imgPoints[3]=contours_poly[i][3];
imgPoints[2]=contours_poly[i][2];
由于引用点,我想以预定义的顺序排列这些点。假设我想从点 0 开始,我该如何订购 以前的点?
最佳答案
如果计算从点 0
到点 x
和 y
的 vector ,它们的 cross product会告诉你 vector 更逆时针。
代码示例 was given in the question "Sort four points in the clockwise order" .
关于c++ - 轮廓的排序点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10539656/