public void Execute() { try { ServicesWorker.GetInstance <FaceRecognizerService>().Load(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Execute() { try { ServicesWorker.GetInstance <FaceRecognizerService>() .DetectGender(GetSamples("Male"), GetSamples("Female")); } catch (DirectoryNotFoundException) { Console.WriteLine(@"Нет изображений для выделения лиц!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Execute() { try { ServicesWorker.GetInstance <FaceRecognizerService>() .TrainGender(GetSamples("DetMale"), GetSamples("DetFemale")); } catch (DirectoryNotFoundException) { Console.WriteLine(@"Нет изображений для обучения распознаванию пола!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Execute() { try { var t = new Thread(ServicesWorker.GetInstance <FaceRecognizerService>().DetectHuman); t.Start(); if (Console.ReadKey() != null) { t.Abort(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static void WriteResult(string name, double distance) { var vs = ServicesWorker.GetInstance <VoiceAssistantService>(); if (name == CurrentName) { _counter++; } else { _counter = 0; CurrentName = name; } Console.WriteLine(name + " " + distance); if (_counter == 5) { vs.SayText("Привет " + name); } }
private static void Main(string[] args) { ServicesWorker.Registration(new CoreModule()); var faceRecognizerService = ServicesWorker.GetInstance <FaceRecognizerService>(); faceRecognizerService.FaceCascadeClassifier = new CascadeClassifier(Application.StartupPath + "\\Cascade\\haarcascade_frontalface_default.xml"); faceRecognizerService.Recognized += WriteResult; faceRecognizerService.GenderRecognized += WriteResult; faceRecognizerService.OnGenderCount += WriteGenderRecognizedCount; faceRecognizerService.OnCount += WriteCount; faceRecognizerService.Load(); var app = new CommandProcessor.Application(); app.Run(); Console.ReadKey(); }
public void Execute() { try { var fileNames = Directory.GetFiles("Images\\TestMale\\", "*.jpg"); var maleImg = fileNames.Select(fileName => new Image <Gray, byte>(fileName)).ToList(); var persentMale = ServicesWorker.GetInstance <FaceRecognizerService>().DetectGenderByPhoto(maleImg, true); Console.WriteLine(@"% правильно распознанных мужчин " + persentMale); fileNames = Directory.GetFiles("Images\\TestFemale\\", "*.jpg"); var femaleImg = fileNames.Select(fileName => new Image <Gray, byte>(fileName)).ToList(); var persentFemale = ServicesWorker.GetInstance <FaceRecognizerService>() .DetectGenderByPhoto(femaleImg, false); Console.WriteLine(@"% правильно распознанных женщин " + persentFemale); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Execute() { try { Console.WriteLine(@"Введите имя человека и встаньте перед камерой."); Console.WriteLine(@"Пожалуйста, во время записи постарайтесь" + "\n" + @"продемонстрировать разные выражения лица"); var name = Console.ReadLine(); Directory.CreateDirectory("Images\\" + name); var images = ServicesWorker.GetInstance <FaceRecognizerService>().AddImagesToHuman(name); foreach (var img in images) { img.Save("Images\\" + name + "\\" + images.IndexOf(img) + ".jpg"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static void WriteResult(bool gender, double distance) { var text = ""; text = gender ? "незнакомец" : "незнакомка"; var vs = ServicesWorker.GetInstance <VoiceAssistantService>(); if (text == CurrentName) { _counter++; } else { _counter = 0; CurrentName = text; } var g = gender ? "М" : "Ж"; Console.WriteLine(g + " " + distance); if (_counter == 5) { vs.SayText("Привет " + text); } }