1. Kotlin
  2. Price Tags

Kotlin

Price Tags

The Vision SDK supports on-device AI scanning for Price Tags, allowing you to extract structured data such as price, currency, and product information directly from item tags—without requiring an internet connection.

⚙️ SDK Configuration

To enable on-device scanning for price tags, you must enable using the method below.

        private suspend fun enablePriceTagMode(view: VisionCameraView, apiKey: String? = null, token: String? = null) {
    view.enablePriceTagMode(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 price tags using the following method:

        private fun startPriceTagScanning() {

    coroutineScope.launch(Dispatcher.IO) {

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

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

                override fun onPriceTagResult(priceTagData: PriceTagData) : Boolean {
                    val priceFromLocalDb = getPriceOfItem(priceTagData.productSKU)
                    return priceFromLocalDb == priceTagData.productPrice
                }
            })

            visionCameraView.startCamera()
        }
    }
}

      

Structure of PriceTagData is as follow:

        data class PriceTagData(
    val productSKU: String,
    val productPrice: String,
)