Opencv如何在应用cv :: findContours和cv :: drawContour后检测矩形的4个角

时间:2014-01-06 18:56:35

标签: c++ opencv rectangles corner-detection

我的问题是我想在使用cvfindcontours后找到4个角的矩形? 这是我的结果:

图像:
enter image description here

如何找到每个矩形的4个角? 我认为建筑功能Cv查找和绘制轮廓有角落的信息,所以我该如何阅读呢?

1 个答案:

答案 0 :(得分:1)

(从here修改)

// Find the rotated rectangles for each contour
vector<cv::RotatedRect> cv::minRect( contours.size() );

for( size_t = 0; i < contours.size(); i++ )
{
    minRect[i] = minAreaRect( cv::Mat(contours[i]) );
}

如果你想要轮廓上的实际点,你可以稍后为每个轮廓找到最接近RotatedRect的每个角的点