How to get confidence level of an extracted field (Hand written/ICR) in Java

  • 685 Views
  • Last Post 15 August 2016
  • Topic Is Solved
Shaown posted this 24 July 2016

I am trying to figure out how to access the confidence of the field that was extracted during ICR (Hand Written) using Java and the ABBYY SDK. How can i get the confidence level information in the sample code of java that has been provided to the Abby SDK. In the below code snippet, I want to print the confidence level in field information also. How can i do that ??

public class FlexiCapture {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    try {
        trace("Load the engine...");
        IEngineLoader engineLoader = Engine.CreateEngineOutprocLoader();           
        IEngine engine = engineLoader.Load(serialNumber, dllPath);

        try {

            trace("Create and configure FlexiCaptureProcessor...");
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
            processor.AddDocumentDefinitionFile("F:\\*\\*\\Document Definition 1.fcdot");

            trace("Add image files to recognize...");
            processor.AddImageFile("F:\\*\\test403.jpg");

            trace("Recognize document...");
            IDocument document = processor.RecognizeNextDocument();
            IDocumentDefinition definition = document.getDocumentDefinition();
            assert (definition != null);
            assert (document.getPages().getCount() == 1);

            IFields fields = document.getSections().Item(0).getChildren();

            trace("====================================");
            for (int i = 0; i < fields.getCount(); i++) {
                IField field = fields.getElement(i);
                trace(field.getName() + ": "
                        + (field.getValue() != null ? field.getValue().getAsString() : "."));
            }
            trace("====================================");

        } finally {
            Engine.Unload();
        }

        trace("Done.");
    } catch (Exception ex) {
        trace("Exception: " + ex.getMessage());
    }
}

private static void trace(String txt) {
    System.out.println(txt);
}

private static final String samplesFolder;
static private String serialNumber;
static private String dllPath;

static {
    //samplesFolder = "..\\";
    try {
        FileInputStream file = new FileInputStream("C:\\Users\\*\\Documents\\NetBeansProjects\\SampleConfig\\SamplesConfig.txt");
        BufferedReader reader = new BufferedReader(new InputStreamReader(file));
        serialNumber = reader.readLine();
        dllPath = reader.readLine();
        file.close();
        trace(serialNumber);
        trace(dllPath);
    } catch (java.io.IOException e) {
        System.out.println(e.getMessage());
    }
}

}

Anna Falevskaya posted this 15 August 2016

Hello!

The value of recognition confidence of a character or a character variant is accessible through the CharConfidence property of the CharParams (this object allows you to access the parameters of a single character in recognized text) or the RecognizedCharacterInfo objects (this object represents the variant of the character recognition).

Recognition confidence of a character variant is a numerical estimate of the probability that the image does in fact represent this character. However, confidence is not guaranteed to be a positive number. We would like to note that the only reliable use of confidence is to compare several variants for one image. More information can be found in the Help file: Guided Tour→Advanced Techniques→Working with Recognition Variants.

  • Liked by
  • Shaown
Close