/// <summary> /// Starts the sensor. /// </summary> /// <param name="sources">The sources. (flags)</param> public void StartSensor(KinectSources sources) { this.CurrentSource = sources; // Gets default Sensor if null if (this.kinectSensor == null) { this.kinectSensor = KinectSensor.GetDefault(); } // Initialize body sensor this.BodyCount = this.kinectSensor.BodyFrameSource.BodyCount; this.faceFrameSources = new FaceFrameSource[this.BodyCount]; this.faceFrameReaders = new FaceFrameReader[this.BodyCount]; this.faceFrameResults = new FaceFrameResult[this.BodyCount]; // Coordinate Mapper this.Mapper = this.kinectSensor.CoordinateMapper; if (this.multiSourceFrameReader == null) { var sourcesTemp = sources; if (sourcesTemp.HasFlag(KinectSources.Face)) { sourcesTemp -= KinectSources.Face; } this.multiSourceFrameReader = this.kinectSensor.OpenMultiSourceFrameReader((FrameSourceTypes)sourcesTemp); this.multiSourceFrameReader.MultiSourceFrameArrived -= this.MultiSourceFrameReaderHandler; this.multiSourceFrameReader.MultiSourceFrameArrived += this.MultiSourceFrameReaderHandler; } if (sources.HasFlag(KinectSources.Face)) { for (int i = 0; i < this.BodyCount; i++) { this.faceFrameSources[i] = new FaceFrameSource(this.kinectSensor, 0, faceFrameFeatures); this.faceFrameReaders[i] = this.faceFrameSources[i].OpenReader(); this.faceFrameReaders[i].FrameArrived -= this.KinectServiceFaceFrameArrived; this.faceFrameReaders[i].FrameArrived += this.KinectServiceFaceFrameArrived; } } // Open Sensor this.kinectSensor.Open(); }
/// <summary> /// Initialize default values /// </summary> protected override void DefaultValues() { base.DefaultValues(); this.CurrentSource = KinectSources.Color; // a bone defined as a line between two joints this.bones = new List <Tuple <JointType, JointType> >(); // Torso this.bones.Add(new Tuple <JointType, JointType>(JointType.Head, JointType.Neck)); this.bones.Add(new Tuple <JointType, JointType>(JointType.Neck, JointType.SpineShoulder)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.SpineMid)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineMid, JointType.SpineBase)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineBase, JointType.HipRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineBase, JointType.HipLeft)); // Right Arm this.bones.Add(new Tuple <JointType, JointType>(JointType.ShoulderRight, JointType.ElbowRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.ElbowRight, JointType.WristRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristRight, JointType.HandRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.HandRight, JointType.HandTipRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristRight, JointType.ThumbRight)); // Left Arm this.bones.Add(new Tuple <JointType, JointType>(JointType.ShoulderLeft, JointType.ElbowLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.ElbowLeft, JointType.WristLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristLeft, JointType.HandLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.HandLeft, JointType.HandTipLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristLeft, JointType.ThumbLeft)); // Right Leg this.bones.Add(new Tuple <JointType, JointType>(JointType.HipRight, JointType.KneeRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.KneeRight, JointType.AnkleRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.AnkleRight, JointType.FootRight)); // Left Leg this.bones.Add(new Tuple <JointType, JointType>(JointType.HipLeft, JointType.KneeLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.KneeLeft, JointType.AnkleLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.AnkleLeft, JointType.FootLeft)); }