Table of Contents

Method Run

Namespace
LMKit.Extraction.Ocr
Assembly
LM-Kit.NET.dll

Run(Attachment, CancellationToken)

Runs OCR synchronously on the specified attachment and returns a detailed result.

public VlmOcr.VlmOcrResult Run(Attachment attachment, CancellationToken cancellationToken = default)

Parameters

attachment Attachment

The Attachment representing the image to be transcribed. This is typically used when the image is already part of a larger data source (for example, a page extracted from a document).

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation while waiting for the underlying asynchronous work to complete.

Returns

VlmOcr.VlmOcrResult

A VlmOcr.VlmOcrResult containing both the raw text-generation result and the constructed PageElement.

Remarks

This is a convenience wrapper around RunAsync(Attachment, CancellationToken) for callers that prefer a synchronous API or cannot easily use async/await.

Exceptions

ArgumentNullException

Thrown if attachment is null.

OperationCanceledException

Thrown if the operation is canceled via cancellationToken.

Run(ImageBuffer, CancellationToken)

Runs OCR synchronously on the specified image and returns a detailed result.

public VlmOcr.VlmOcrResult Run(ImageBuffer image, CancellationToken cancellationToken = default)

Parameters

image ImageBuffer

The ImageBuffer containing the image to be transcribed.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation while waiting for the underlying asynchronous work to complete.

Returns

VlmOcr.VlmOcrResult

A VlmOcr.VlmOcrResult containing both the raw text-generation result and the constructed PageElement.

Remarks

This overload is convenient when you already have an ImageBuffer (for example, loaded via LoadAsRGB(string)). The image is internally wrapped into an attachment for processing.

Exceptions

ArgumentNullException

Thrown if image is null.

OperationCanceledException

Thrown if the operation is canceled via cancellationToken.