Record Class OcrRegion
java.lang.Object
java.lang.Record
ai.doctruth.spi.OcrRegion
- Record Components:
text- the recovered text in this region.box- pixel bounding box on the rendered page image.confidence- per-region confidence in[0.0, 1.0].
One OCR-recovered text region with its pixel bounding box on the rendered page image.
The
(x, y, width, height) are pixels at the rendering DPI; downstream code
scales to PDF user-space if needed via the same DPI.
Why pixel coordinates and not PDF user-space points? OCR engines work on raster images; reporting the pixel box back is the only honest representation of where the engine "saw" the text. Callers that need PDF user-space coordinates convert once, with the DPI they used.
Invariants (constructors):
textnon-null (empty allowed — represents a region the engine couldn't transcribe).boxnon-null and geometrically valid.confidencein[0.0, 1.0].
- Since:
- 0.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbox()Returns the value of theboxrecord component.doubleReturns the value of theconfidencerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intheight()text()Returns the value of thetextrecord component.final StringtoString()Returns a string representation of this record class.intwidth()intx()inty()
-
Constructor Details
-
OcrRegion
-
OcrRegion
Creates an instance of aOcrRegionrecord class.- Parameters:
text- the value for thetextrecord componentbox- the value for theboxrecord componentconfidence- the value for theconfidencerecord component
-
-
Method Details
-
x
public int x() -
y
public int y() -
width
public int width() -
height
public int height() -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
text
-
box
-
confidence
public double confidence()Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-