Class PaddleOcrDetectionPostProcessor

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

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

    • PaddleOcrDetectionPostProcessor

      public PaddleOcrDetectionPostProcessor (float thresh, float boxThresh, float unclipRatio, int maxCandidates)
      Creates a new post-processor.
      Parameters:
      thresh - threshold value used, when binarizing a monochromatic image. If pixel value is greater or equal to the threshold, it is mapped to 1, otherwise it is mapped to 0
      boxThresh - score threshold for a detected box. If score is lower than this value, the box gets discarded
      unclipRatio - coefficient used to scale, how much a box is enlarged from the ones found in a model output. The higher the value, the bigger the enlargement is
      maxCandidates - maximum amount of text box contours, that will be handled in the post processor
    • PaddleOcrDetectionPostProcessor

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

    • buildTextContourPredictionMask

      protected org.bytedeco.opencv.opencv_core.Mat buildTextContourPredictionMask (org.bytedeco.opencv.opencv_core.Mat contour, org.bytedeco.opencv.opencv_core.Rect contourBox)
      Builds and return a mask for calculating prediction score for the provided contour.

      Mask should adhere to the following requirements:

      • Mask should have the same dimensions as the contour box.
      • Data type should be CV_8U.
      • Pixels, that should be counted towards the score, should have a non-zero value in the mask.
      Overrides:
      buildTextContourPredictionMask in class BasicDetectionPostProcessor
      Parameters:
      contour - contour to build mask for
      contourBox - bounding box of the contour to build mask for
      Returns:
      the built mask
    • 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