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