Ejemplo n.º 1
0
 private void TurnOnClassifiers()
 {
     mCameraDetector.setDetectAllEmotions(false);
     mCameraDetector.setDetectAllExpressions(false);
     foreach (String metric in mEnabledClassifiers)
     {
         MethodInfo setMethodInfo = mCameraDetector.GetType().GetMethod(String.Format("setDetect{0}", NameMappings(metric)));
         setMethodInfo.Invoke(mCameraDetector, new object[] { true });
     }
 }
Ejemplo n.º 2
0
        static void processCamera(String trainingDataFolder, bool record)
        {
            try
            {
                Affdex.Detector detector = null;

                System.Console.WriteLine("Trying to process a camera feed...");
                double FPS    = 30.0D;
                uint   faceNo = 1;
                Affdex.FaceDetectorMode faceLarge = Affdex.FaceDetectorMode.LARGE_FACES;
                detector = new Affdex.CameraDetector(0, FPS, FPS, faceNo, faceLarge);


                if (detector != null)
                {
                    System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
                    customCulture.NumberFormat.NumberDecimalSeparator = ".";

                    System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

                    string pV = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    if (Environment.OSVersion.Version.Major >= 6)
                    {
                        pV = Directory.GetParent(pV).ToString();
                    }

                    string       Fname     = Path.Combine(@pV, "video_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".avi");
                    ProcessVideo videoForm = new ProcessVideo(detector, FPS);
                    if (record)
                    {
                        videoForm.setOutputVideoFile(Fname);
                    }

                    detector.setClassifierPath(trainingDataFolder);
                    detector.setDetectAllEmotions(true);
                    detector.setDetectAllExpressions(true);
                    detector.setDetectAllEmojis(true);
                    detector.setDetectAllAppearances(true);
                    detector.start();
                    System.Console.WriteLine("Face detector mode = " + detector.getFaceDetectorMode().ToString());

                    videoForm.ShowDialog();
                    videoForm.Dispose();

                    /*
                     * detector.stop();
                     * detector.Dispose();
                     */
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
            }
        }