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:
@@ -1,9 +1,15 @@
|
|||||||
"""Kraken OCR engine wrapper — historical HTR model support for Kurrent/Suetterlin."""
|
"""Kraken OCR engine wrapper — historical HTR model support for Kurrent/Suetterlin."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from PIL.Image import Image
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -94,7 +100,7 @@ def is_available() -> bool:
|
|||||||
return _model is not None
|
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]:
|
sender_model_path: str | None = None) -> list[dict]:
|
||||||
"""Run Kraken segmentation + recognition on a single PIL image.
|
"""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
|
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:
|
sender_model_path: str | None = None) -> str:
|
||||||
"""Crop image to a normalized region and run Kraken recognition on the crop.
|
"""Crop image to a normalized region and run Kraken recognition on the crop.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user