public void MatchFoto(byte[] sampleFoto) { OnProgress("Search for face on the sample foto."); byte[] sampleFace = FaceDetectionWrapper.GetFirstFace(sampleFoto); if (sampleFace == null) { OnProgress("No face were fount on the sample photo."); return; } using (FaceDetectionWrapper.FaceRecognizer faceRecoznizer = new FaceDetectionWrapper.FaceRecognizer("faces.db")) { OnProgress("Search for face in the database."); int predictedLabel = faceRecoznizer.Predict(sampleFace); OnProgress("Predicted label is: " + predictedLabel); } }
public void TrainRecognizer() { using (FaceDetectionWrapper.FaceRecognizer faceRecoznizer = new FaceDetectionWrapper.FaceRecognizer("faces.db")) { int fotosProcessed = 0; m_DbModel.EnumerateFaces(new Action<int, byte[]>((userId, image) => { faceRecoznizer.Train(image, userId); OnProgress(string.Format("Processed {0} fotos.", ++fotosProcessed)); })); OnProgress(string.Format("Trainig is completed. Total processed fotos: {0}.", fotosProcessed)); } }