Esempio n. 1
0
        /// <summary>
        /// Draws the image captured from the camera.
        /// </summary>
        /// <param name="image">The image captured.</param>
        private void DrawCapturedImage(object sender, FaceWatcherEventArgs e)
        {
            // Update the Image control from the UI thread
            var result = this.Dispatcher.BeginInvoke((Action)(() =>
            {
                try
                {
                    Affdex.Frame image = e.Frame;
                    // 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)
                {
                    DataManager.ShowExceptionAndShutDown(ex);
                }
            }));
        }
Esempio n. 2
0
        /// <summary>
        /// Draws the facial analysis captured by Affdex.Detector.
        /// </summary>
        /// <param name="image">The image analyzed.</param>
        /// <param name="faces">The faces found in the image analyzed.</param>
        private void DrawData(object sender, FaceWatcherEventArgs e)
        {
            try
            {
                Affdex.Frame image = e.Frame;
                Dictionary <int, Affdex.Face> faces = e.Faces;

                // Plot Face Points
                if (faces != null)
                {
                    var result = this.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        if ((DataManager.FaceWatcher.Detector != null) && (DataManager.FaceWatcher.Detector.isRunning()))
                        {
                            canvas.Faces = faces;
                            canvas.Width = cameraDisplay.ActualWidth;
                            canvas.Height = cameraDisplay.ActualHeight;
                            canvas.XScale = canvas.Width / image.getWidth();
                            canvas.YScale = canvas.Height / image.getHeight();
                            canvas.InvalidateVisual();
                            DrawSkipCount = 0;
                        }
                    }));
                }
            }
            catch (Exception ex)
            {
                DataManager.ShowExceptionAndShutDown(ex);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Continuously Update Emotions on Chart Control
        /// </summary>
        private void ExtractData(object sender, FaceWatcherEventArgs e)
        {
            Dictionary <int, Affdex.Face> FaceDictionary = e.Faces;

            if (FaceDictionary.Count != 0)
            {
                foreach (string classifier in DataManager.FaceWatcher.EnabledClassifiers)
                {
                    float value = DataManager.ExtractFeaturePropertyValue(FaceDictionary.ElementAt(0).Value, classifier);
                    DataManager.TrackData(classifier, value);
                }
            }
        }