public KinectNuiService() { if (KinectSensor.KinectSensors.Count == 0) { return; } this.handsRaisingStart = new Dictionary <JointType, DateTime>(); this.handsRaising = new Dictionary <JointType, bool>(); this.handsWaitingToLower = new Dictionary <JointType, bool>(); this.BoundsWidth = .5d; this.BoundsDepth = .5d; this.MinDistanceFromCamera = 1.0d; this.sensor = KinectSensor.KinectSensors[0]; this.sensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(sensor_AllFramesReady); this.initialized = true; var parameters = new TransformSmoothParameters(); parameters.Smoothing = 0.7f; parameters.Correction = 0.9f; parameters.Prediction = 0.5f; parameters.JitterRadius = 0.5f; parameters.MaxDeviationRadius = 0.5f; this.sensor.SkeletonStream.Enable(parameters); this.sensor.SkeletonStream.Enable(); this.sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); this.sensor.Start(); DebugLogWriter.WriteMessage("Kinect initialized."); }
public Root() { logger = new DebugLogWriter(); errLogger = new DebugLogWriter(true); Console.SetOut(logger); Console.SetError(errLogger); }
void CheckRaisedHand(Joint hand, Joint head) { var id = hand.JointType; if (!this.handsRaising.ContainsKey(id)) { this.handsRaising.Add(id, false); } if (!this.handsWaitingToLower.ContainsKey(id)) { this.handsWaitingToLower.Add(id, false); } if (!this.handsRaisingStart.ContainsKey(id)) { this.handsRaisingStart.Add(id, DateTime.MinValue); } // user started raising their hand if (!this.handsRaising[id] & hand.Position.Y >= head.Position.Y) { this.handsRaisingStart[id] = DateTime.Now; this.handsRaising[id] = true; return; } var elapsed = DateTime.Now - this.handsRaisingStart[id]; // user lowered their hand before the time limit if (this.handsRaising[id] & hand.Position.Y < head.Position.Y & elapsed.TotalMilliseconds < RaiseHandMilliseconds) { this.handsRaising[id] = false; return; } // user kept their hand raised until the time limit if (this.handsRaising[id] & elapsed.TotalMilliseconds > RaiseHandMilliseconds & !this.handsWaitingToLower[id]) { this.handsWaitingToLower[id] = true; if (this.UserRaisedHand != null) { DebugLogWriter.WriteMessage("User raised hand with ID '" + id.ToString() + "'"); this.UserRaisedHand(this, new HandRaisedEventArgs() { JointId = id }); } return; } // user lowered their hand after a "raise" was recorded. if (this.handsRaising[id] & this.handsWaitingToLower[id] & hand.Position.Y < head.Position.Y) { this.handsWaitingToLower[id] = false; this.handsRaising[id] = false; return; } }
void LoadWireframes() { var wireframes = this.ViewModel.ScreenLinesCollection; foreach (var wireframe in wireframes) { this.wireVisual.Children.Insert(0, wireframe); } DebugLogWriter.WriteMessage("Wireframes loaded."); }
public static LoggerProvider AddDebug(this LoggerProvider provider, string name = "", string source = "", string format = "", LogLevel minLevel = LogLevel.Info, LogLevel maxLevel = LogLevel.Info, Func <LogEvent, bool> condition = null) { DebugLogWriter writer = new DebugLogWriter { Name = name, Format = format, Source = source, MinLevel = minLevel, MaxLevel = maxLevel, }; if (condition != null) { writer.Condition = condition; } provider.Writers.Add(writer); return(provider); }
public AzureSessionCredential(IAzureContext DefaultContext, DebugLogWriter logWriter = null) { if (DefaultContext == null || DefaultContext.Account == null) { throw new InvalidOperationException(Resources.ContextCannotBeNull); } if (logWriter != null) { this.debugLogWriter = logWriter; } IAccessToken accessToken1 = AzureSession.Instance.AuthenticationFactory.Authenticate( DefaultContext.Account, DefaultContext.Environment, DefaultContext.Tenant.Id, null, ShowDialog.Never, null, AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointResourceId); accessToken = accessToken1; }
public AzureSessionCredential(IAzureContext DefaultContext, DebugLogWriter logWriter = null) { if (DefaultContext == null || DefaultContext.Account == null) { throw new InvalidOperationException(Resources.ContextCannotBeNull); } if (logWriter != null) { this.debugLogWriter = logWriter; } IAccessToken accessToken1 = AzureSession.Instance.AuthenticationFactory.Authenticate( DefaultContext.Account, EnsureStorageOAuthAudienceSet(DefaultContext.Environment), DefaultContext.Tenant.Id, null, ShowDialog.Never, null, StorageOAuthEndpointResourceKey); accessToken = accessToken1; }
void ClearWireframes() { this.wireVisual.Children.Clear(); DebugLogWriter.WriteMessage("Wireframes cleared."); }
void HandleBoundingBoxEnabledMessage(BoundingBoxEnabledMessage message) { this.enabled = message.Enabled; DebugLogWriter.WriteMessage("Bounding box calculations enabled: " + this.enabled.ToString()); }
/// <summary> /// Create a storage context usign cloud storage account /// </summary> /// <param name="account">cloud storage account</param> public AzureStorageContext(CloudStorageAccount account, string accountName = null, IAzureContext DefaultContext = null, DebugLogWriter logWriter = null) { StorageAccount = account; TableStorageAccount = XTable.CloudStorageAccount.Parse(StorageAccount.ToString(true)); if (account.BlobEndpoint != null) { BlobEndPoint = account.BlobEndpoint.ToString(); } if (account.TableEndpoint != null) { TableEndPoint = account.TableEndpoint.ToString(); } if (account.QueueEndpoint != null) { QueueEndPoint = account.QueueEndpoint.ToString(); } if (account.FileEndpoint != null) { FileEndPoint = account.FileEndpoint.ToString(); } StorageAccountName = string.IsNullOrEmpty(accountName) ? (account.Credentials is null ? null : account.Credentials.AccountName) : accountName; Context = this; Name = String.Empty; if (string.IsNullOrEmpty(StorageAccountName)) { if (account.Credentials != null && account.Credentials.IsSAS) { StorageAccountName = "[SasToken]"; } else if (account.Credentials != null && account.Credentials.IsToken) { StorageAccountName = "[AccessToken]"; } else { StorageAccountName = "[Anonymous]"; } } if (account.Credentials != null && account.Credentials.IsToken) { Track2OauthToken = new AzureSessionCredential(DefaultContext, logWriter); } }