Guest User

Untitled

a guest
Mar 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. foreach (var eye in eyes)
  2. {
  3. var e = eye;
  4. e.X += face.X;
  5. e.Y += face.Y;
  6. }
  7.  
  8. //gets paths to haash files
  9. string facePath = Path.GetFullPath(@"../../../datalol/haarcascade_frontalface_default.xml");
  10. string eyePath = Path.GetFullPath(@"../../../datalol/haarcascade_eye.xml");
  11. //sets classifiers for face and eye detection
  12. CascadeClassifier classifierFace = new CascadeClassifier(facePath);
  13. CascadeClassifier classifierEye = new CascadeClassifier(eyePath);
  14.  
  15.  
  16. var imgGray = imgInput.Convert<Gray, byte>().Clone();
  17. Rectangle[] faces = classifierFace.DetectMultiScale(imgGray, 1.1, 6);
  18.  
  19. foreach (var face in faces)
  20. {
  21. imgInput.Draw(face, new Bgr(0, 0, 255), 2);
  22.  
  23. imgGray.ROI = face;
  24. Rectangle[] eyes = classifierEye.DetectMultiScale(imgGray, 1.1, 6);
  25. foreach (var eye in eyes)
  26. {
  27. var e = eye;
  28.  
  29. e.X += face.X;
  30.  
  31. e.Y += face.Y;
  32.  
  33. }
  34. }
Add Comment
Please, Sign In to add comment