首页 文章

延迟绘制轮廓周围的矩形

提问于
浏览
0

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

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只能识别一次通过的所有轮廓,你仍然可以在一次通过中找到它们,但是只有在逐个绘制它们时才会实现延迟 .

相关问题