예제 #1
0
 public Kinect1Backend()
 {
     this.sensors = new Kinect1Data[KinectSensor.KinectSensors.Count];
     for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
     {
         Kinect1Data sensor = new Kinect1Data(KinectSensor.KinectSensors[i]);
         if (sensor.IsUsable())
         {
             this.sensors[i] = sensor;
         }
         this.totalSensors += 1;
     }
 }
예제 #2
0
        public Position GetRawJoint(int sensor, int skeleton, RawJointName id)
        {
            if (sensor < 0)
            {
                return(Position.Invalid);
            }
            else if (sensor < this.kv1.GetUsableKinectCount())
            {
                Kinect1Data kinect = this.kv1.GetKinect(sensor);
                if (kinect == null)
                {
                    return(Position.Invalid);
                }
                switch (id)   // TODO: Move these to kv1 and kv2, make both extend a shared interface
                {
                case RawJointName.HandLeft1: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.HandLeft1)));

                case RawJointName.HandLeft2: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.HandLeft2)));

                case RawJointName.HandRight1: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.HandRight1)));

                case RawJointName.HandRight2: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.HandRight2)));

                case RawJointName.Head1: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.Head1)));

                case RawJointName.Head2: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.Head2)));

                case RawJointName.FootLeft1: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.FootLeft1)));

                case RawJointName.FootLeft2: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.FootLeft2)));

                case RawJointName.FootLeftHigh: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.FootLeftHigh)));

                case RawJointName.FootRight1: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.FootRight1)));

                case RawJointName.FootRight2: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.FootRight2)));

                case RawJointName.FootRightHigh: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.FootRightHigh)));

                case RawJointName.Hip1: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.Hip1)));

                case RawJointName.Hip2: return(new Position(kinect.GetJoint(skeleton, Kinect1JointName.Hip2)));

                default: return(Position.Invalid);
                }
            }
            else if (sensor < this.kv1.GetUsableKinectCount() + this.kv2.GetUsableKinectCount())
            {
                Kinect2Data kinect = this.kv2.GetKinect(sensor);
                if (kinect == null)
                {
                    return(Position.Invalid);
                }
                switch (id)
                {
                case RawJointName.HandLeft1: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.HandLeft1)));

                case RawJointName.HandLeft2: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.HandLeft2)));

                case RawJointName.HandRight1: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.HandRight1)));

                case RawJointName.HandRight2: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.HandRight2)));

                case RawJointName.Head1: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.Head1)));

                case RawJointName.Head2: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.Head2)));

                case RawJointName.FootLeft1: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.FootLeft1)));

                case RawJointName.FootLeft2: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.FootLeft2)));

                case RawJointName.FootLeftHigh: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.FootLeftHigh)));

                case RawJointName.FootRight1: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.FootRight1)));

                case RawJointName.FootRight2: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.FootRight2)));

                case RawJointName.FootRightHigh: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.FootRightHigh)));

                case RawJointName.Hip1: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.Hip1)));

                case RawJointName.Hip2: return(new Position(kinect.GetJoint(skeleton, Kinect2JointName.Hip2)));

                default: return(Position.Invalid);
                }
            }
            else
            {
                return(Position.Invalid);
            }
        }