Skip to main content

Scanning a Barcode from an Image | React Native Document Scanner

Scanning a barcode from an image

This function will detect barcodes/QR codes in the given image. As input a file URI of an image must be passed. The output returns a BarcodeResult containing an array of all the barcodes/QR codes that have been detected on the given image.

ScanbotSDK.detectBarcodesOnImage(args: DetectBarcodesOnImageArguments): Promise<BarcodeResult>

Arguments

export interface DetectBarcodesOnImageArguments {
/**
* The input image file URI (REQUIRED)
*/
imageFileUri: string;
/**
* Accepted barcode formats
*/
barcodeFormats?: BarcodeFormat[];
/**
* An optional array of barcode document formats that act as a detection filter.
* By default all supported document formats will be detected.
*/
acceptedDocumentFormats?: BarcodeDocumentFormat[];
/**
* Optional minimum required text length of the detected barcode.
* The default is 0 (setting is turned off).
* NOTE: This feature works on ITF barcodes only.
*/
minimumTextLength?: number;
/**
* Optional maximum required text length of the detected barcode.
* The default is 0 (setting is turned off).
* NOTE: This feature works on ITF barcodes only.
*/
maximumTextLength?: number;
/**
* Optional minimum required quiet zone on the barcode.
* Measured in modules (the size of minimal bar on the barcode).
* The default is 10.
* NOTE: This feature works on ITF barcodes only.
*/
minimum1DBarcodesQuietZone?: number;
/**
* With this option enabled, the scanner removes checks digits for UPC, EAN and MSI Plessey codes.
* Has no effect if both single and double digit MSI Plessey checksums are enabled.
* The default is `false`
*/
stripCheckDigits?: boolean;
/**
* When set to `true`, the scanner assumes that the barcode can be a GS1 barcode.
* Turn it off, if you don't want to see decoded FNC1 characters ("]C1" and ASCII char 29).
* The default value is `true`.
* NOTE: Currently works for CODE128 barcodes only!
*/
gs1DecodingEnabled?: boolean;
/**
* The checksum algorithm for MSI Plessey barcodes.
* The default value is Mod10.
*/
msiPlesseyChecksumAlgorithm?: MSIPlesseyChecksumAlgorithm;
}

Returns

Returns object with the following fields

  • status - 'OK' or 'ERROR' in all error cases.
  • barcodes - the array of detected barcodes.
    • type - the detected BarcodeFormat
    • text - text value of detected barcode/QR code.

Detect Barcodes on Multiple Images

This function will detect barcodes/QR codes in the given images. As input an array of image file URIs must be passed. The output returns a DetectBarcodesOnImagesResult containing an array of all the barcodes/QR codes that have been detected on the given images.

ScanbotSDK.detectBarcodesOnImages(args: DetectBarcodesOnImagesArguments): Promise<DetectBarcodesOnImagesResult>

Arguments

export interface DetectBarcodesOnImagesArguments {
/**
* The input image files URIs (REQUIRED)
*/
imageFileUris: string[];
/**
* Accepted barcode formats
*/
barcodeFormats?: BarcodeFormat[];
/**
* An optional array of barcode document formats that act as a detection filter.
* By default all supported document formats will be detected.
*/
acceptedDocumentFormats?: BarcodeDocumentFormat[];
/**
* Optional minimum required text length of the detected barcode.
* The default is 0 (setting is turned off).
* NOTE: This feature works on ITF barcodes only.
*/
minimumTextLength?: number;
/**
* Optional maximum required text length of the detected barcode.
* The default is 0 (setting is turned off).
* NOTE: This feature works on ITF barcodes only.
*/
maximumTextLength?: number;
/**
* Optional minimum required quiet zone on the barcode.
* Measured in modules (the size of minimal bar on the barcode).
* The default is 10.
* NOTE: This feature works on ITF barcodes only.
*/
minimum1DBarcodesQuietZone?: number;
/**
* With this option enabled, the scanner removes checks digits for UPC, EAN and MSI Plessey codes.
* Has no effect if both single and double digit MSI Plessey checksums are enabled.
* The default is `false`
*/
stripCheckDigits?: boolean;
/**
* When set to `true`, the scanner assumes that the barcode can be a GS1 barcode.
* Turn it off, if you don't want to see decoded FNC1 characters ("]C1" and ASCII char 29).
* The default value is `true`.
* NOTE: Currently works for CODE128 barcodes only!
*/
gs1DecodingEnabled?: boolean;
/**
* The checksum algorithm for MSI Plessey barcodes.
* The default value is Mod10.
*/
msiPlesseyChecksumAlgorithm?: MSIPlesseyChecksumAlgorithm;
}

Returns

Returns object with the following fields

  • status - 'OK' or 'ERROR' in all error cases.
  • results - the array of results
    • imageFileUri - the imageFileUri on which the detection was executed
    • barcodeResults - the array of barcodes that have been detected in the image
      • type - the detected BarcodeFormat
      • text - text value of detected barcode/QR code.
    • error - an optional string that contains an error description when the detection fails

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?