static void Main(string[] args) { string inputfile = ""; Affdex.VideoDetector detector = new Affdex.VideoDetector(30, 1, Affdex.FaceDetectorMode.LARGE_FACES); Form1 f1 = new Form1(); ProcessVideo feed = new ProcessVideo(detector); System.Console.WriteLine("ranunaaa"); detector.setClassifierPath("C:\\Program Files\\Affectiva\\AffdexSDK\\data"); detector.setDetectAllEmotions(true); detector.setDetectAllEmojis(true); detector.setDetectAllExpressions(true); detector.setDetectAge(true); detector.setDetectGender(true); detector.setDetectGlasses(true); detector.setDetectLipCornerDepressor(false); detector.setDetectLipPress(false); detector.setDetectLipPucker(false); detector.setDetectLipStretch(false); detector.setDetectLipSuck(false); detector.setDetectMouthOpen(false); detector.setDetectSmile(false); detector.setDetectSmirk(false); detector.setDetectUpperLipRaise(false); System.Console.WriteLine("all functions on"); Application.Run(f1); using (Form1 form2 = new Form1()) { inputfile = Form1.getFilename(); Console.WriteLine("hey from program"); Console.WriteLine(inputfile); } detector.start(); System.Console.WriteLine("detector started"); //System.Diagnostics.Process.Start("C:\\Users\\Rana\\Desktop\\video\\test.avi"); //var dir = new DirectoryInfo(@"C:\Users\Rana\Desktop\video\enterface database"); //foreach (var file in dir.EnumerateFiles("*.avi", SearchOption.AllDirectories)) { // dynamic filename = file.FullName; detector.process(inputfile); Application.Run(feed); //feed.ShowDialog(); // System.Console.WriteLine("detector reset"); detector.reset(); } System.Console.WriteLine("detector stopped"); detector.stop(); }
static void Main(string[] args) { CmdOptions options = new CmdOptions(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { Affdex.Detector detector = null; List <string> imgExts = new List <string> { ".bmp", ".jpg", ".gif", ".png", ".jpe" }; List <string> vidExts = new List <string> { ".avi", ".mov", ".flv", ".webm", ".wmv", ".mp4" }; bool isCamera = (options.Input.ToLower() == "camera"); bool isImage = imgExts.Any <string>(s => (options.Input.Contains(s) || options.Input.Contains(s.ToUpper()))); bool isVideo = (!isImage && !isCamera); if (isCamera) { System.Console.WriteLine("Trying to process a camera feed..."); detector = new Affdex.CameraDetector(0, 30, 30, (uint)options.numFaces, (Affdex.FaceDetectorMode)options.faceMode); } else if (isImage) { System.Console.WriteLine("Trying to process a bitmap image..." + options.Input.ToString()); detector = new Affdex.PhotoDetector((uint)options.numFaces, (Affdex.FaceDetectorMode)options.faceMode); } else if (isVideo) { System.Console.WriteLine("Trying to process a video file..." + options.Input.ToString()); detector = new Affdex.VideoDetector(15, (uint)options.numFaces, (Affdex.FaceDetectorMode)options.faceMode); } else { System.Console.WriteLine("File-Type not supported."); } if (detector != null) { ProcessVideo videoForm = new ProcessVideo(detector); detector.setClassifierPath(options.DataFolder); detector.setDetectAllEmotions(true); detector.setDetectAllExpressions(true); detector.setDetectAllEmojis(true); detector.setDetectAllAppearances(true); detector.start(); System.Console.WriteLine("Face detector mode = " + detector.getFaceDetectorMode().ToString()); if (isVideo) { ((Affdex.VideoDetector)detector).process(options.Input); } else if (isImage) { ((Affdex.PhotoDetector)detector).process(LoadFrameFromFile(options.Input)); } else { ; } videoForm.ShowDialog(); detector.stop(); //Hifza //close socket after data transfer is complete myNetworks.myNetwork.CloseClient(); } } }
static void processVideo(String pVideo, CmdOptions options) { try { Affdex.Detector detector = null; List <string> imgExts = new List <string> { ".bmp", ".jpg", ".gif", ".png", ".jpe" }; List <string> vidExts = new List <string> { ".avi", ".mov", ".flv", ".webm", ".wmv", ".mp4" }; bool isImage = imgExts.Any <string>(s => (pVideo.Contains(s) || pVideo.Contains(s.ToUpper()))); if (isImage) { System.Console.WriteLine("Trying to process a bitmap image..." + options.Input.ToString()); detector = new Affdex.PhotoDetector((uint)options.numFaces, (Affdex.FaceDetectorMode)options.faceMode); } else { System.Console.WriteLine("Trying to process a video file..." + options.Input.ToString()); detector = new Affdex.VideoDetector(60F, (uint)options.numFaces, (Affdex.FaceDetectorMode)options.faceMode); } 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 = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName; if (Environment.OSVersion.Version.Major >= 6) { pV = Directory.GetParent(pV).ToString(); } Boolean research = false; StreamWriter outputFile = null; string Fname = Path.Combine(@pV, "blinkValues_" + DateTime.Now.ToString("yyMMdd_hhmmss") + ".txt"); string fileHeader = ""; fileHeader += "Blink\tEye-Aspect-Rate\t"; fileHeader += "frame"; System.Console.WriteLine(fileHeader); outputFile = new StreamWriter(Fname); outputFile.WriteLine(fileHeader); ProcessVideo videoForm = new ProcessVideo(detector, 15); videoForm.setOutputVideoFileLog(outputFile); detector.setClassifierPath(options.DataFolder); detector.setDetectAllEmotions(true); detector.setDetectAllExpressions(true); detector.setDetectAllEmojis(true); detector.setDetectAllAppearances(true); detector.start(); System.Console.WriteLine("Face detector mode = " + detector.getFaceDetectorMode().ToString()); if (isImage) { Affdex.Frame img = LoadFrameFromFile(options.Input); ((Affdex.PhotoDetector)detector).process(img); } else { ((Affdex.VideoDetector)detector).process(options.Input); } videoForm.ShowDialog(); videoForm.Dispose(); //videoForm = null; outputFile.Close(); detector.stop(); detector.Dispose(); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } }