# `Kreuzberg.OcrConfidence`
[🔗](https://github.com/kreuzberg-dev/kreuzberg/blob/main/lib/kreuzberg/ocr_confidence.ex#L1)

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

# `t`

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

# `from_map`

```elixir
@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`

```elixir
@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}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
