コード例 #1
0
        /// <summary>
        /// Starts the camera processing.
        /// </summary>
        private void StartCameraProcessing()
        {
            try
            {
                btnStartCamera.IsEnabled = false;
                btnResetCamera.IsEnabled =
                Points.IsEnabled =
                Metrics.IsEnabled =
                Appearance.IsEnabled =
                Emojis.IsEnabled =
                btnStopCamera.IsEnabled =
                btnAppShot.IsEnabled = 
                btnExit.IsEnabled = true;

                // Instantiate CameraDetector using default camera ID
                const int cameraId = 0;
                const int numberOfFaces = 10;
                const int cameraFPS = 15;
                const int processFPS = 15;
                Detector = new Affdex.CameraDetector(cameraId, cameraFPS, processFPS, numberOfFaces, Affdex.FaceDetectorMode.LARGE_FACES);

                //Set location of the classifier data files, needed by the SDK
                Detector.setClassifierPath(FilePath.GetClassifierDataFolder());

                // Set the Classifiers that we are interested in tracking
                TurnOnClassifiers();

                Detector.setImageListener(this);
                Detector.setProcessStatusListener(this);

                Detector.start();

                // Hide the logo, show the camera feed and the data canvas
                logoBackground.Visibility = Visibility.Hidden;
                cornerLogo.Visibility = Visibility.Visible;
                canvas.Visibility = Visibility.Visible;
                cameraDisplay.Visibility = Visibility.Visible;
            }
            catch (Affdex.AffdexException ex)
            {
                if (!String.IsNullOrEmpty(ex.Message))
                {
                    // If this is a camera failure, then reset the application to allow the user to turn on/enable camera
                    if (ex.Message.Equals("Unable to open webcam."))
                    {
                        MessageBoxResult result = MessageBox.Show(ex.Message,
                                                                "AffdexMe Error",
                                                                MessageBoxButton.OK,
                                                                MessageBoxImage.Error);
                        StopCameraProcessing();
                        return;
                    }
                }

                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
            catch (Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
        }
コード例 #2
0
        private void StartCameraProcessing()
        {
            try
            {
                btnStartCamera.IsEnabled        = false;
                btnResetCamera.IsEnabled        =
                    btnShowPoints.IsEnabled     =
                        btnStopCamera.IsEnabled =
                            btnExit.IsEnabled   = true;

                // Instantiate CameraDetector using default camera ID
                mCameraDetector = new Affdex.CameraDetector();

                mCameraDetector.setClassifierPath(GetClassifierDataFolder());

                // Set the Classifiers that we are interested in tracking
                TurnOnClassifiers();

                // Initialize Classifier cache
                for (int index = 0; index < mAffdexClassifierValues.Count(); index++)
                {
                    mAffdexClassifierValues[index] = 0;
                }

                mCachedSkipFaceResultsCount = 0;
                mCameraDetector.setImageListener(this);
                mCameraDetector.setProcessStatusListener(this);



                // Set the License Path
                mCameraDetector.setLicensePath(GetAffdexLicense());

                mStartTime = DateTime.Now;
                mCameraDetector.start();

                // Delay loading the Classifier panel until 1st face
                mFirstFaceRecognized = false;

                // Hide the logo
                imgAffdexLogoDisplay.Visibility = Visibility.Hidden;
            }
            catch (Affdex.AffdexException ex)
            {
                if (!String.IsNullOrEmpty(ex.Message))
                {
                    // If this is a camera failure, then reset the application to allow the user to turn on/enable camera
                    if (ex.Message.Equals("Unable to open webcam."))
                    {
                        MessageBoxResult result = MessageBox.Show(ex.Message,
                                                                  "AffdexMe Error",
                                                                  MessageBoxButton.OK,
                                                                  MessageBoxImage.Error);
                        StopCameraProcessing();
                        return;
                    }
                }

                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
            catch (Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
        }
コード例 #3
0
        private void StartCameraProcessing()
        {
            try
            {
                btnStartCamera.IsEnabled = false;
                btnResetCamera.IsEnabled =
                btnShowPoints.IsEnabled =
                btnStopCamera.IsEnabled =
                btnExit.IsEnabled = true;

                // Instantiate CameraDetector using default camera ID
                mCameraDetector = new Affdex.CameraDetector();
                
                mCameraDetector.setClassifierPath(GetClassifierDataFolder());

                // Set the Classifiers that we are interested in tracking
                TurnOnClassifiers();

                // Initialize Classifier cache
                for (int index = 0; index < mAffdexClassifierValues.Count(); index++)
                {
                    mAffdexClassifierValues[index] = 0;
                }

                mCachedSkipFaceResultsCount = 0;
                mCameraDetector.setImageListener(this);
                mCameraDetector.setProcessStatusListener(this);



                // Set the License Path
                mCameraDetector.setLicensePath(GetAffdexLicense());
                
                mStartTime = DateTime.Now;
                mCameraDetector.start();

                // Delay loading the Classifier panel until 1st face
                mFirstFaceRecognized = false;

                // Hide the logo
                imgAffdexLogoDisplay.Visibility = Visibility.Hidden;
            }
            catch(Affdex.AffdexException ex)
            {
                if (!String.IsNullOrEmpty(ex.Message))
                {
                    // If this is a camera failure, then reset the application to allow the user to turn on/enable camera
                    if (ex.Message.Equals("Unable to open webcam."))
                    {
                        MessageBoxResult result = MessageBox.Show(ex.Message,
                                                                "AffdexMe Error",
                                                                MessageBoxButton.OK,
                                                                MessageBoxImage.Error);
                        StopCameraProcessing();
                        return;
                    }
                }

                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
            catch(Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
        }
コード例 #4
0
        /// <summary>
        /// Starts the camera processing.
        /// </summary>
        private void StartCameraProcessing()
        {
            try
            {
                btnStartCamera.IsEnabled                      = false;
                btnResetCamera.IsEnabled                      =
                    Points.IsEnabled                          =
                        Metrics.IsEnabled                     =
                            Appearance.IsEnabled              =
                                Emojis.IsEnabled              =
                                    btnStopCamera.IsEnabled   =
                                        btnAppShot.IsEnabled  =
                                            btnExit.IsEnabled = true;

                // Instantiate CameraDetector using default camera ID
                const int cameraId      = 0;
                const int numberOfFaces = 10;
                const int cameraFPS     = 15;
                const int processFPS    = 15;
                Detector = new Affdex.CameraDetector(cameraId, cameraFPS, processFPS, numberOfFaces, Affdex.FaceDetectorMode.LARGE_FACES);

                //Set location of the classifier data files, needed by the SDK
                Detector.setClassifierPath(FilePath.GetClassifierDataFolder());

                // Set the Classifiers that we are interested in tracking
                TurnOnClassifiers();

                Detector.setImageListener(this);
                Detector.setProcessStatusListener(this);

                Detector.start();

                // Hide the logo, show the camera feed and the data canvas
                logoBackground.Visibility = Visibility.Hidden;
                cornerLogo.Visibility     = Visibility.Visible;
                canvas.Visibility         = Visibility.Visible;
                cameraDisplay.Visibility  = Visibility.Visible;
            }
            catch (Affdex.AffdexException ex)
            {
                if (!String.IsNullOrEmpty(ex.Message))
                {
                    // If this is a camera failure, then reset the application to allow the user to turn on/enable camera
                    if (ex.Message.Equals("Unable to open webcam."))
                    {
                        MessageBoxResult result = MessageBox.Show(ex.Message,
                                                                  "AffdexMe Error",
                                                                  MessageBoxButton.OK,
                                                                  MessageBoxImage.Error);
                        StopCameraProcessing();
                        return;
                    }
                }

                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
            catch (Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
        }