Class BasicLabelPostProcessor
java.lang.Object
com.itextpdf.pdfocr.onnx.recognition.BasicLabelPostProcessor
- All Implemented Interfaces:
-
IRecognitionPostProcessor
- Direct Known Subclasses:
-
CrnnPostProcessor,CtcLabelPostProcessor
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidappendLabel(StringBuilder output, int labelIndex) Adds label to the string output, based on the label's index.process(FloatBufferMdArray output) Process ML model output and return recognized characters as string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.itextpdf.pdfocr.onnx.recognition.IRecognitionPostProcessor
labelDimension
-
Constructor Details
-
BasicLabelPostProcessor
public BasicLabelPostProcessor()
-
-
Method Details
-
process
Process ML model output and return recognized characters as string.- Specified by:
-
processin interfaceIRecognitionPostProcessor - Parameters:
-
output- raw output of the ML model - Returns:
- recognized characters as string
-
appendLabel
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.
-