Skip to content

Commit 95cf316

Browse files
committed
Finalize javadocs for pdfocr-onnxtr
DEVSIX-9236
1 parent b35e080 commit 95cf316

22 files changed

+216
-28
lines changed

pdfocr-api/src/main/java/com/itextpdf/pdfocr/OcrPdfCreatorEventHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class OcrPdfCreatorEventHelper extends AbstractPdfOcrEventHelper {
3939
this.metaInfo = metaInfo;
4040
}
4141

42+
/**
43+
* {@inheritDoc}
44+
*/
4245
@Override
4346
public void onEvent(AbstractProductITextEvent event) {
4447
if (event instanceof AbstractContextBasedITextEvent) {
@@ -50,11 +53,17 @@ public void onEvent(AbstractProductITextEvent event) {
5053
EventManager.getInstance().onEvent(event);
5154
}
5255

56+
/**
57+
* {@inheritDoc}
58+
*/
5359
@Override
5460
public SequenceId getSequenceId() {
5561
return sequenceId;
5662
}
5763

64+
/**
65+
* {@inheritDoc}
66+
*/
5867
@Override
5968
public EventConfirmationType getConfirmationType() {
6069
return EventConfirmationType.ON_CLOSE;

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/AbstractOnnxPredictor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ protected AbstractOnnxPredictor(String modelPath, OnnxInputProperties inputPrope
135135
}
136136
}
137137

138+
/**
139+
* {@inheritDoc}
140+
*/
138141
@Override
139142
public Iterator<R> predict(Iterator<T> inputs) {
140143
return new BatchProcessingGenerator<>(
@@ -151,6 +154,9 @@ public Iterator<R> predict(Iterator<T> inputs) {
151154
);
152155
}
153156

157+
/**
158+
* {@inheritDoc}
159+
*/
154160
@Override
155161
public void close() {
156162
if (closed) {

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/OnnxInputProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class OnnxInputProperties {
4040
* Expected channel count. We expect RGB format.
4141
*/
4242
public static final int EXPECTED_CHANNEL_COUNT = 3;
43+
4344
/**
4445
* Expected shape size. We inspect the standard BCHW format (batch, channel, height, width).
4546
*/
@@ -49,14 +50,17 @@ public class OnnxInputProperties {
4950
* Per-channel mean, used for normalization. Should be EXPECTED_SHAPE_SIZE length.
5051
*/
5152
private final float[] mean;
53+
5254
/**
5355
* Per-channel standard deviation, used for normalization. Should be EXPECTED_SHAPE_SIZE length.
5456
*/
5557
private final float[] std;
58+
5659
/**
5760
* Target input shape. Should be EXPECTED_SHAPE_SIZE length.
5861
*/
5962
private final long[] shape;
63+
6064
/**
6165
* Whether padding should be symmetrical during input resizing.
6266
*/
@@ -270,11 +274,17 @@ public boolean useSymmetricPad() {
270274
return symmetricPad;
271275
}
272276

277+
/**
278+
* {@inheritDoc}
279+
*/
273280
@Override
274281
public int hashCode() {
275282
return Objects.hash((Object) Arrays.hashCode(mean), Arrays.hashCode(std), Arrays.hashCode(shape), symmetricPad);
276283
}
277284

285+
/**
286+
* {@inheritDoc}
287+
*/
278288
@Override
279289
public boolean equals(Object o) {
280290
if (this == o) {
@@ -288,6 +298,9 @@ public boolean equals(Object o) {
288298
&& Arrays.equals(std, that.std) && Arrays.equals(shape, that.shape);
289299
}
290300

301+
/**
302+
* {@inheritDoc}
303+
*/
291304
@Override
292305
public String toString() {
293306
return "OnnxInputProperties{" +

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/OnnxTrEventHelper.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,31 @@ This file is part of the iText (R) project.
3434
final class OnnxTrEventHelper extends AbstractPdfOcrEventHelper {
3535

3636
OnnxTrEventHelper() {
37-
// do nothing
37+
// Do nothing.
3838
}
3939

40+
/**
41+
* {@inheritDoc}
42+
*/
4043
@Override
4144
public void onEvent(AbstractProductITextEvent event) {
4245
EventManager.getInstance().onEvent(event);
4346
}
4447

48+
/**
49+
* {@inheritDoc}
50+
*/
4551
@Override
46-
public SequenceId getSequenceId() {
47-
return new SequenceId();
52+
public EventConfirmationType getConfirmationType() {
53+
return EventConfirmationType.ON_DEMAND;
4854
}
4955

56+
/**
57+
* {@inheritDoc}
58+
*/
5059
@Override
51-
public EventConfirmationType getConfirmationType() {
52-
return EventConfirmationType.ON_DEMAND;
60+
public SequenceId getSequenceId() {
61+
return new SequenceId();
5362
}
63+
5464
}

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/OnnxTrFileResultEventHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ final class OnnxTrFileResultEventHelper extends AbstractPdfOcrEventHelper {
4444
this.events = new ArrayList<>();
4545
}
4646

47+
/**
48+
* {@inheritDoc}
49+
*/
4750
@Override
4851
public void onEvent(AbstractProductITextEvent event) {
4952
if (isConfirmForProcessImageOnnxTrEvent(event)) {
@@ -53,11 +56,17 @@ public void onEvent(AbstractProductITextEvent event) {
5356
}
5457
}
5558

59+
/**
60+
* {@inheritDoc}
61+
*/
5662
@Override
5763
public SequenceId getSequenceId() {
5864
return wrappedEventHelper.getSequenceId();
5965
}
6066

67+
/**
68+
* {@inheritDoc}
69+
*/
6170
@Override
6271
public EventConfirmationType getConfirmationType() {
6372
return wrappedEventHelper.getConfirmationType();

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/OnnxTrOcrEngine.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public OnnxTrOcrEngine(IDetectionPredictor detectionPredictor, IRecognitionPredi
122122
this(detectionPredictor, null, recognitionPredictor);
123123
}
124124

125+
/**
126+
* {@inheritDoc}
127+
*/
125128
@Override
126129
public void close() throws Exception {
127130
detectionPredictor.close();
@@ -131,11 +134,17 @@ public void close() throws Exception {
131134
recognitionPredictor.close();
132135
}
133136

137+
/**
138+
* {@inheritDoc}
139+
*/
134140
@Override
135141
public Map<Integer, List<TextInfo>> doImageOcr(File input) {
136142
return doImageOcr(input, new OcrProcessContext(new OnnxTrEventHelper()));
137143
}
138144

145+
/**
146+
* {@inheritDoc}
147+
*/
139148
@Override
140149
public Map<Integer, List<TextInfo>> doImageOcr(File input, OcrProcessContext ocrProcessContext) {
141150
Map<Integer, List<TextInfo>> result = doOnnxTrOcr(input, ocrProcessContext);
@@ -147,11 +156,17 @@ public Map<Integer, List<TextInfo>> doImageOcr(File input, OcrProcessContext ocr
147156
return result;
148157
}
149158

159+
/**
160+
* {@inheritDoc}
161+
*/
150162
@Override
151163
public void createTxtFile(List<File> inputImages, File txtFile) {
152164
createTxtFile(inputImages, txtFile, new OcrProcessContext(new OnnxTrEventHelper()));
153165
}
154166

167+
/**
168+
* {@inheritDoc}
169+
*/
155170
@Override
156171
public void createTxtFile(List<File> inputImages, File txtFile, OcrProcessContext ocrProcessContext) {
157172
LoggerFactory.getLogger(getClass()).info(
@@ -182,16 +197,25 @@ public void createTxtFile(List<File> inputImages, File txtFile, OcrProcessContex
182197
}
183198
}
184199

200+
/**
201+
* {@inheritDoc}
202+
*/
185203
@Override
186204
public boolean isTaggingSupported() {
187205
return false;
188206
}
189207

208+
/**
209+
* {@inheritDoc}
210+
*/
190211
@Override
191212
public PdfOcrMetaInfoContainer getMetaInfoContainer() {
192213
return new PdfOcrMetaInfoContainer(new OnnxTrMetaInfo());
193214
}
194215

216+
/**
217+
* {@inheritDoc}
218+
*/
195219
@Override
196220
public ProductData getProductData() {
197221
return null;

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/actions/events/PdfOcrOnnxTrProductEvent.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public static PdfOcrOnnxTrProductEvent createProcessImageOnnxTrEvent(SequenceId
6767
return new PdfOcrOnnxTrProductEvent(sequenceId, metaInfo, PROCESS_IMAGE_ONNXTR, eventConfirmationType);
6868
}
6969

70+
/**
71+
* {@inheritDoc}
72+
*/
7073
@Override
7174
public String getEventType() {
7275
return eventType;

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/detection/OnnxDetectionPostProcessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public OnnxDetectionPostProcessor() {
8484
this(0.1F, 0.1F);
8585
}
8686

87+
/**
88+
* {@inheritDoc}
89+
*/
8790
@Override
8891
public List<Point[]> process(BufferedImage input, FloatBufferMdArray output) {
8992
final int height = output.getDimension(1);

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/detection/OnnxDetectionPredictor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,18 @@ public OnnxDetectionPredictorProperties getProperties() {
173173
return properties;
174174
}
175175

176+
/**
177+
* {@inheritDoc}
178+
*/
176179
@Override
177180
protected FloatBufferMdArray toInputBuffer(List<BufferedImage> batch) {
178181
// Just your regular BCHW input
179182
return BufferedImageUtil.toBchwInput(batch, properties.getInputProperties());
180183
}
181184

185+
/**
186+
* {@inheritDoc}
187+
*/
182188
@Override
183189
protected List<List<Point[]>> fromOutputBuffer(List<BufferedImage> inputBatch, FloatBufferMdArray outputBatch) {
184190
final IDetectionPostProcessor postProcessor = properties.getPostProcessor();

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/detection/OnnxDetectionPredictorProperties.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ public IDetectionPostProcessor getPostProcessor() {
215215
return postProcessor;
216216
}
217217

218+
/**
219+
* {@inheritDoc}
220+
*/
218221
@Override
219222
public boolean equals(Object o) {
220223
if (this == o) {
@@ -229,11 +232,17 @@ public boolean equals(Object o) {
229232
Objects.equals(postProcessor, that.postProcessor);
230233
}
231234

235+
/**
236+
* {@inheritDoc}
237+
*/
232238
@Override
233239
public int hashCode() {
234240
return Objects.hash((Object) modelPath, inputProperties, postProcessor);
235241
}
236242

243+
/**
244+
* {@inheritDoc}
245+
*/
237246
@Override
238247
public String toString() {
239248
return "OnnxDetectionPredictorProperties{" +

0 commit comments

Comments
 (0)