Class EasyOcrDetectionPostProcessor
java.lang.Object
com.itextpdf.pdfocr.onnx.detection.BasicDetectionPostProcessor
com.itextpdf.pdfocr.onnx.detection.EasyOcrDetectionPostProcessor
- All Implemented Interfaces:
-
IDetectionPostProcessor
Implementation of a text detection predictor post-processor, used for EasyOCR model outputs.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new post-processor with the default parameters.EasyOcrDetectionPostProcessor(float scoreThreshold) Creates a new post-processor. -
Method Summary
Modifier and TypeMethodDescriptionprotected ListapplyTextBoxMerger(List detectedTextBoxes) The text detection model from EasyOCR, for the most part, returns words or small groups of words.protected doublecalcTextBoxEnlargement(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.protected IScoreCalculatorCreates a new score calculator for calculating score over a text contour.protected FloatBufferMdArraygetMaskSourceArray(FloatBufferMdArray output) Returns the array to be used, when building a mask for contour detection.process(BufferedImage input, FloatBufferMdArray output) Process ML model output for a specified image and return a list of detected objects.Methods inherited from class com.itextpdf.pdfocr.onnx.detection.BasicDetectionPostProcessor
buildTextContourPredictionMask, findTextContours, getPredsArray, isValidContour, mapPredToSample
-
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
Process ML model output for a specified image and return a list of detected objects.- Specified by:
-
processin interfaceIDetectionPostProcessor - Overrides:
-
processin classBasicDetectionPostProcessor - 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
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
Returns the array to be used, when building a mask for contour detection.- Overrides:
-
getMaskSourceArrayin classBasicDetectionPostProcessor - Parameters:
-
output- output buffer from the model - Returns:
- the array to build the mask from
-
createScoreCalculator
Creates a new score calculator for calculating score over a text contour.- Overrides:
-
createScoreCalculatorin classBasicDetectionPostProcessor - 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:
-
calcTextBoxEnlargementin classBasicDetectionPostProcessor - Parameters:
-
width- original width of the text box -
height- original height of the text box - Returns:
- value to enlarge the dimensions by
-