闪烁轮廓线 [英] Blinking contour line

查看:232
本文介绍了闪烁轮廓线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计划目标



我发现当最大的轮廓(aka largest_contours code>在我的程序中),轮廓的轮廓线将闪烁,并且有时将中断该函数以在其周围绘制一条红线(因为轮廓线不再连接,轮廓检测图像内)。



我的问题是:


  1. 发生这个问题的原因是什么?

  2. 如何避免(或者我们可以避免)这个问题发生?

  3. 任何改善轮廓检测程序的建议?

>

PS:有关代码,图片和更多信息,请点击 HERE 这里的视频!!!


findContours OpenCV的API修改用于查找轮廓的图像。您可以尝试以下操作。

  Mat displayContours = Mat :: zeros(image.rows,image.cols,CV_8UC1); 
for(int i = 1; i <(int)largest_contours [0] .size(); i ++)
{
line(displayContours,largest_contours [0] [i-1] largest_contours [0] [i],255,2,8,0);
line(image,largest_contours [0] [i-1],largest_contours [0] [i],cv :: Scalar(0,0,255),2,8,0)
}



现在显示 displayContours 而不是 foreground


My program's objective is to identify the largest contour from a video camera and draw it with red line.

I discovered that when the largest contour (aka largest_contours in my program) is detected, the contour's contour line will blink and sometime will interrupt the function to draw a red line around it (because the contour's line is not connected anymore so no more contour detected inside the image).

My questions are:

  1. What is the reason for this problem to happen?
  2. How to avoid (or can we avoid) this problem from happening?
  3. Any suggestions to improve my contour's detection program?

Thanks in advance.

PS: For the codes, pics and more info, click HERE. VIDEO HERE!!!

解决方案

findContours API of OpenCV modifies the image which it uses to find contours.You can try the following.

Mat displayContours = Mat::zeros(image.rows,image.cols,CV_8UC1);
for(int i = 1;i<(int)largest_contours[0].size();i++)
{
   line(displayContours,largest_contours[0][i-1],largest_contours[0][i],255,2,8,0);
   line(image,largest_contours[0][i-1],largest_contours[0][i],cv::Scalar(0,0,255),2,8,0);
}

Now display the displayContours instead of foreground

这篇关于闪烁轮廓线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆