闪烁轮廓线 [英] Blinking contour line
问题描述
我发现当最大的轮廓(aka largest_contours > code>在我的程序中),轮廓的轮廓线将闪烁,并且
有时将中断该函数以在其周围绘制一条红线(因为轮廓线不再连接,轮廓检测图像内)。
我的问题是:
- 发生这个问题的原因是什么?
- 如何避免(或者我们可以避免)这个问题发生?
- 任何改善轮廓检测程序的建议?
>
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:
- What is the reason for this problem to happen?
- How to avoid (or can we avoid) this problem from happening?
- 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屋!