The bounding box is a rectangle that bounds an item on the document. It is used for both segments and ocr results.

Bounding Box Model

The BoundingBox model represents the bounding box and can be used to for highlights and annotations, as well as for VLM input as images.

interface BoundingBox {
  left: number;
  top: number;
  width: number;
  height: number;
}

Relative bounding box for OCR results

The bounding boxes for the OCR results are relative to the segment, so you might need to convert them to the document coordinate system before using them.

function convertToDocumentCoordinates(
  bbox: BoundingBox,
  segment: Segment
): BoundingBox {
  return {
    left: bbox.left + segment.bbox.left,
    top: bbox.top + segment.bbox.top,
    width: bbox.width,
    height: bbox.height,
  };
}

Click here to learn more about the OCR results.