/// <summary> /// Update Control Values based on state /// </summary> /// <param name="state">Kinect state</param> private void UpdateControlValuesBasedOnState(kinect.KinectState state) { this.TransformSmooth.IsChecked = state.TransformSmooth; // we don't want to update those fields while user may be typing something if (!this.TiltDegrees.IsFocused) { this.TiltDegrees.Text = ((int)state.TiltDegrees).ToString(); } if (!this.Smoothing.IsFocused) { this.Smoothing.Text = state.SkeletalEngineTransformSmoothParameters.Smoothing.ToString(); } if (!this.Correction.IsFocused) { this.Correction.Text = state.SkeletalEngineTransformSmoothParameters.Correction.ToString(); } if (!this.Prediction.IsFocused) { this.Prediction.Text = state.SkeletalEngineTransformSmoothParameters.Prediction.ToString(); } if (!this.JitterRadius.IsFocused) { this.JitterRadius.Text = state.SkeletalEngineTransformSmoothParameters.JitterRadius.ToString(); } if (!this.MaxDeviationRadius.IsFocused) { this.MaxDeviationRadius.Text = state.SkeletalEngineTransformSmoothParameters.MaxDeviationRadius.ToString(); } }
/// <summary> /// Callback to update UI elements that represent KinectService state(config) such as image resolution, etc /// </summary> /// <param name="state">Kinect state</param> internal void UpdateState(kinect.KinectState state) { this.CalculateEffectiveFrameRate(); this.UpdateControlValuesBasedOnState(state); if (!this.viewUpdatedAtLeastOnce) { this.UpdateImmutableControlsOnFirstStateRead(state); } this.viewUpdatedAtLeastOnce = true; }
/// <summary> /// We want to disable controls that can't be used due to config state (i.e. can't choose to view video if video frame read was not configured) /// </summary> /// <param name="state">Kinect state</param> private void UpdateImmutableControlsOnFirstStateRead(kinect.KinectState state) { if (!state.UseColor) { this.VideImageType.IsEnabled = false; this.VideoCB.IsEnabled = false; this.VideoCB.IsChecked = false; } if (!state.UseSkeletalTracking) { this.SkeletalCB.IsChecked = false; this.SkeletalCB.IsEnabled = false; this.TransformSmooth.IsEnabled = false; this.Smoothing.IsEnabled = false; this.Correction.IsEnabled = false; this.Prediction.IsEnabled = false; this.JitterRadius.IsEnabled = false; this.MaxDeviationRadius.IsEnabled = false; } if (!state.UseDepth) { this.DepthCB.IsChecked = false; this.DepthCB.IsEnabled = false; } this.DeviceID.Text = state.DeviceID.ToString(); this.FrameRate.Text = state.FrameRate.ToString(); this.VideImageType.Text = state.ColorImageFormat.ToString(); this.DepthImageType.Text = state.DepthImageFormat.ToString(); this.DepthCamAlternate.Text = state.IsDepthServiceUpdateEnabled == true ? "yes" : "no"; this.WebCamAlternate.Text = state.IsWebCamServiceUpdateEnabled == true ? "yes" : "no"; // cache the resolution of the color image switch (state.ColorImageFormat) { case ColorImageFormat.RgbResolution1280x960Fps12: KinectUI.ColorImageWidth = 1280; KinectUI.ColorImageHeight = 960; break; case ColorImageFormat.RawYuvResolution640x480Fps15: case ColorImageFormat.RgbResolution640x480Fps30: case ColorImageFormat.YuvResolution640x480Fps15: default: KinectUI.ColorImageWidth = 640; KinectUI.ColorImageHeight = 480; break; } }
/// <summary> /// Initializes this instance. /// </summary> /// <returns>Standard ccr iterator</returns> private IEnumerator <ITask> Initialize() { var located = new PortSet <VisualEntity, Fault>(); SpawnIterator(located, this.LocateCameraEntity); yield return(located.Choice()); var entity = (VisualEntity)located; if (entity == null) { LogError("Kinect entity not found"); StartFailed(); yield break; } this.kinectEntity = (KinectEntity)entity; if (this.state == null) { this.state = new kinect.KinectState { DepthImageFormat = DepthImageFormat.Resolution320x240Fps30, FrameRate = MaxFramesPerSec, IsDepthServiceUpdateEnabled = true, IsWebCamServiceUpdateEnabled = true, UseColor = true, UseDepth = true, UseSkeletalTracking = false, ColorImageFormat = ColorImageFormat.RgbResolution640x480Fps30 }; SaveState(this.state); } this.panTiltState = InitialPanTiltState(); base.Start(); MainPortInterleave.CombineWith( new Interleave( new ExclusiveReceiverGroup( Arbiter.ReceiveWithIterator(true, this.pollPort, this.DrainPendingRequests)), new ConcurrentReceiverGroup())); this.kinectOps.Post(new kinect.SetFrameRate(new kinect.SetFrameRateRequest(this.state.FrameRate))); }
/// <summary> /// Update the kinect state on the UI /// </summary> /// <param name="kinectState">Kinect State</param> private void UpdateState(kinectProxy.KinectState kinectState) { this.wpfServicePort.Invoke(() => this.userInterface.UpdateState(kinectState)); }