Face Verification Trial Version Issue

General information about Neurotechnology and its software

Face Verification Trial Version Issue

Postby mumair » Sep 12, 2019 04:22

Hi Neurotech Support,

We are busy testing the trial of ‘simple-faces-application’ (java version). We were able to run it in trial mode.

However, when trying to extract the VerifyFace.java code in a simple test app, it throws an error ‘operation not activated (attaching error as well as source)’.

Kindly redirect us to the best place for this query. If possible please forward the query to your technical team.

It would be great if we could have the trial going smooth. We are looking to buy a full license.

Thank you.


Error:
com.neurotec.util.concurrent.NAggregateExecutionException: One or more errors occurred
at com.neurotec.util.concurrent.ConcurrentUtilErrorCreator.create(ConcurrentUtilErrorCreator.java:17)
at com.neurotec.lang.ChainedErrorCreator.create(ChainedErrorCreator.java:22)
at com.neurotec.lang.NError.get(NError.java:174)
at com.neurotec.lang.NError.get(NError.java:191)
at com.neurotec.lang.NError.getLast(NError.java:205)
at com.neurotec.lang.NResult.checkUnchecked(NResult.java:235)
at com.neurotec.util.concurrent.NAsyncOperation.getRaw(NAsyncOperation.java:116)
at com.neurotec.util.concurrent.NAsyncOperation.get(NAsyncOperation.java:153)
at com.neurotec.util.concurrent.NCompletionHandler$1.stateChanged(NCompletionHandler.java:20)
at com.neurotec.lang.NObject$1.invoke(NObject.java:108)
Caused by[1 of 1]: com.neurotec.lang.NotActivatedException: Operation is not activated
at com.neurotec.lang.RuntimeErrorCreator.create(RuntimeErrorCreator.java:56)
at com.neurotec.lang.ChainedErrorCreator.create(ChainedErrorCreator.java:22)
at com.neurotec.lang.NError.get(NError.java:174)
at com.neurotec.lang.NError.get(NError.java:168)
at com.neurotec.lang.NError.get(NError.java:191)
at com.neurotec.lang.NError.getLast(NError.java:205)
at com.neurotec.lang.NResult.checkUnchecked(NResult.java:235)
at com.neurotec.util.concurrent.NAsyncOperation.getRaw(NAsyncOperation.java:116)
at com.neurotec.util.concurrent.NAsyncOperation.get(NAsyncOperation.java:153)
at com.neurotec.util.concurrent.NCompletionHandler$1.stateChanged(NCompletionHandler.java:20)
at com.neurotec.lang.NObject$1.invoke(NObject.java:108)
Errorcom.neurotec.util.concurrent.NAggregateExecutionException: One or more errors occurred



Code: Select all
import java.io.IOException;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import com.neurotec.biometrics.NBiometricStatus;
import com.neurotec.biometrics.NFace;
import com.neurotec.biometrics.NSubject;
import com.neurotec.biometrics.NSubject.FaceCollection;
import com.neurotec.biometrics.client.NBiometricClient;
import com.neurotec.biometrics.swing.NFaceView;
import com.neurotec.licensing.NLicenseManager;
import com.neurotec.util.concurrent.CompletionHandler;

public class Test {

   private final TemplateCreationHandler templateCreationHandler = new TemplateCreationHandler();
   private final VerificationHandler verificationHandler = new VerificationHandler();
   private NSubject subjectLeft;
   private NSubject subjectRight;
   private static final String SUBJECT_LEFT = "left";
   private static final String SUBJECT_RIGHT = "right";
   private NFaceView viewLeft;
   private NFaceView viewRight;
   
   public static void main(String[] args) throws IOException {


      //LibraryManager.initLibraryPath();
      Test t1 = new Test();
      t1.loadItem("left","C:UsersAutoMedDocuments\0.JPG");
      t1.loadItem("right","C:UsersAutoMedDocuments2.JPG");
      t1.verifyImage();
      System.out.println("Hello world!");
      
   }
   
   public Test() throws IOException {
      //super();
      boolean trialMode = true;//Utils.getTrialModeFlag();
      NLicenseManager.setTrialMode(trialMode);
      LibraryManager.initLibraryPath();
      System.out.println("   Trial mode: " + trialMode);
      BasePanel.requiredLicenses.add("Biometrics.FaceExtraction");
      BasePanel.requiredLicenses.add("Biometrics.FaceMatching");
      subjectLeft = new NSubject();
      subjectRight = new NSubject();
   }

   
   private void loadItem(String position, String path) throws IOException
   {
   
         NSubject subjectTmp = null;
         NFace face = null;
         try
         {
            subjectTmp = NSubject.fromFile(path);
            FaceCollection faces = subjectTmp.getFaces();
            if (faces.isEmpty())
            {
               subjectTmp = null;
               throw new IllegalArgumentException("Template contains no face records.");
            }
            face = faces.get(0);
            templateCreationHandler.completed(NBiometricStatus.OK, position);
         }
         catch (UnsupportedOperationException e)
         {
            // Ignore. UnsupportedOperationException means file is not a valid template.
         }

         // If file is not a template, try to load it as an image.
         if (subjectTmp == null)
         {
            face = new NFace();
            face.setFileName(path);
            subjectTmp = new NSubject();
            subjectTmp.getFaces().add(face);
            updateFacesTools();
            FaceTools.getInstance().getClient().createTemplate(subjectTmp, position, templateCreationHandler);
         }

         if (SUBJECT_LEFT.equals(position)) {
            subjectLeft = subjectTmp;
            //lblLeftItemLocation.setText(fc.getSelectedFile().getAbsolutePath());
            //viewLeft.setFace(face);
         } else if (SUBJECT_RIGHT.equals(position)) {
            subjectRight = subjectTmp;
            //lblRightItemLocation.setText(fc.getSelectedFile().getAbsolutePath());
            //viewRight.setFace(face);
         } else {
            throw new AssertionError("Unknown subject position: " + position);
         }
      
   }
   
   
   private void verifyImage()
   {
      try
      {
         updateFacesTools();
         FaceTools.getInstance().getClient().verify(subjectLeft, subjectRight, null, verificationHandler);
      }
      catch(Exception e)
      {
         e.printStackTrace();
         System.out.println(e.getMessage());
      }
      
   }
   
   private void updateFacesTools()
   {
      try
      {
         NBiometricClient client = FaceTools.getInstance().getClient();
         client.setFacesDetectAllFeaturePoints(true);
         FaceTools.getInstance().getClient().setMatchingThreshold(48);
      }
      catch(Exception e)
      {
         System.out.println(e.getMessage());
      }
      
   }


   void updateLabel(String msg) {
      //lblScore.setText(msg);
   }

   NSubject getLeft() {
      return subjectLeft;
   }

   NSubject getRight() {
      return subjectRight;
   }
   
   
   // ===========================================================
   // Inner classes
   // ===========================================================

   private class TemplateCreationHandler implements CompletionHandler<NBiometricStatus, String> {

      public void completed(final NBiometricStatus status, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
               if (status != NBiometricStatus.OK) {
                  //JOptionPane.showMessageDialog(Test.this, "Template was not created: " + status, "Error", JOptionPane.WARNING_MESSAGE);
               }
               //updateControls();
            }

         });
      }

      public void failed(final Throwable th, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
               //showError(th);
            }

         });
      }
      
   }
   
   
   private class VerificationHandler implements CompletionHandler<NBiometricStatus, String> {
      
      public void completed(final NBiometricStatus status, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {
            public void run() {
               if (status == NBiometricStatus.OK) {
                  int score = getLeft().getMatchingResults().get(0).getScore();
                  String msg = "Score of matched templates: " + score;
                  System.out.println(msg);
                  //updateLabel(msg);
                  //JOptionPane.showMessageDialog(VerifyFace.this, msg, "Match", JOptionPane.PLAIN_MESSAGE);
               } else {
                  //JOptionPane.showMessageDialog(VerifyFace.this, "Templates didn"t match.", "No match", JOptionPane.WARNING_MESSAGE);
               }
            }

         });
      }

      @Override
      public void failed(final Throwable th, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
               //showError(th);
               th.printStackTrace();
               System.out.println("Error"+th);
            }

         });
      }

   }

}
mumair
 
Posts: 1
Joined: Sep 12, 2019 04:16

Re: Face Verification Trial Version Issue

Postby vaidasz » Sep 12, 2019 13:04

mumair wrote:Hi Neurotech Support,

We are busy testing the trial of ‘simple-faces-application’ (java version). We were able to run it in trial mode.

However, when trying to extract the VerifyFace.java code in a simple test app, it throws an error ‘operation not activated (attaching error as well as source)’.

Kindly redirect us to the best place for this query. If possible please forward the query to your technical team.

It would be great if we could have the trial going smooth. We are looking to buy a full license.

Thank you.


Error:
com.neurotec.util.concurrent.NAggregateExecutionException: One or more errors occurred
at com.neurotec.util.concurrent.ConcurrentUtilErrorCreator.create(ConcurrentUtilErrorCreator.java:17)
at com.neurotec.lang.ChainedErrorCreator.create(ChainedErrorCreator.java:22)
at com.neurotec.lang.NError.get(NError.java:174)
at com.neurotec.lang.NError.get(NError.java:191)
at com.neurotec.lang.NError.getLast(NError.java:205)
at com.neurotec.lang.NResult.checkUnchecked(NResult.java:235)
at com.neurotec.util.concurrent.NAsyncOperation.getRaw(NAsyncOperation.java:116)
at com.neurotec.util.concurrent.NAsyncOperation.get(NAsyncOperation.java:153)
at com.neurotec.util.concurrent.NCompletionHandler$1.stateChanged(NCompletionHandler.java:20)
at com.neurotec.lang.NObject$1.invoke(NObject.java:108)
Caused by[1 of 1]: com.neurotec.lang.NotActivatedException: Operation is not activated
at com.neurotec.lang.RuntimeErrorCreator.create(RuntimeErrorCreator.java:56)
at com.neurotec.lang.ChainedErrorCreator.create(ChainedErrorCreator.java:22)
at com.neurotec.lang.NError.get(NError.java:174)
at com.neurotec.lang.NError.get(NError.java:168)
at com.neurotec.lang.NError.get(NError.java:191)
at com.neurotec.lang.NError.getLast(NError.java:205)
at com.neurotec.lang.NResult.checkUnchecked(NResult.java:235)
at com.neurotec.util.concurrent.NAsyncOperation.getRaw(NAsyncOperation.java:116)
at com.neurotec.util.concurrent.NAsyncOperation.get(NAsyncOperation.java:153)
at com.neurotec.util.concurrent.NCompletionHandler$1.stateChanged(NCompletionHandler.java:20)
at com.neurotec.lang.NObject$1.invoke(NObject.java:108)
Errorcom.neurotec.util.concurrent.NAggregateExecutionException: One or more errors occurred



Code: Select all
import java.io.IOException;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import com.neurotec.biometrics.NBiometricStatus;
import com.neurotec.biometrics.NFace;
import com.neurotec.biometrics.NSubject;
import com.neurotec.biometrics.NSubject.FaceCollection;
import com.neurotec.biometrics.client.NBiometricClient;
import com.neurotec.biometrics.swing.NFaceView;
import com.neurotec.licensing.NLicenseManager;
import com.neurotec.util.concurrent.CompletionHandler;

public class Test {

   private final TemplateCreationHandler templateCreationHandler = new TemplateCreationHandler();
   private final VerificationHandler verificationHandler = new VerificationHandler();
   private NSubject subjectLeft;
   private NSubject subjectRight;
   private static final String SUBJECT_LEFT = "left";
   private static final String SUBJECT_RIGHT = "right";
   private NFaceView viewLeft;
   private NFaceView viewRight;
   
   public static void main(String[] args) throws IOException {


      //LibraryManager.initLibraryPath();
      Test t1 = new Test();
      t1.loadItem("left","C:UsersAutoMedDocuments.JPG");
      t1.loadItem("right","C:UsersAutoMedDocuments2.JPG");
      t1.verifyImage();
      System.out.println("Hello world!");
      
   }
   
   public Test() throws IOException {
      //super();
      boolean trialMode = true;//Utils.getTrialModeFlag();
      NLicenseManager.setTrialMode(trialMode);
      LibraryManager.initLibraryPath();
      System.out.println("   Trial mode: " + trialMode);
      BasePanel.requiredLicenses.add("Biometrics.FaceExtraction");
      BasePanel.requiredLicenses.add("Biometrics.FaceMatching");
      subjectLeft = new NSubject();
      subjectRight = new NSubject();
   }

   
   private void loadItem(String position, String path) throws IOException
   {
   
         NSubject subjectTmp = null;
         NFace face = null;
         try
         {
            subjectTmp = NSubject.fromFile(path);
            FaceCollection faces = subjectTmp.getFaces();
            if (faces.isEmpty())
            {
               subjectTmp = null;
               throw new IllegalArgumentException("Template contains no face records.");
            }
            face = faces.get(0);
            templateCreationHandler.completed(NBiometricStatus.OK, position);
         }
         catch (UnsupportedOperationException e)
         {
            // Ignore. UnsupportedOperationException means file is not a valid template.
         }

         // If file is not a template, try to load it as an image.
         if (subjectTmp == null)
         {
            face = new NFace();
            face.setFileName(path);
            subjectTmp = new NSubject();
            subjectTmp.getFaces().add(face);
            updateFacesTools();
            FaceTools.getInstance().getClient().createTemplate(subjectTmp, position, templateCreationHandler);
         }

         if (SUBJECT_LEFT.equals(position)) {
            subjectLeft = subjectTmp;
            //lblLeftItemLocation.setText(fc.getSelectedFile().getAbsolutePath());
            //viewLeft.setFace(face);
         } else if (SUBJECT_RIGHT.equals(position)) {
            subjectRight = subjectTmp;
            //lblRightItemLocation.setText(fc.getSelectedFile().getAbsolutePath());
            //viewRight.setFace(face);
         } else {
            throw new AssertionError("Unknown subject position: " + position);
         }
      
   }
   
   
   private void verifyImage()
   {
      try
      {
         updateFacesTools();
         FaceTools.getInstance().getClient().verify(subjectLeft, subjectRight, null, verificationHandler);
      }
      catch(Exception e)
      {
         e.printStackTrace();
         System.out.println(e.getMessage());
      }
      
   }
   
   private void updateFacesTools()
   {
      try
      {
         NBiometricClient client = FaceTools.getInstance().getClient();
         client.setFacesDetectAllFeaturePoints(true);
         FaceTools.getInstance().getClient().setMatchingThreshold(48);
      }
      catch(Exception e)
      {
         System.out.println(e.getMessage());
      }
      
   }


   void updateLabel(String msg) {
      //lblScore.setText(msg);
   }

   NSubject getLeft() {
      return subjectLeft;
   }

   NSubject getRight() {
      return subjectRight;
   }
   
   
   // ===========================================================
   // Inner classes
   // ===========================================================

   private class TemplateCreationHandler implements CompletionHandler<NBiometricStatus, String> {

      public void completed(final NBiometricStatus status, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
               if (status != NBiometricStatus.OK) {
                  //JOptionPane.showMessageDialog(Test.this, "Template was not created: " + status, "Error", JOptionPane.WARNING_MESSAGE);
               }
               //updateControls();
            }

         });
      }

      public void failed(final Throwable th, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
               //showError(th);
            }

         });
      }
      
   }
   
   
   private class VerificationHandler implements CompletionHandler<NBiometricStatus, String> {
      
      public void completed(final NBiometricStatus status, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {
            public void run() {
               if (status == NBiometricStatus.OK) {
                  int score = getLeft().getMatchingResults().get(0).getScore();
                  String msg = "Score of matched templates: " + score;
                  System.out.println(msg);
                  //updateLabel(msg);
                  //JOptionPane.showMessageDialog(VerifyFace.this, msg, "Match", JOptionPane.PLAIN_MESSAGE);
               } else {
                  //JOptionPane.showMessageDialog(VerifyFace.this, "Templates didn"t match.", "No match", JOptionPane.WARNING_MESSAGE);
               }
            }

         });
      }

      @Override
      public void failed(final Throwable th, final String subject) {
         SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
               //showError(th);
               th.printStackTrace();
               System.out.println("Error"+th);
            }

         });
      }

   }

}


Hello,

I do not see in your code that you obtain licenses like it is done sin samples and tutorial provided with SDK. To obtain licenses you need to use NLicense.obtain(). Please check samples/tutorials how to obtain required license(s) in the source code of your application.
Vaidas Z
Neurotechnology
vaidasz
Neurotechnology
 
Posts: 635
Joined: Apr 30, 2010 06:57
Location: Vilnius, Lithuania


Return to Public

Who is online

Users browsing this forum: No registered users and 4 guests