HSOCRObservation
TypeA single region of text recognized in an image.
Instances are delivered inside the observations array of an HSOCRResult.
Each observation represents a discrete text run found in the source image,
along with a confidence score and a normalized bounding box.
Bounding-box coordinates use a normalized top-left-origin system:
(0, 0) is the top-left corner of the image and (1, 1) is the bottom-right.
This matches the convention used by most image-processing tools and differs
from Vision's internal bottom-left-origin system (the conversion is automatic).
- Example:
const result = await hs.ocr.recognizeText('/tmp/image.png')
result.observations.forEach(obs => {
const pct = (obs.confidence * 100).toFixed(0)
console.log(obs.text + ' (' + pct + '% confidence)')
const b = obs.bounds
console.log(' region: x=' + b.x.toFixed(3) + ' y=' + b.y.toFixed(3)
+ ' w=' + b.w.toFixed(3) + ' h=' + b.h.toFixed(3))
})
Properties
confidence
number
Recognition confidence in the range `0.0` (uncertain) to `1.0` (certain).
Use `minimumConfidence` in the options passed to `recognizeText()` to
pre-filter observations below a threshold rather than filtering here.
bounds
HSRect
Normalized bounding box of this observation in the source image, as an `HSRect`.
All values are in the range 0–1 with **top-left origin**
(`(0, 0)` = top-left corner, `(1, 1)` = bottom-right corner).
Use `bounds.x`, `bounds.y`, `bounds.w`, and `bounds.h` to access the components.
Methods
This type has no methods.