hammerspoon2-docs
    Preparing search index...

    Class HSOCRObservation

    A 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).

    Index
    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.

    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.

    text: string

    The recognized text string for this observation.

    typeName: string

    The Swift type name, for JavaScript introspection.

    • Returns a plain object describing this observation, for JSON serialisation

      JSON.stringify() calls this automatically, so you rarely need to call it yourself.

      Returns Record<string, any>

      An object with the observation's text, confidence and bounds