Bounding geometry for OCR-extracted text elements.
Represents the geometric positioning of OCR-detected text, supporting both rectangular (left/top/width/height) and point-based (polygon points) geometry definitions.
Fields
:type- Geometry type ("rect" or "polygon"):left- Left x-coordinate for rectangular geometry, or nil:top- Top y-coordinate for rectangular geometry, or nil:width- Width for rectangular geometry, or nil:height- Height for rectangular geometry, or nil:points- Array of [x, y] points for polygon geometry, or nil
Examples
iex> geometry = %Kreuzberg.OcrBoundingGeometry{
...> type: "rect",
...> left: 10.0,
...> top: 20.0,
...> width: 100.0,
...> height: 50.0
...> }
iex> geometry.type
"rect"
Summary
Functions
Creates an OcrBoundingGeometry struct from a map.
Converts an OcrBoundingGeometry struct to a map.
Types
Functions
Creates an OcrBoundingGeometry struct from a map.
Parameters
data- A map containing geometry fields
Returns
An OcrBoundingGeometry struct with properly typed fields.
Examples
iex> geometry_map = %{
...> "type" => "rect",
...> "left" => 10.0,
...> "top" => 20.0,
...> "width" => 100.0,
...> "height" => 50.0
...> }
iex> geometry = Kreuzberg.OcrBoundingGeometry.from_map(geometry_map)
iex> geometry.type
"rect"
Converts an OcrBoundingGeometry struct to a map.
Parameters
geometry- AnOcrBoundingGeometrystruct
Returns
A map with string keys representing all fields.
Examples
iex> geometry = %Kreuzberg.OcrBoundingGeometry{
...> type: "rect",
...> left: 10.0,
...> top: 20.0,
...> width: 100.0,
...> height: 50.0
...> }
iex> Kreuzberg.OcrBoundingGeometry.to_map(geometry)
%{
"type" => "rect",
"left" => 10.0,
...
}