コード例 #1
0
 private void btnAuthenticate_Click(object sender, EventArgs e)
 {
     try
     {
         var predictedUserId = _recognizerEngine.RecognizeUser(new Image <Gray, byte>(picCapturedUser.Image.Bitmap));
         if (predictedUserId == -1)
         {
             MessageBox.Show("This person is not recognized, Kindly register this face", "Authentication Result",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             //proceed to documents library
             IDataStoreAccess dataStore = new DataStoreAccess(_databasePath);
             var username = dataStore.GetUsername(predictedUserId);
             if (username != String.Empty)
             {
                 if (MessageBox.Show(
                         String.Format("Face Recognized as {0}, Do you want to proceed?", username.ToUpper()),
                         "Authentication Result",
                         MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                 {
                     var documentLibrary = new FrmDocumentLibrary();
                     if (documentLibrary.ShowDialog() == DialogResult.OK)
                     {
                         documentLibrary.Close();
                     }
                 }
             }
             else
             {
                 MessageBox.Show("No Username for this face, Kindly register this face", "Authentication Result",
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message, "Authentication Result - Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 public RecognizerEngine(String databasePath, String recognizerFilePath)
 {
     _recognizerFilePath = recognizerFilePath;
     _dataStoreAccess    = new DataStoreAccess();
     _faceRecognizer     = new EigenFaceRecognizer(80, double.PositiveInfinity);
 }