【问题标题】:EmguCV - Motion detection not returning anglesEmguCV - 运动检测不返回角度
【发布时间】:2011-10-10 14:21:56
【问题描述】:

我runnng针对视频(文件)的运动检测算法和之后的代码示例运动检测,并试图找到每个部件的角度和整体运动。我得到的运动值背面,与斑点等,但各组分的运动方向总是始终为0度或360度,并没有任何意义。还有什么比我做错了?请帮忙,谢谢。

这是构造 P>

_motionHistory = new MotionHistory(
                                              10.0, //in second, the duration of motion history you wants to keep
                                              0.05, //in second, parameter for cvCalcMotionGradient
                                              0.5); //in second, parameter for cvCalcMotionGradient

以下是用于通过运动部件循环的代码:

foreach (MCvConnectedComp comp in motionComponents)
                    {
                        //reject the components that have small area;
                        if (comp.area < 1) continue;

                        // find the angle and motion pixel count of the specific area
                            double angle, motionPixelCount;
                            _motionHistory.MotionInfo(comp.rect, out angle, out motionPixelCount);

                            string motion_direction = GetMotionDescriptor(comp.rect);
Console.writeline (motion_direction);


                    }

                    // find and draw the overall motion angle
                    double overallAngle, overallMotionPixelCount;
                    _motionHistory.MotionInfo(motionMask.ROI, out overallAngle, out overallMotionPixelCount);

和这个,我让我的运动描述角 P>

private string GetMotionDescriptor(Rectangle motionRegion)
        {
            float circleRadius = (motionRegion.Width + motionRegion.Height) >> 2;
            Point center = new Point(motionRegion.X + motionRegion.Width >> 1, motionRegion.Y + motionRegion.Height >> 1);

            int xDirection = (int)(Math.Cos(angle * (Math.PI / 180.0)) * circleRadius);
            int yDirection = (int)(Math.Sin(angle * (Math.PI / 180.0)) * circleRadius);
            //double movementAngle = Math.Atan(xDirection / yDirection) * 180 / Math.PI;
            Point pointOnCircle = new Point(center.X + xDirection, center.Y - yDirection);
            double slope = (double)(pointOnCircle.Y - center.Y)/(double)(pointOnCircle.X - center.X);
            double ang = Math.Atan(slope) * 180/Math.PI;
            return (ang).ToString() + " degrees";
        }

【问题讨论】:

    标签: c# opencv emgucv


    【解决方案1】:

    啊哈!如果有人遇到同样的问题,我找出原因并在此处发布。

    _motionHistory = new MotionHistory(mhi, maxDelta, minDelta); 
    

    应根据帧速率和运动进行调整。诀窍在于 3 个参数 (1) 要保留的运动历史记录,(2) 最大时间增量,(3) 最小时间增量。

    需要以某种方式调整它们以反映您希望捕捉的动作。 希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多