/// <summary> /// Draws the image captured from the camera. /// </summary> /// <param name="image">The image captured.</param> private void DrawCapturedImage(Affdex.Frame image) { // Update the Image control from the UI thread var result = this.Dispatcher.BeginInvoke((Action)(() => { try { // Update the Image control from the UI thread //cameraDisplay.Source = rtb; cameraDisplay.Source = ConstructImage(image.getBGRByteArray(), image.getWidth(), image.getHeight()); // Allow N successive OnCapture callbacks before the FacePoint drawing canvas gets cleared. if (++DrawSkipCount > 4) { canvas.Faces = new Dictionary<int, Affdex.Face>(); canvas.InvalidateVisual(); DrawSkipCount = 0; } if (image != null) { image.Dispose(); } } catch (Exception ex) { String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message; ShowExceptionAndShutDown(message); } })); }
private void DisplayImageToOffscreenCanvas(Affdex.Frame image) { // Update the Image control from the UI thread var result = this.Dispatcher.BeginInvoke((Action)(() => { try { mCurrentTimeStamp = image.getTimestamp(); // Update the Image control from the UI thread //imgAffdexFaceDisplay.Source = rtb; imgAffdexFaceDisplay.Source = ConstructImage(image.getBGRByteArray(), image.getWidth(), image.getHeight()); // Allow N successive OnCapture callbacks before the FacePoint drawing canvas gets cleared. if (++mFeaturePointsSkipCount > 4) { canvasFacePoints.Children.Clear(); mFeaturePointsSkipCount = 0; } if (image != null) { image.Dispose(); } } catch (Exception ex) { String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message; ShowExceptionAndShutDown(message); } })); }