Scanning a barcode from an image
The Barcode Scanner efficiently analyzes a still image to identify and extract information from any barcodes present. Once detected, the scanner returns the barcode data in the result.
Processing the image
With the Scanbot SDK, you can detect barcodes from a still image, such as a JPG from the Photo Library or another source. The image should be provided as a file URI.
Single image barcode detection
Picking an image from the gallery using galleryManager:
var imageBitmapForDetection by remember { mutableStateOf<ImageBitmap?>(null) }
imageBitmapForDetection?.let { bitmap ->
var barcodeResult = detectBarcodesFromImageBitmap(bitmap)
}
val galleryManager = rememberGalleryManager { sharedImage ->
imageBitmapForDetection = sharedImage?.imageBitmap
}
LaunchedEffect(Unit) {
galleryManager.launch()
}
To detect barcodes from a single image:
val imageBitmap: ImageBitmap = /* your ImageBitmap here */
// Specify the barcode formats you want to detect
val barcodeFormats = listOf(
BarcodeFormat.AZTEC,
BarcodeFormat.EAN_8,
BarcodeFormat.UPC_A
//...
)
// Specify accepted document formats for barcode detection
val documentFormats = listOf(
BarcodeDocumentFormat.SEPA,
BarcodeDocumentFormat.MEDICAL_CERTIFICATE
//..
)
val result: List<BarcodeItem>? = detectBarcodesFromImageBitmap(
imageBitmap = imageBitmap,
barcodeFormats = barcodeFormats, /* your list of BarcodeFormat here, or null */
acceptedDocumentFormats = documentFormats /* your list of BarcodeDocumentFormat here, or null */
)
- Result:
result- A list of recognized barcodes as items ofList<BarcodeItem>type.
For a complete list of parameters and detailed descriptions, refer to the API documentation.
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial licenseScanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
