Skip to content

Expose positioned OCR spans in OcrPageResult - #514

Open
yitom486 wants to merge 3 commits into
firecrawl:mainfrom
yitom486:feat/ocr-spans
Open

yitom486 wants to merge 3 commits into
firecrawl:mainfrom
yitom486:feat/ocr-spans

Conversation

@yitom486

@yitom486 yitom486 commented Sep 8, 2026

Copy link
Copy Markdown

Closes #513.

Purpose

Expose the positioned OCR recognition lines already produced by the vision pipeline through the Node.js and Python OcrPageResult APIs. This lets downstream readers such as Inkdown place OCR text on a rendered page, show confidence-aware overlays, and search/select scanned content without re-running OCR or parsing Markdown.

API

Each page now exposes spans, a recognition-order, line-level list of:

  • text
  • x, y, width, height — axis-aligned PDF-point rectangle in the same visible-page coordinate frame as TextItem; y grows upward
  • confidence — 0.0 to 1.0

spans is empty when OCR did not run for a page. When OCR does run, spans remain available even if fusion ultimately chooses native Markdown.

Compatibility

This is additive only. It does not change existing Markdown, routing, provenance, model, or inference behavior, and does not trigger an extra OCR pass.

Validation

  • cargo test -j 1 — 1,209 unit + 176 integration + 2 doc tests passed
  • cargo test --lib --features "ocr python" — 1,298 tests passed, including the new Python mapping test
  • cargo test --manifest-path napi/Cargo.toml maps_positioned_ocr_spans_into_napi_result — passed
  • node napi/test.mjs — passed
  • cargo clippy -j 1 -- -D warnings — passed
  • git diff --check — passed

The new deterministic NAPI and Python tests assert that text, all geometry fields, confidence, and the empty non-OCR-page case are preserved by each binding.

@yitom486
yitom486 marked this pull request as ready for review September 9, 2026 06:54

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Shadow auto-approve: would not auto-approve because issues were found.

Fix all with cubic | Re-trigger cubic

Comment thread src/python.rs
Comment thread src/vision/fusion.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would auto-approve. Expose positioned OCR spans via NAPI and Python OcrPageResult, backed by deterministic mapping tests and updated docs.

Re-trigger cubic

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bindings] Expose positioned OCR spans in OcrPageResult

1 participant