protected virtual void OnKinectV2StatusChanged(KinectV2StatusEventArgs e) { if (KinectV2StatusChanged != null) { KinectV2StatusChanged(this, e); } }
void KinectV2StatusHelper_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e) { if (KinectV2StatusChanged != null) //Only do this is there are subscribers to the event { KinectV2StatusEventArgs args = new KinectV2StatusEventArgs(); if (e.IsAvailable) { args.Status = KinectBase.KinectStatus.Connected; System.Diagnostics.Debug.WriteLine("Kinect 2 connected (event)."); } else { if (KinectSensor.GetDefault().IsOpen) { args.Status = KinectBase.KinectStatus.NotReady; System.Diagnostics.Debug.WriteLine("Kinect 2 not ready (event)."); } else { args.Status = KinectBase.KinectStatus.Disconnected; System.Diagnostics.Debug.WriteLine("Kinect 2 disconnected (event)."); } } args.KinectNumber = 0; //This is always 0 because the Kinect v2 only supports 1 Kinect args.UniqueKinectID = KinectSensor.GetDefault().UniqueKinectId; OnKinectV2StatusChanged(args); } }
private void realHelper_KinectV2StatusChanged(object sender, KinectV2StatusEventArgs e) { if (StatusChanged != null) { StatusEventArgs args = new StatusEventArgs(); args.KinectNumber = e.KinectNumber; args.Status = e.Status; args.UniqueKinectID = e.UniqueKinectID; StatusChanged(this, args); } }
public static KinectV2StatusEventArgs[] GetAllKinectsStatus() { //For the time being, this will always be an array with one element because of the one Kinect v2 per computer limit KinectV2StatusEventArgs[] statusArray = new KinectV2StatusEventArgs[1]; for (int i = 0; i < 1; i++) { KinectV2StatusEventArgs temp = new KinectV2StatusEventArgs(); temp.KinectNumber = i; KinectSensor tempKinect = KinectSensor.GetDefault(); //It looks like the service can be opened at any time, and only becomes available if there is actually a Kinect attached to the computer temp.UniqueKinectID = tempKinect.UniqueKinectId; if (tempKinect.IsAvailable) { temp.Status = KinectBase.KinectStatus.Connected; System.Diagnostics.Debug.WriteLine("Kinect 2 connected (static method)."); } else { if (tempKinect.IsOpen) { temp.Status = KinectBase.KinectStatus.NotReady; System.Diagnostics.Debug.WriteLine("Kinect 2 not ready (static method)."); } else { temp.Status = KinectBase.KinectStatus.Disconnected; System.Diagnostics.Debug.WriteLine("Kinect 2 disconnected (static method)."); } } statusArray[i] = temp; } return(statusArray); }
public static KinectV2StatusEventArgs[] GetAllKinectsStatus() { //For the time being, this will always be an array with one element because of the one Kinect v2 per computer limit KinectV2StatusEventArgs[] statusArray = new KinectV2StatusEventArgs[1]; for (int i = 0; i < 1; i++) { KinectV2StatusEventArgs temp = new KinectV2StatusEventArgs(); temp.KinectNumber = i; KinectSensor tempKinect = KinectSensor.GetDefault(); //It looks like the service can be opened at any time, and only becomes available if there is actually a Kinect attached to the computer temp.UniqueKinectID = tempKinect.UniqueKinectId; if (tempKinect.IsAvailable) { temp.Status = KinectBase.KinectStatus.Connected; System.Diagnostics.Debug.WriteLine("Kinect 2 connected (static method)."); } else { if (tempKinect.IsOpen) { temp.Status = KinectBase.KinectStatus.NotReady; System.Diagnostics.Debug.WriteLine("Kinect 2 not ready (static method)."); } else { temp.Status = KinectBase.KinectStatus.Disconnected; System.Diagnostics.Debug.WriteLine("Kinect 2 disconnected (static method)."); } } statusArray[i] = temp; } return statusArray; }