首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用C#和EmguCV进行运动检测

使用C#和EmguCV进行运动检测
EN

Stack Overflow用户
提问于 2016-06-29 01:58:29
回答 1查看 1.2K关注 0票数 0

我是emgucv和光流的新手。我试图在视频中识别运动中的对象,并围绕它们绘制圆形或矩形或其他一些形状。我必须使用opticalflow.HS和opticalflow.LK,这是我想做的第一件事。我使用的是emgu cv2.4.9,我有一些代码,但这只是一些想法。我修改了前一帧和当前帧,并将其发送到opticalflow.HS,但我不知道之后该做什么,我也找不到任何使用HS的示例,所以我真的很感谢同样的示例,在opticalflow.HS之后下一步该做什么以及一些建议。

代码语言:javascript
复制
  private void ProcessFrame(object sender, EventArgs e)
  {
      bool firstFrame = true;
      bool keepProcessing = true;

      Image<Gray, Byte> nextFrame = new Image<Gray, byte>(160, 640);
      Image<Gray, Byte> previousFrame = null;

      while (keepProcessing)
      {
          // ****** Change - Save previous frame before getting next one
          // Only do this if the first frame has passed
          if (!firstFrame)
              previousFrame = nextFrame.Clone();

          // grab the next frame from video source
         // _capture.Grab();

          // decode and return the grabbed video frame
          nextFrame = _capture.RetrieveGrayFrame();

          // if the frame is valid (not end of video for example)
          if (!(nextFrame==null))
          {
              // **** Change - If we are on the first frame, only show that and
              // set the flag to false
              if (firstFrame)
              {
                  firstFrame = false;

              }
              else
              {
                  Image<Gray, float> velx = new Image<Gray, float>(previousFrame.Size);
                  Image<Gray, float> vely = new Image<Gray, float>(nextFrame.Size);
                  OpticalFlow.HS(previousFrame, nextFrame, true, velx, vely, 0.1d, new MCvTermCriteria(100));
                  //capturedImageBox.Image = nextFrame;

              }
          }
          else
          {
              keepProcessing = false;
          }
      }
EN

回答 1

Stack Overflow用户

发布于 2016-06-29 02:24:56

OpticalFlow.HS Method使用Horn & Schunck算法计算第一个输入图像的每个像素的流量。

在此之后,我建议你应该密集的光流图。希望能对你有所帮助。

Go to link.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38083170

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档