Kreuzberg.OcrConfidence (kreuzberg v4.4.2)

Copy Markdown View Source

Confidence scores for OCR text detection and recognition.

Contains separate confidence metrics for different stages of the OCR process: detection (finding text regions) and recognition (reading the text).

Fields

  • :detection - Confidence score for text detection (0.0-1.0), or nil
  • :recognition - Confidence score for text recognition (0.0-1.0), or nil

Examples

iex> confidence = %Kreuzberg.OcrConfidence{
...>   detection: 0.95,
...>   recognition: 0.92
...> }
iex> confidence.detection
0.95

Summary

Functions

Creates an OcrConfidence struct from a map.

Converts an OcrConfidence struct to a map.

Types

t()

@type t() :: %Kreuzberg.OcrConfidence{
  detection: float() | nil,
  recognition: float() | nil
}

Functions

from_map(data)

@spec from_map(map()) :: t()

Creates an OcrConfidence struct from a map.

Parameters

  • data - A map containing confidence fields

Returns

An OcrConfidence struct with properly typed fields.

Examples

iex> confidence_map = %{"detection" => 0.95, "recognition" => 0.92}
iex> confidence = Kreuzberg.OcrConfidence.from_map(confidence_map)
iex> confidence.detection
0.95

to_map(confidence)

@spec to_map(t()) :: map()

Converts an OcrConfidence struct to a map.

Parameters

  • confidence - An OcrConfidence struct

Returns

A map with string keys representing all fields.

Examples

iex> confidence = %Kreuzberg.OcrConfidence{
...>   detection: 0.95,
...>   recognition: 0.92
...> }
iex> Kreuzberg.OcrConfidence.to_map(confidence)
%{"detection" => 0.95, "recognition" => 0.92}