Created
July 19, 2019 11:29
-
-
Save mdfarragher/49453713ed35cf867f89248c153b33f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// detect all faces | |
var chips = new List<Matrix<RgbPixel>>(); | |
var faces = new List<Rectangle>(); | |
Console.WriteLine("Detecting faces..."); | |
foreach (var face in detector.Operator(img)) | |
{ | |
// detect landmarks | |
var shape = predictor.Detect(img, face); | |
// extract normalized and rotated 150x150 face chip | |
var faceChipDetail = Dlib.GetFaceChipDetails(shape, 150, 0.25); | |
var faceChip = Dlib.ExtractImageChip<RgbPixel>(img, faceChipDetail); | |
// convert the chip to a matrix and store | |
var matrix = new Matrix<RgbPixel>(faceChip); | |
chips.Add(matrix); | |
faces.Add(face); | |
} | |
Console.WriteLine($" Found {chips.Count} faces in image"); | |
// the rest of the code goes here... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment