Method ReadAsync
- Namespace
- LMKit.Extraction.Barcodes
- Assembly
- LM-Kit.NET.dll
ReadAsync(ImageBuffer, CancellationToken)
Reads every barcode of a decoded image, in the order the reader found them. An image without a barcode returns an empty list.
public Task<IReadOnlyList<BarcodeDetection>> ReadAsync(ImageBuffer image, CancellationToken cancellationToken = default)
Parameters
imageImageBufferThe image (GRAY8, RGB24, RGBA32 or BINARY1).
cancellationTokenCancellationTokenCancels the read before it starts.
Returns
- Task<IReadOnlyList<BarcodeDetection>>
The barcodes found, positioned in the image's pixels.
Exceptions
- ArgumentNullException
imageisnull.- NotSupportedException
The image's pixel format is not supported.
- ArgumentException
A format in Formats is unknown to the native reader.
- RuntimeException
The native reader failed.
ReadAsync(string, CancellationToken)
Reads every barcode of an image file (its first page for a multi-page TIFF).
public Task<IReadOnlyList<BarcodeDetection>> ReadAsync(string imagePath, CancellationToken cancellationToken = default)
Parameters
imagePathstringThe image file (PNG, JPEG, TIFF, BMP, WebP...). For a PDF, use ReadPages(string, string, int, string, CancellationToken).
cancellationTokenCancellationTokenCancels the read before it starts.
Returns
Exceptions
- ArgumentNullException
imagePathisnullor empty.
ReadAsync(Attachment, int, int, CancellationToken)
Reads every barcode of one page of a document (PDF, image, multi-page TIFF...).
public Task<IReadOnlyList<BarcodeDetection>> ReadAsync(Attachment source, int pageIndex, int dpi = 200, CancellationToken cancellationToken = default)
Parameters
sourceAttachmentThe document.
pageIndexintThe zero-based page index.
dpiintThe resolution a PDF or other vector page is rendered at; image pages are read at their own resolution.
cancellationTokenCancellationTokenCancels the read.
Returns
- Task<IReadOnlyList<BarcodeDetection>>
The barcodes found, with their PageIndex and PageRegion, in reading order.
Exceptions
- ArgumentNullException
sourceisnull.- ArgumentOutOfRangeException
pageIndexordpiis out of range.- Exception
The page could not be rendered or decoded (the original error).