๐Ÿค– Android AI and Generative AI

Image Understanding and Description in Android Apps

Phones are cameras first. Understanding images (reading text, recognising objects, describing scenes, answering questions about a photo) unlocks features from receipt scanning to accessibility. Here's how to choose between task-specific ML, on-device description and multimodal cloud models.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 3 min read ๐ŸŽฏ Intermediate
On this page
  1. Three levels of image understanding
  2. Task-specific: image labeling
  3. On-device description
  4. Multimodal Gemini with structured output
  5. Hybrid pattern: OCR first, then reason on text
  6. Privacy and safety
  7. Use cases
  8. Frequently asked questions
  9. Conclusion

"What's in this image?" has many answers depending on the task. Is there a barcode? What does the text say? What objects are present? What's happening in the scene? Is this rash serious? (Don't build that last one casually.) The right tool depends on which question you're asking.

Three levels of image understanding

Choosing an image understanding approach Task-specific ML Kit vision APIs such as text recognition, barcode scanning and image labeling are fast, free and on-device. On-device Image Description with Gemini Nano generates short natural-language descriptions on supported devices. Multimodal cloud Gemini answers open questions and returns structured data, with network and cost. ML Kit visionOCR ยท barcodes ยท labelsfaces ยท objects ยท poseson-device, broad devices GenAI Image Descriptionshort scene descriptionGemini Nanosupported devices only Multimodal Geminiopen questions, reasoningstructured JSON outputcloud: network + cost
Fixed perception tasks belong on the left. Open-ended understanding belongs on the right.

Task-specific: image labeling

Labels.ktKotlin
// implementation("com.google.mlkit:image-labeling:<version>")
val labeler = ImageLabeling.getClient(ImageLabelerOptions.Builder().setConfidenceThreshold(0.7f).build())

suspend fun labels(bitmap: Bitmap): List<String> =
    labeler.process(InputImage.fromBitmap(bitmap, 0)).await().map { it.text }   // e.g. ["Dog", "Grass"]

Labels are fast and free, which is good for tagging, search and filters. They don't describe relationships ("a dog chasing a ball").

On-device description

ML Kit's GenAI Image Description API produces a short natural-language description on supported devices. It's ideal for draft alt text that stays private. Code is in ML Kit GenAI APIs Explained.

Multimodal Gemini with structured output

When you need specific information extracted from an image, ask a multimodal model for structured JSON matching a schema rather than free text:

ReceiptExtractor.ktKotlin
@Serializable
data class ReceiptInfo(val merchant: String?, val totalPaise: Long?, val date: String?, val category: String?)

class ReceiptExtractor {
    private val schema = Schema.obj(
        mapOf(
            "merchant" to Schema.string(nullable = true),
            "totalPaise" to Schema.long(description = "Total amount in paise", nullable = true),
            "date" to Schema.string(description = "ISO-8601 date", nullable = true),
            "category" to Schema.enumeration(listOf("food", "travel", "shopping", "bills", "other")),
        )
    )

    private val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
        modelName = "gemini-3.8-flash",            // check current names
        generationConfig = generationConfig {
            responseMimeType = "application/json"
            responseSchema = schema
            temperature = 0f
        },
    )

    suspend fun extract(photo: Bitmap): ReceiptInfo {
        val response = model.generateContent(content {
            image(photo.scaleToMaxSide(1280))
            text("Extract the receipt details. Use null when a value is not clearly visible.")
        })
        return Json { ignoreUnknownKeys = true }.decodeFromString(response.text ?: "{}")
    }
}

Structured output reduces parsing errors, but values can still be wrong, so always let users review extracted data before saving. Schema helper names follow Firebase AI Logic's Kotlin SDK. Check the structured-output docs for your SDK version.

Hybrid pattern: OCR first, then reason on text

For documents and receipts, running on-device OCR (ML Kit text recognition) first and sending only the extracted text to a cloud model is often cheaper and more private than sending the full photo, and accurate enough for many tasks.

Privacy and safety

  • Photos often contain people, documents and locations. Get consent before cloud processing, and strip EXIF metadata (GPS) before uploading.
  • Don't build identification of real people from faces without strong legal and ethical review.
  • Avoid medical, legal or safety-critical judgements from images without professional oversight.
  • Downscale images: smaller uploads use fewer tokens, less data and less time.

Use cases

Expense capture

Receipt โ†’ structured fields โ†’ user confirms โ†’ saved.

Accessibility

Draft alt text for user-posted images, edited by the poster.

Catalogue tagging

On-device labels to auto-tag product photos for search.

Frequently asked questions

Can I process camera frames in real time?

Use CameraX with ML Kit's on-device vision APIs for real-time tasks such as barcodes or text. Cloud multimodal models are too slow and costly per frame.

How large should uploaded images be?

Downscale to the smallest size that preserves needed detail, often around 1024โ€“1600 px on the long side for documents. Test accuracy against size.

Can the model read Hindi or other scripts?

ML Kit text recognition v2 supports several scripts, including Devanagari. Multimodal Gemini models handle many languages. Verify on your own samples.

Conclusion

Match the tool to the question: ML Kit vision for fixed perception tasks, on-device Image Description for private short descriptions, and multimodal Gemini with structured output for open questions and extraction. Combine OCR with text reasoning where you can, and keep users in the loop.

Next step: add voice input with Speech-to-Text and AI Voice Features.

Official references

๐Ÿ“ฑ Apps built by Yunok Tech

Real Android apps on Google Play, free to download.

See all our apps โ†’

Ready to build real Android applications?

Every AI feature still runs inside an Android app that has to be fast, reliable and well structured. Strengthen the Kotlin, Jetpack Compose and architecture skills that AI integrations depend on, then apply these AI concepts with confidence.

Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.

Explore the Android course and take your next step as an Android developer.

Share: LinkedIn X / Twitter WhatsApp