使用 OpenCV 跟踪 blob

发布于 2024-10-15 20:28:52 字数 135 浏览 3 评论 0原文


我有一个 EMGU(openCV 包装器)程序,可以从
中减去背景 相机馈送并提取干净的斑点。
现在我需要一些东西来跟踪这些 blob 并为它们分配 ID。
有什么建议/库吗?


谢谢,
SW

I have an EMGU (openCV wrapper) program that subtracts the background from
a camera feed and extracts nice clean blobs.
Now I need something that will track these blobs and assign them with IDs.
Any suggestions/libraries ?

Thanks,
SW

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橪书 2024-10-22 20:28:52

如果您想要跟踪多个对象,您可以尝试粒子过滤器

粒子过滤器基本上是在图像上“处理”粒子,每个粒子都有一定的权重。在每个时间步中,通过将这些权重与当时物体的实际测量值进行比较来更新这些权重。然后,具有高权重的粒子将在其方向上放置更多粒子(在方向上添加轻微的随机部分)以进行下一个时间步骤。
经过几个时间步长后,粒子将聚集在物体测量位置周围。这就是为什么这种方法有时也被称为“适者生存”方法……

所以这整个事情构建了一个循环:

Initialization  ---->      Sampling
                        >             \
                       /               >
                 Updating           Prediction
                      <                /
                       \               <
                          Association

所以这提供了一种在给定场景中跟踪对象的好方法。进行多对象跟踪的一种方法是对所有对象使用这一粒子过滤器,这可以工作,但当您尝试为对象提供 ID 时以及当对象相互交叉时,它会存在缺点,因为粒子云可能会失去一个物体而追随另一个物体。

为了解决这个问题,你可以尝试使用混合粒子过滤器(Vermaak et al. [2003])。这个通过单独的粒子过滤器跟踪每个对象(当然使用较少必要的粒子)。

可以在这里找到一篇关于这方面的好论文: http://www.springerlink.com/content/qn4704415gx65315/
(如果您愿意,我还可以为您提供其他一些相关内容,如果您会说德语,我什至可以为您提供我不久前在我的大学举行的有关此内容的演示)

编辑:

忘记提及:既然你尝试在 OpenCV 中执行此操作:据我所知,Condensation 算法的实现(第一个在整个图像上使用一个粒子过滤器的算法)是 OpenCV 发行版的一部分,尽管它可能已经过时了一点。直接在 OpenCV 中可能有更新的粒子过滤器方法,但如果没有,如果您寻找 OpenCV 和粒子过滤器,您会在 Google 上找到很多结果

希望有帮助...如果没有,请继续询问...

well if you have multiple objects that you would like to track you could try a Particle Filter.

Particle filters basically "disposes" particles on the image which each have a certain weight. In each time step these weights are then updated by comparing them with the actual measured value of the object at that time. Particles with high weight will then dispose more particles in its direction (with adding a slight random part on the direction) for the next time step.
After a few time steps the particles will then group around the objects measured position. That's why this method is sometimes also called Survival of the fittest method...

So this whole thing builds a circle:

Initialization  ---->      Sampling
                        >             \
                       /               >
                 Updating           Prediction
                      <                /
                       \               <
                          Association

So this provides a good method of tracking objects in a given scene. One way to do multi-object tracking would be to use this one particle filter on all the objects, which would work, but has disadvantages when you try to give IDs to the objects and also when the objects cross each other since the particle clouds might lose one object and follow another one.

To solve this you could try a Mixture-Particle-Filter (by Vermaak et al. [2003]). This one tracks each of the objects by an individual Particle filter (with of course less necessary particles).

A good paper on that can be found here: http://www.springerlink.com/content/qn4704415gx65315/
(I can also supply you with several other stuff on that if you like and if you speak German I can even give you a presentation I held about that in my university a while ago)

EDIT:

Forgot to mention: Since you try to do this in OpenCV: as far as I know there is an implementation of the Condensation algorithm (the first one where you use one particle filter on the whole image) is part of the OpenCV distribution, though it might be outdated a bit. There might be newer ways of the particle filter in OpenCV directly but if not you will find a lot of results on Google if you look for OpenCV and particle filters

Hope that helps... if not, please keep asking...

初雪 2024-10-22 20:28:52

您可以简单地改编 EMGU CV 示例之一,该示例利用
视频监控命名空间:

     public partial class VideoSurveilance : Form
       {
          private static MCvFont _font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0);
          private static Capture _cameraCapture;
          private static BlobTrackerAuto<Bgr> _tracker;
          private static IBGFGDetector<Bgr> _detector;
    
          public VideoSurveilance()
          {
             InitializeComponent();
             Run();
          }
    
          void Run()
          {
             try
             {
                _cameraCapture = new Capture();
             }
             catch (Exception e)
             {
                MessageBox.Show(e.Message);
                return;
             }
             
             _detector = new FGDetector<Bgr>(FORGROUND_DETECTOR_TYPE.FGD);
    
             _tracker = new BlobTrackerAuto<Bgr>();
    
             Application.Idle += ProcessFrame;
          }
    
          void ProcessFrame(object sender, EventArgs e)
          {
             Image<Bgr, Byte> frame = _cameraCapture.QueryFrame();
             frame._SmoothGaussian(3); //filter out noises
    
             #region use the background code book model to find the forground mask
             _detector.Update(frame);
             Image<Gray, Byte> forgroundMask = _detector.ForgroundMask;
             #endregion
    
             _tracker.Process(frame, forgroundMask);
    
             foreach (MCvBlob blob in _tracker)
             {
                frame.Draw(Rectangle.Round(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));
             }
    
             imageBox1.Image = frame;
             imageBox2.Image = forgroundMask;
    
          }
       }

You could simply adapt one of the EMGU CV examples that makes use of
VideoSurveillance namespace:

     public partial class VideoSurveilance : Form
       {
          private static MCvFont _font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0);
          private static Capture _cameraCapture;
          private static BlobTrackerAuto<Bgr> _tracker;
          private static IBGFGDetector<Bgr> _detector;
    
          public VideoSurveilance()
          {
             InitializeComponent();
             Run();
          }
    
          void Run()
          {
             try
             {
                _cameraCapture = new Capture();
             }
             catch (Exception e)
             {
                MessageBox.Show(e.Message);
                return;
             }
             
             _detector = new FGDetector<Bgr>(FORGROUND_DETECTOR_TYPE.FGD);
    
             _tracker = new BlobTrackerAuto<Bgr>();
    
             Application.Idle += ProcessFrame;
          }
    
          void ProcessFrame(object sender, EventArgs e)
          {
             Image<Bgr, Byte> frame = _cameraCapture.QueryFrame();
             frame._SmoothGaussian(3); //filter out noises
    
             #region use the background code book model to find the forground mask
             _detector.Update(frame);
             Image<Gray, Byte> forgroundMask = _detector.ForgroundMask;
             #endregion
    
             _tracker.Process(frame, forgroundMask);
    
             foreach (MCvBlob blob in _tracker)
             {
                frame.Draw(Rectangle.Round(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));
             }
    
             imageBox1.Image = frame;
             imageBox2.Image = forgroundMask;
    
          }
       }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文