private void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e) { if (KinectV1StatusChanged != null) //Okay, maybe it isn't that much work, but we may as well not do it if we don't have to { KinectV1StatusEventArgs args = new KinectV1StatusEventArgs(); args.Status = (KinectBase.KinectStatus)e.Status; //This case SHOULD work because the numbers in the enum are assigned the same int sensorNumber = -1; bool isXbox360Kinect = false; for (int i = 0; i < KinectSensor.KinectSensors.Count; i++) { if (e.Sensor.UniqueKinectId == KinectSensor.KinectSensors[i].UniqueKinectId) { sensorNumber = i; try { ColorCameraSettings test = KinectSensor.KinectSensors[i].ColorStream.CameraSettings; test = null; isXbox360Kinect = false; } catch { isXbox360Kinect = true; } } } args.KinectNumber = sensorNumber; //args.ConnectionID = e.Sensor.DeviceConnectionId; //args.UniqueKinectID = e.Sensor.UniqueKinectId; args.UniqueKinectID = e.Sensor.DeviceConnectionId; args.isXBox360Kinect = isXbox360Kinect; OnKinectV1StatusChanged(args); } }
public static KinectV1StatusEventArgs[] GetAllKinectsStatus() { KinectV1StatusEventArgs[] statusArray = new KinectV1StatusEventArgs[KinectSensor.KinectSensors.Count]; for (int i = 0; i < KinectSensor.KinectSensors.Count; i++) { KinectV1StatusEventArgs temp = new KinectV1StatusEventArgs(); temp.KinectNumber = i; //temp.ConnectionID = KinectSensor.KinectSensors[i].DeviceConnectionId; //temp.UniqueKinectID = KinectSensor.KinectSensors[i].UniqueKinectId; temp.UniqueKinectID = KinectSensor.KinectSensors[i].DeviceConnectionId; temp.Status = (KinectBase.KinectStatus)KinectSensor.KinectSensors[i].Status; //Test each Kinect to see if it is an XBox 360 Kinect bool isXbox360Kinect = false; try { ColorCameraSettings test = KinectSensor.KinectSensors[i].ColorStream.CameraSettings; test = null; isXbox360Kinect = false; } catch { isXbox360Kinect = true; } temp.isXBox360Kinect = isXbox360Kinect; statusArray[i] = temp; } return(statusArray); }
//TODO: Ensure that all initial Kinect settings (like white balance, etc) get set on the actual Kinect for both GUI and console mode private void LaunchKinect() { //Setup default properties if (masterKinectSettings.colorImageMode != KinectBase.ColorImageFormat.Undefined) { kinect.ColorStream.Enable(convertColorImageFormat(masterKinectSettings.colorImageMode)); kinect.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(kinect_ColorFrameReady); isColorStreamOn = true; //Check to see if the Kinect is a Kinect for Windows or a Xbox 360 Kinect so options can be enabled accordingly try { ColorCameraSettings test = kinect.ColorStream.CameraSettings; test = null; isXbox360Kinect = false; } catch { isXbox360Kinect = true; } } if (masterKinectSettings.depthImageMode != KinectBase.DepthImageFormat.Undefined) { //kinect.DepthStream.Enable(); kinect.DepthStream.Enable(convertDepthImageFormat(masterKinectSettings.depthImageMode)); isDepthStreamOn = true; kinect.SkeletonStream.Enable(); //Note, the audio stream MUST be started AFTER this (known issue with SDK v1.7). Currently not an issue as the audio isn't started until the server is launched later in the code. kinect.SkeletonStream.EnableTrackingInNearRange = true; //Explicitly enable depth tracking in near mode (this can be true when the depth mode is near or default, but if it is false, there is no skeleton data in near mode) //Create the skeleton data container if (skeletonHandGrabData == null) { skeletonHandGrabData = new List <HandGrabInfo>(); } else { skeletonHandGrabData.Clear(); } interactStream = new InteractionStream(kinect, new DummyInteractionClient()); kinect.DepthFrameReady += new EventHandler <DepthImageFrameReadyEventArgs>(kinect_DepthFrameReady); kinect.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady); kinect.SkeletonStream.EnableTrackingInNearRange = true; interactStream.InteractionFrameReady += new EventHandler <InteractionFrameReadyEventArgs>(interactStream_InteractionFrameReady); } kinect.Start(); StartUpdateTimer(); }