我正在尝试执行非常基本的 blob 检测,但没有成功。只需使用 VideoSurveillance 示例...它编译并运行良好,但实际上根本没有检测到 blob。 FGDetector 似乎工作得很好,所以我似乎得到了一个很好的前景,但 BlobTrackerAuto.Process 几乎不会导致找到一个 blob……即使在 foregroundMask 图像中似乎有一个非常突出的 blob。这是一个代码片段,显示了我如何捕获和处理图像。
void ProcessFrame(object sender, EventArgs e)
{
Image<Bgr, Byte> frame = _cameraCapture.QueryFrame();
frame._SmoothGaussian(3); //filter out noises
_detector.Update(frame);
Image<Gray, Byte> foregroundMask = _detector.ForegroundMask;
_tracker.Process(frame, foregroundMask);
foreach (MCvBlob blob in _tracker)
{
frame.Draw((Rectangle)blob, new Bgr(255.0, 255.0, 255.0), 2);
frame.Draw(blob.ID.ToString(), ref _font, Point.Round(blob.Center), new Bgr(255.0, 255.0, 255.0));
}
Image<Bgr, Byte> frameDisplay = frame.Resize(imageBox1.Width, imageBox1.Height, INTER.CV_INTER_LINEAR, false);
Image<Gray, Byte> fgMaskDisplay = foregroundMask.Resize(imageBox2.Width, imageBox2.Height, INTER.CV_INTER_LINEAR, false);
imageBox1.Image = frameDisplay;
imageBox2.Image = fgMaskDisplay;
}
这是来自程序的示例图像,它显示(在我看来)一个非常明显的未检测到的 Blob 。
似乎必须有某种方法来配置 blob 检测(阈值设置?),以便它知道如何区分前景和背景。
任何建议将不胜感激。
最佳答案
void ProcessFrame(object sender, EventArgs e)
{
Image<Bgr, Byte> frame = _cameraCapture.QueryFrame();
frame._SmoothGaussian(3); //filter out noises
_detector.Update(frame);
Image<Gray, Byte> foregroundMask = _detector.ForegroundMask;
_tracker.Process(frame, foregroundMask);
foreach (MCvBlob blob in _tracker)
{
frame.Draw((Rectangle)blob, new Bgr(255.0, 255.0, 255.0), 2);
frame.Draw(blob.ID.ToString(), ref _font, Point.Round(blob.Center), new Bgr(255.0, 255.0, 255.0));
}
Image<Bgr, Byte> frameDisplay = frame.Resize(imageBox1.Width, imageBox1.Height, INTER.CV_INTER_LINEAR, false);
Image<Gray, Byte> fgMaskDisplay = foregroundMask.Resize(imageBox2.Width, imageBox2.Height, INTER.CV_INTER_LINEAR, false);
imageBox1.Image = frameDisplay;
imageBox2.Image = fgMaskDisplay;
}
关于opencv - Emgu CV Blob 检测 - 视频监控示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22021302/