11 Replies Latest reply on Jul 18, 2017 6:54 AM by MartyG

    Reloading database from file through SetDatabaseBuffer not working in Face recognition.

    DevSuj

      Hello,

           I need to save the recognized user in a database, so the app can load the data later for the camera to recognize the user as a registered user. I downloaded a sample application and it works well. it detects users and register the user but when i close the application and restart then it never recognizes the user if the user is loaded from the database file.

      I saved the data in database with the following code:

       

              private void SaveDatabaseToFile()

              {

                  // Allocate the buffer to save the database

                  PXCMFaceData.RecognitionModuleData recognitionModuleData = faceData.QueryRecognitionModule();

                  Int32 nBytes = recognitionModuleData.QueryDatabaseSize();

                  Byte[] buffer = new Byte[nBytes];

       

                  // Retrieve the database buffer

                  recognitionModuleData.QueryDatabaseBuffer(buffer);

       

                  // Save the buffer to a file

                  // (NOTE: production software should use file encryption for privacy protection)

                  File.WriteAllBytes(DatabaseFilename, buffer);

                  dbState = "Saved";

              }

       

      For reloading the saved database file i used this code.

       

      private void LoadDatabaseFromFile()

              {

                  if (File.Exists(DatabaseFilename))

                  {

                      Byte[] buffer = File.ReadAllBytes(DatabaseFilename);

                      recognitionConfig.SetDatabaseBuffer(buffer);

                      dbState = "Loaded";

                  }

                  else

                  {

                      dbState = "Not Found";

                  }

              }

       

      Thanks