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
attachmentAttachmentThe 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).
cancellationTokenCancellationTokenA 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
attachmentisnull.- 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
imageImageBufferThe ImageBuffer containing the image to be transcribed.
cancellationTokenCancellationTokenA 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
imageisnull.- OperationCanceledException
Thrown if the operation is canceled via
cancellationToken.