style(ocr): add Image type hints to extract_page_blocks and extract_region_text

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-17 20:22:34 +02:00
parent 57ffb7d751
commit 07035b9fa9

View File

@@ -1,9 +1,15 @@
"""Kraken OCR engine wrapper — historical HTR model support for Kurrent/Suetterlin."""
from __future__ import annotations
import collections
import logging
import os
import threading
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from PIL.Image import Image
logger = logging.getLogger(__name__)
@@ -94,7 +100,7 @@ def is_available() -> bool:
return _model is not None
def extract_page_blocks(image, page_idx: int, language: str = "de",
def extract_page_blocks(image: Image, page_idx: int, language: str = "de",
sender_model_path: str | None = None) -> list[dict]:
"""Run Kraken segmentation + recognition on a single PIL image.
@@ -148,7 +154,7 @@ def extract_page_blocks(image, page_idx: int, language: str = "de",
return blocks
def extract_region_text(image, x: float, y: float, w: float, h: float,
def extract_region_text(image: Image, x: float, y: float, w: float, h: float,
sender_model_path: str | None = None) -> str:
"""Crop image to a normalized region and run Kraken recognition on the crop.