2013-05-31 3 views
0

나는 사람이 이동 한 거리를 계산하기 위해 Xbox 360 용 Kinect를 사용하는 간단한 프로그램 인 것처럼 보이는 것을 개발하려고합니다. Kinect가 가리킬 공간은 10 x 10입니다. 사용자가 버튼을 누르면 피사체가이 공간을 중심으로 움직입니다. 피사체가 해당 지역의 최종 목적지에 도달하면 사용자는 버튼을 다시 누릅니다. Kinect는 두 피사체가 얼마나 멀리 떨어져 있는지를 출력합니다. 전에 Kinect를 위해 개발 한 적이 없으므로 시작하기가 꽤 어려웠습니다. 내 문제는 내가 거리를 측정하기 위해 무엇을 사용해야하는지 완전히 확신하지 못한다는 것입니다. 나의 연구에서, 나는 물체가 Kinect로부터 떨어져있는 거리를 계산할 수있는 방법을 찾았지만 그 점이 그 것이다.Kinect를 사용하여 이동 거리 계산

+1

어떤 SDK를 사용하십니까? OpenNI (1.54 또는 2.0) 또는 Kinect SDK? – ArturSkowronski

+0

KinectSDK를 사용하고 있습니다. – TeegsD

답변

0

당신이 듣는 것은 직교 비행기를 다루는 간단한 질문입니다. Kinect는 XYZ 공간에 20 개의 관절이 있으며 거리는 미터로 측정됩니다. 이러한 관절에 액세스하려면, 당신은 "트래커"클래스 내부의 이러한 진술이 (당신이 SDK에서 C# 또는 C++를 사용하는 경우이 ... 확실하지 않은 C#을) :

public Tracker(KinectSensor sn, MainWindow win, string fileName) 
     { 
      window = win; 

      sensor = sn; 
      try 
      { 
       sensor.Start(); 
      } 
      catch (IOException) 
      { 
       sensor = null; 
       MessageBox.Show("No Kinect sensor found. Please connect one and restart the application", "*****ERROR*****"); 
       return; 
      } 

      sensor.SkeletonFrameReady += SensorSkeletonFrameReady; //Frame handlers 
      sensor.ColorFrameReady += SensorColorFrameReady; 
      sensor.SkeletonStream.Enable(); 
      sensor.ColorStream.Enable(); 
     } 

이러한 색상에 액세스 및 Kinect에서 골격 스트림. 골격 스트림이 관절을 포함, 그래서 당신은 이러한 진술과 그에 초점 : (하나를 선택 ... (20)가

//Start sending skeleton stream 
     private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) 
     { 
      //Access the skeleton frame 
      using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) 
      { 

       if (skeletonFrame != null) 
       { 
        //Check to see if there is any data in the skeleton 
        if (this.skeletons == null) 

         //Allocate array of skeletons 
         this.skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; 

        //Copy skeletons from this frame 
        skeletonFrame.CopySkeletonDataTo(this.skeletons); 

        //Find first tracked skeleton, if any 
        Skeleton skeleton = this.skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault(); 
        if (skeleton != null) 
        { 
         //Initialize joints 
         ///<summary> 
         ///Joints to be displayed, projected, recorded, etc. 
         ///</summary> 
         Joint leftFoot = skeleton.Joints[JointType.FootLeft]; 
        } 
       } 

따라서, 프로그램의 시작 부분에, 당신이 합작을 선택하도록 항상 것입니다 프로그램을) 실행시 키 넥트 향하게하고 다음 문 같은 자사의 위치 : 끝에

if(skeleton.Joints[JointType.FootLeft].TrackingState == JointTrackingState.Tracked) 
{ 
    double xPosition = skeleton.Joints[JointType.FootLeft].Position.X; 
    double yPosition = skeleton.Joints[JointType.FootLeft].Position.Y; 
    double zPosition = skeleton.Joints[JointType.FootLeft].Position.Z; 
} 

, 당신은 당신이 스트림을 중지하기 전에 약간의 지연을 할 수 있습니다 .. 클릭과 Kinect에서 스트림을 차단할 때까지 어느 정도 시간이 걸립니다. 그런 다음 두 점 사이의 거리를 구하기 위해해야 ​​할 수학을 수행합니다. 지연이 없다면 데카르트 점을 얻을 수 없습니다.