【问题标题】:Emgu CV Blob Detection -Video Surveillance ExampleEmgu CV Blob 检测 - 视频监控示例
【发布时间】:2014-03-28 02:17:28
【问题描述】:

我正在尝试执行非常基本的 blob 检测,但没有成功。只需使用 VideoSurveillance 示例...它编译并运行良好,但实际上根本没有检测到 blob。 FGDetector 似乎工作得很好,所以我似乎得到了一个很好的前景,但 BlobTrackerAuto.Process 几乎不会导致发现一个斑点……即使前景蒙版图像中似乎有一个非常突出的斑点。这是一段代码 sn-p,展示了我如何捕获和处理图像。

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 检测(阈值设置?),以便它知道如何区分前景和背景。

任何建议将不胜感激。

【问题讨论】:

    标签: opencv blob detection emgucv


    【解决方案1】:
    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;
      }
    

    【讨论】:

    • 虽然此代码 sn-p 可能是解决方案,但 including an explanation 确实有助于提高您的帖子质量。请记住,您是在为将来的读者回答问题,而这些人可能不知道您提出代码建议的原因。
    猜你喜欢
    • 2011-09-04
    • 1970-01-01
    • 2016-11-10
    • 2015-05-17
    • 2015-09-21
    • 2018-08-28
    • 2012-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多