1. Kotlin
  2. Item Retrieval

Kotlin

Item Retrieval

The Vision SDK supports on-device AI scanning for Item Retrieval, allowing you to extract data from barcodes and directly checking them with your local inventory, to check if they exist in your local inventory or not.

⚙️ SDK Configuration

To enable on-device scanning for item retrieval, you must enable using the method below.

        private suspend fun enableItemRetrievalMode(view: VisionCameraView, apiKey: String? = null, token: String? = null) {
    view.enableItemRetrievalMode(apiKey, token)
}

      

💡 You must provide either an apiKey or a valid token during configuration.

📸 Extracting Data from Camera feed

Once the model has been prepared, you can start scanning for item retrievals using the following method:

        private fun startItemRetrievalScanning() {

    coroutineScope.launch(Dispatcher.IO) {

        enableItemRetrievalMode(view = visionCameraView, apiKey = getApiKey())

        withContext(Dispatcher.Main) {
        
            visionCameraView.setScannerCallback(object : ScannerCallbackAdapter() {

                override fun onItemRetrievalResult(scannedCodeResults: ScannedCodeResult) : Boolean {
                    val itemsInLocalInventory = getItemsInLocalInventory()
                    return scannedCodeResults.scannedCode in itemsInLocalInventory
                }
            })

            visionCameraView.startCamera()
        }
    }
}

      

Structure of ScannedCodeResult is as follow:

        data class ScannedCodeResult(
    val scannedCode: String,
    val symbology: BarcodeSymbology,
    val gs1ExtractedInfo: Map<String, String>? = null
)