2011-10-10 2 views
0

비디오 (파일)에 대해 모션 샘플링 알고리즘을 실행하고 코드 샘플 모션 감지를 따르고 각 구성 요소의 각도와 전체 동작을 찾으려고합니다. 블롭 (blob) 등으로 모션 값을 다시 얻지 만 각 구성 요소의 동작 방향은 항상 항상 0도 또는 360도이며 의미가 없습니다. 나는 무엇을 잘못 할 수 있 었는가? 도와주세요, 고마워요. EmguCV - 모션 감지가 돌아 오지 않는 각도

다음은 모션 구성 요소를 통해 반복에 대한 코드 생성자

_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); 

그리고 내 움직임 기술자 각도를 얻을 곳이

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"; 
     } 

답변

2

아하! 나는 누군가가 같은 문제에 부딪치고있는 이유와 이유를 알아 냈다. The

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

프레임 속도와 동작을 조정해야합니다. 트릭은 3 개의 매개 변수 (1)을 유지할 동작 기록, (2) 최대 시간 델타, (3) 최소 시간 델타에 있습니다.

캡처하려는 동작을 반영하기 위해 어떤 방식 으로든 조정해야합니다. 도움이 되길 바랍니다.

관련 문제