Setup

AI Data Capture SDK

Overview

This document discusses the process for setting up Android Studio to work with AI Data Capture SDK. The SDK and its models for various use cases are distributed as AAR libraries, which can be integrated into your Android Studio project via Gradle or manually. These libraries are available through Zebra's official Maven repository.


Requirements

  • Supported Zebra Devices:

    Features Platform Device Model
    Products with DSP
    Fastest and most battery efficient
    QC6490 TC53, TC58, TC73, TC78, ET60, ET65
    QC5430 EM45
    Products without DSP
    Applies to still images
    QC4490 TC53e, TC58e, MC9400, MC9450

    For more information on devices based on platform, see Zebra Platform Devices.

  • Android Project: Target SDK version 34 (Android 14) or higher

  • Development Tools: Latest version of Android Studio

  • Licensing Information: The AI Data Capture SDK and all current AI models are available for free, with perpetual use on Zebra mobile computers. While specialized future models may require a license fee, current models and the SDK are available at no cost and without any licensing requirements. Any future models with licensing fees will be explicitly noted in their respective technical documentation.


Performance Optimization

Hardware Acceleration for AI Models - AI vision model inference speed is significantly accelerated by specialized processing blocks (NPUs) included in premium Qualcomm mobile computing chips. Zebra mobile computers equipped with Qualcomm 6 series and 5 series chips feature NPUs, enabling significantly faster AI model performance compared to devices using Qualcomm 4 series chips.

To estimate performance for a specific use case, users can try the AI Demo Applications available through the Zebra Showcase App, which is pre-loaded on Zebra devices.


Features & Models

The table below lists the SDK features along with their associated model names and versions required for setup. The model name and related information can be obtained by invoking methods from the AIVisionSDK class.

Features Model Name Model Version
Barcode Decoder barcode-localizer 5.0.1
Barcode Localizer barcode-localizer 5.0.1
Product Recognizer product-and-shelf-recognizer 3.4.2
Shelf and Product Localizer product-and-shelf-recognizer 3.4.2
TextOCR text-ocr-recognizer 2.7.3

Note: Barcode Decoder’s process() API uses the barcode-localizer model to perform detections before decoding.


Setup SDK

Integrate the AI Data Capture SDK and models into an Android project by using either the Gradle or manual method. Models can be included as a bundle with the application or loaded independently. After integration, develop application logic for functionalities such as localization, recognition, barcode decoding, or text OCR.

For effective use of the AI Data Capture SDK, models can be loaded independently from the application (Method 1). Alternatively, they can be bundled with the application using Gradle (Method 2)or manual integration (Method 3). Choose the approach that best fits your needs and follow the corresponding method below.


Method 1: Load Models Independently

Procedure for deploying models independently:

  1. Configure the Application to Access the Model: Program the application to retrieve the model from a designated public folder. e: Instead of /data/local/tmp used in the sample below, it may be replaced by any application-accessible location on the device. Sample code:

    // Define the model file path and name. 
    String modelFilePath = "/data/local/tmp/barcode-localizer-5.0.1.aar"; // Path to the model file 
    File modelFile = new File(modelFilePath); // modelFile represents the model File object 
    
    // Create a Localizer Settings object using the specified model file object 
    Localizer.Settings locSettings = new Localizer.Settings(modelFile); 
    
    // For TextOCR, create TextOCR Settings object using defined model file object. 
    TextOCR.Settings textOCRSettings = new TextOCR.Settings(modelFile); 
    
  2. Deploy the Models to the Specified Folder: Transfer models to the configured folder using adb (Android Debug Bridge) or Enterprise Mobility Management (EMM) tools. To push the model to the public folder on the device using aadb:

    adb push barcode_localizer.tar.crypt /data/local/tmp/
    
  3. Application Accesses the Model Upon Launch: Upon launching, the application automatically accesses the model from the folder where it was deployed. Ensure the application is configured to correctly locate and utilize the model from this designated path.


Method 2: Use Gradle

Follow these steps to include the SDK and models to your Android Studio project through Gradle:

  1. Prepare the AndroidManifest.xml: Grant the necessary permissions for camera access and set the attribute extractNativeLibs to true:

    <application android:extractNativeLibs="true"/>
    
  2. Update Gradle Settings: Open the application's version catalog file (libs.versions.toml) and add definitions for the SDK and model. Specify the desired model version as needed:

    • Define SDK and model versions, for example:

      aiSdkVersion = "3.0.2"
      localizerVersion = "5.0.1"
      

      Note: Replace "localizerVersion" with the desired model and version.

    • Add the following in the [libraries] section. Refer to the Features & Models section for the model name to use for "name."

      [libraries]
      …
      ai-sdk-version = {group ="com.zebra.ai.vision", name="AI-Data-Capture-SDK", version.ref ="aiSdkVersion"}
      barcode-localizer = {group ="com.zebra.ai.models", name="barcode-localizer", version.ref ="localizerVersion"} 
      

      Note: The "version.ref" field must match the variable defined in the previous step.

  3. Add Dependencies: In the app-level gradle file (build.gradle.kts), add the dependencies for the SDK and model:

        dependencies{
            ……
            implementation(libs.ai-sdk-version) { artifact { type ="aar" } } 
            implementation(libs.barcode-localizer) { artifact { type ="aar" } } 
        }
    

    Note: The string following "libs." must match the variable defined in the [libraries] section from the previous step.

  4. Configure Gradle for No Compression: Ensure Gradle does not compress .TAR and TAR.CRYPT extensions:

    android{
        …
        androidResources {
                noCompress.add("tar")
                noCompress.add("tar.crypt")
       }
    }
    
  5. Enter Maven Settings: In the settings.gradle.kts file, provide the maven URL as follows:

    maven {
        url = uri("https://zebratech.jfrog.io/ui/packages")
    }
    
  6. Sync Project: Synchronize the Android Studio project to ensure the models defined in the Gradle file are integrated into the workspace.

  7. Include SDK Packages: Open Java project files (e.g., MainActivity.java) and incorporate the AI Data Capture SDK packages.


Method 3: Manual

Follow these steps to manually include the SDK and models to your Android Studio project:

  1. Download the SDK and model .AAR files from Zebra's official Maven repository.
  2. In Android Studio, create a "libs" folder within the app/ folder.
  3. Copy the .AAR files into the "libs" folder.
  4. Synchronize the project with the Gradle files.