Module utilities.azure_ocr_integrator
Function call for Microsoft Azure OCR requests
Classes
class AzureOCRIntegrator (max_retries: int = 10, timeout: int = 60)
-
Extract text from pdf images via calls to Azure Cognitive Services OCR API.
Class variables
var client : azure.cognitiveservices.vision.computervision._computer_vision_client.ComputerVisionClient | None
var last_op_id : str
var last_read_results : list[azure.cognitiveservices.vision.computervision.models._models_py3.ReadResult]
var max_retries : int
var timeout : int
Methods
def create_client(self, azure_secret_name: str) ‑> None
-
Create an Azure ComputerVisionClient based on the supplied AWS secret.
If the
azure_secret_name
parameter is empty or does not point to a valid AWS secret, self.client is set to None and no image text will be extracted.Args
azure_secret_name
- the name of the secret defined in AWS for this facility's subscription key.
Environment Variables: AWS_ACCESS_KEY_ID: the access key ID for an account with access to the secret AWS_SECRET_ACCESS_KEY: the secret access key for an account with access to the secret AWS_SESSION_TOKEN (optional): required if the selected account is not allowed the non-interactive login permission. Blank otherwise. AWS_REGION (optional): defaults to "us-east-1" if not set.
def ocr_pages(self, pdf: bytes, pages: list[int], debug_path: pathlib.Path | None = None) ‑> list[str]
-
Read the text from supplied pdf page indices.
Args
pdf
- bytes of a pdf file
pages
- list of pdf page indices to OCR
Returns
list[str]
- list of strings containing structured text extracted from each supplied page index.