Class EasyOcrDetectionPostProcessor

java.lang.Object
com.itextpdf.pdfocr.onnx.detection.BasicDetectionPostProcessor
com.itextpdf.pdfocr.onnx.detection.EasyOcrDetectionPostProcessor
All Implemented Interfaces:
IDetectionPostProcessor

public class EasyOcrDetectionPostProcessor extends BasicDetectionPostProcessor
Implementation of a text detection predictor post-processor, used for EasyOCR model outputs.
  • Constructor Details

    • EasyOcrDetectionPostProcessor

      public EasyOcrDetectionPostProcessor (float scoreThreshold)
      Creates a new post-processor.
      Parameters:
      scoreThreshold - score threshold for a detected box. If score is lower than this value, the box gets discarded
    • EasyOcrDetectionPostProcessor

      public EasyOcrDetectionPostProcessor()
      Creates a new post-processor with the default parameters.
  • Method Details

    • process

      public List process (BufferedImage input, FloatBufferMdArray output)
      Process ML model output for a specified image and return a list of detected objects.
      Specified by:
      process in interface IDetectionPostProcessor
      Overrides:
      process in class BasicDetectionPostProcessor
      Parameters:
      input - input image, which was used to produce the inputs to the ML model
      output - output of the ML model
      Returns:
      a list of detected objects. See interface documentation for more information
    • applyTextBoxMerger

      protected List applyTextBoxMerger (List detectedTextBoxes)
      The text detection model from EasyOCR, for the most part, returns words or small groups of words. Since the EasyOCR text recognition models expect lines as input, we need to merge the boxes.
      Parameters:
      detectedTextBoxes - list of rotated text boxes, provided by the text detection routine
      Returns:
      a new list with merged text boxes
    • getMaskSourceArray

      protected FloatBufferMdArray getMaskSourceArray (FloatBufferMdArray output)
      Returns the array to be used, when building a mask for contour detection.
      Overrides:
      getMaskSourceArray in class BasicDetectionPostProcessor
      Parameters:
      output - output buffer from the model
      Returns:
      the array to build the mask from
    • createScoreCalculator

      protected IScoreCalculator createScoreCalculator()
      Creates a new score calculator for calculating score over a text contour.
      Overrides:
      createScoreCalculator in class BasicDetectionPostProcessor
      Returns:
      a new score calculator
    • calcTextBoxEnlargement

      protected double calcTextBoxEnlargement (double width, double height)
      Calculates by how much the dimensions of a text box should be enlarged compared to the ones gotten from the model output.
      Overrides:
      calcTextBoxEnlargement in class BasicDetectionPostProcessor
      Parameters:
      width - original width of the text box
      height - original height of the text box
      Returns:
      value to enlarge the dimensions by