Class BasicLabelPostProcessor

java.lang.Object
com.itextpdf.pdfocr.onnx.recognition.BasicLabelPostProcessor
All Implemented Interfaces:
IRecognitionPostProcessor
Direct Known Subclasses:
CrnnPostProcessor, CtcLabelPostProcessor

public abstract class BasicLabelPostProcessor extends Object implements IRecognitionPostProcessor
Abstract Implementation of a basic text recognition predictor post-processor. It contains logic, which is common between OnnxTR, EasyOCR and PaddleOCR label mappers:
  • It receives a two-dimensional array with a (maxStringLength, labelDimension) shape.
  • Label with the highest value in the array is picked as the recognized one.
  • There are labels, which should not be added to the string, and should just be treated as separators.
  • If the same label appears multiple times in a row in a string, it is returned only once.
  • Constructor Details

    • BasicLabelPostProcessor

      public BasicLabelPostProcessor()
  • Method Details

    • process

      public String process (FloatBufferMdArray output)
      Process ML model output and return recognized characters as string.
      Specified by:
      process in interface IRecognitionPostProcessor
      Parameters:
      output - raw output of the ML model
      Returns:
      recognized characters as string
    • appendLabel

      protected abstract void appendLabel (StringBuilder output, int labelIndex)
      Adds label to the string output, based on the label's index. Can be a noop, if label index should be ignored.
      Parameters:
      output - string builder to append the label to
      labelIndex - index of the label to append, guaranteed to be in the [0; labelDimension()) range.