0

我正在写废弃的物体检测器,但我有一个问题。对于找到的每个对象,我想在它周围绘制一个矩形,但延迟 10 秒(查找轮廓 -> 等待 10 秒 -> 在轮廓周围绘制矩形)但我不知道如何实现该延迟。我会很感激你的帮助。

4

1 回答 1

0

C++: void drawContours(InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point() )

contourIdx – 指示要绘制的轮廓的参数。如果为负数,则绘制所有轮廓。

所以你基本上可以这样做:

Find contours here (not shown)

for (int i=0; i < contours.size(); ++i)
{
    drawContours(image,contours, i,...); //the "i" here shows we are drawing just the i-th contour at an iteration.
    cvWaitKey(10000);
}

我很确定 opencv 只能一次识别所有轮廓,您仍然会在一次遍历中找到它们,但是只有在一张一张地绘制它们时才会实现延迟。

于 2013-04-17T16:04:36.443 回答