opencv - Emgu CV Blob 检测 - 视频监控示例

标签 opencv blob detection emgucv

我正在尝试执行非常基本的 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 。

Screen shot from my program

似乎必须有某种方法来配置 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/

相关文章:

javascript - IE 11 : How to Open JavaScript genereted file without Open/Save dialog?

azure - azure blob 存储是否通过网络使用 gzip

c - 金字塔分割 OpenCV

azure - 将 SQL Azure 数据库导出到 blob - Start-AzureSqlDatabaseExport : Cannot convert AzureStorageContainer to AzureStorageContainer

python - 使用 Python OpenCV 从网络摄像头视频中检测白纸上的黑色矩形

javascript - 您如何检测和识别 Javascript/jQuery 冲突?

Linux 内核 Rootkit 示例

python - 无法分割手写字符

python - PyOpenGL,使用 glFrustum 和 glTranslate 在屏幕上出现 3D 图形问题

opencv - 当只有屏幕空间坐标可用时,将世界空间中的正方形扩展为立方体