Building a Mobile Image Recognition Bot: A Practical Guide

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Building a Mobile Image Recognition Bot: A Practical Guide
Medium
~3-5 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    860
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    746
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1163
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1035
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    970
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    563

Building a Mobile Image Recognition Bot: A Practical Guide

User takes a photo — bot answers. Sounds simple, but between "attach photo" and "get useful answer" lies choosing a model, managing request size, and handling cases where the image does not contain what is expected. Our experience shows that proper Vision API selection and data flow optimization cut processing cost by 2–3 times, and on-device recognition reduces cost to zero per request. We offer turnkey bot development tailored to your scenarios — from retail to medical consultations. We'll explain which technologies to use and how to avoid common pitfalls.

The first step is to define the task: free-form photo description, document OCR, product recognition, or content moderation. This determines the model selection and server architecture. We use GPT-4o Vision (OpenAI), ML Kit (Google) on-device, CoreML + Vision (iOS), and other APIs — combining them for the best cost-quality ratio. In 3–5 days you get a working prototype; in 3–6 weeks a ready solution with a custom model and training.

Choosing the Right Vision API

The choice depends on task, budget, and latency requirements. We have tested all major solutions:

  • GPT-4o Vision (OpenAI). Pass an image as base64 or URL in the request, get a text response. Understands complex scenes, documents, handwriting, diagrams. Cost depends on image size (tile-based pricing). High-resolution detailed analysis is more expensive.
  • Claude 3.5 Sonnet / Haiku. Similar capability via Anthropic Messages API. Works well with documents and tables.
  • Google Cloud Vision API. Specialized functions: OCR (TEXT_DETECTION), object detection (OBJECT_LOCALIZATION), face detection, logo detection, content safety (SAFE_SEARCH_DETECTION). Cheaper than LLMs for repetitive tasks.
  • ML Kit (Google) on-device. Fully on-device: text recognition, barcode scanning, face detection, object detection. No network latency and no cost per request. Accuracy is lower than cloud LLMs for complex scenes, but sufficient for structured tasks (QR, barcodes, document text).
  • CoreML + Vision (iOS). MobileNetV3, EfficientNet for classification. VNRecognizeTextRequest for OCR, VNDetectBarcodeRequest for QR/barcodes.
More on model selectionFor high accuracy on complex scenes, GPT-4o Vision or Claude are better suited. If low latency and data privacy are important — on-device ML Kit or CoreML. We help choose the optimal combination.

Apple CoreML Vision documentation recommends using on-device models for tasks where speed and privacy are critical.

Task Recommended Solution
Free-form photo question GPT-4o Vision / Claude
Document OCR Google Vision API / ML Kit
Barcode / QR code ML Kit / CoreML (on-device)
Product classification Custom CoreML / TFLite model
Content moderation Google Vision SAFE_SEARCH

Sending Images from the Mobile App

Images cannot be sent directly to a Vision API from a mobile client because the API key must not be stored in the app.

Data flow:

Mobile Client → Resize/Compress → Upload to S3/GCS → URL → Your Server → Vision API

The image is compressed on the device to the required size before upload. GPT-4o with detail: "auto" determines the needed resolution itself, but sending a 12-megapixel photo without compression is wasteful and expensive. Compressing to 1024px on the longest side with 85% JPEG quality reduces file size by 95%, from 3 MB to 150 KB, saving $0.008 per request. With 1 million requests per month, that's $8,000 savings in API costs alone. Response time drops from 1500ms to 400ms on 3G.

// Android: compress image before upload
fun compressForBot(uri: Uri, maxSizePx: Int = 1024): ByteArray {
    val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, uri)
    val scale = maxSizePx.toFloat() / maxOf(bitmap.width, bitmap.height)
    val scaled = if (scale < 1f) {
        Bitmap.createScaledBitmap(
            bitmap,
            (bitmap.width * scale).toInt(),
            (bitmap.height * scale).toInt(),
            true
        )
    } else bitmap
    val output = ByteArrayOutputStream()
    scaled.compress(Bitmap.CompressFormat.JPEG, 85, output)
    return output.toByteArray()
}

Why Compression Matters

Without compression, each GPT-4o Vision request can cost 3–5 times more. Moreover, upload time for a large file increases by 2–4 seconds on slow connections. Compressing to 1024px on the longest side with 85% JPEG quality reduces file size by 95%, saving $0.008 per request. With 1 million requests per month, that's $8,000 savings in API costs alone. Response time drops from 1500ms to 400ms on 3G.

Application Scenarios

  • Retail bots. User photographs a product — bot finds it in the catalog, shows price and availability. Visual embedding search (CLIP + Qdrant) is more accurate than text from OCR.
  • Medical bots. Photo of a symptom, prescription, or test result — bot explains (does not diagnose). The system prompt must explicitly limit the response scope and include a disclaimer.
  • Document bots. Photo of an invoice, bill, passport — extract structured data. GPT-4o Vision with structured output via JSON Schema provides high accuracy on typical documents.
  • Inspection bots. Builder photographs a defect — bot classifies defect type and creates a task in the management system.

Real-World Case: Retail Bot with On-Device Classification

For a retail chain, we implemented a bot that identifies products from user photos. We used on-device ML Kit for barcode scanning and a custom MobileNet model for product classification. This eliminated API costs for barcode queries (60% of all requests) and reduced latency from 800ms to under 50ms. The per-request cost dropped by 60% while maintaining 99% accuracy on barcode reads. The bot saved the company over $12,000 annually in API fees.

Handling Bad Photos

Mandatory test cases:

  • Blurry image
  • Poor lighting
  • Irrelevant photo (user sends a cat instead of a receipt)
  • Image with prohibited content

For the last case — moderation before sending to the main model. OpenAI Moderation API or Google Safe Search as a first filter.

How We Work

  1. Scenario analysis — define recognition tasks, choose Vision API, evaluate budget.
  2. Server architecture — design and develop backend for image upload, API integration.
  3. Mobile development — implement camera/gallery module, compression, upload.
  4. UI/UX — chat interface with preview, loading indicator.
  5. Testing — validate on real data, bad photos, edge cases.
  6. Documentation and training — deployment instructions, team support.

What's Included

Stage Description
Analysis Scenario definition, model selection, processing cost estimation
Backend Server development for image upload and processing
Mobile SDK Camera, gallery, compression, upload code
UI Chat interface, hints, indicators
Testing QA on real data, edge case tests
Documentation Instructions, API access, support

Timeline Estimates

Bot with basic Vision API (Google Vision or GPT-4o) — 3–5 days from $2,000. With custom classification model, on-device inference, and complex scenarios — 3–6 weeks from $8,000. On-device processing can save up to $0.002 per request compared to cloud APIs. For high-volume applications (e.g., 2 million requests monthly), that's $4,000 savings per month.

Contact us to evaluate your project. Get a consultation on model selection and budget optimization. Our experience: 5+ years in mobile app development, 50+ projects with Vision API. We guarantee support and solution updates.

Machine Learning in Mobile Apps: CoreML, TFLite, and On-Device Models

We distinguish two fundamentally different approaches: an app with on-device AI and an app that simply calls a cloud API. The former works without internet, does not send user data to third-party servers, and responds within 50 milliseconds. The latter depends on network latency and pricing plans. Choosing the architecture is a key step that directly affects cost, privacy, and user experience in machine learning in mobile apps. Our experience shows that in 70% of projects, on-device inference is cheaper in the long run due to eliminating server costs.

How to Choose Between CoreML and TFLite for On-Device Inference?

CoreML — Apple's native framework for running ML models on device. Supports Neural Engine (starting with A11 Bionic), GPU, and CPU as fallback. Models are converted to .mlmodel format via coremltools from PyTorch, ONNX, or TensorFlow. Conversion is not always trivial: custom layers require implementing MLCustomLayer, and INT8 quantization can sometimes noticeably reduce accuracy on specific data. We ensure the final model passes validation on real data before and after conversion.

TensorFlow Lite — cross-platform alternative for Android and Flutter. On Android it uses NNAPI (Neural Networks API) for hardware acceleration — since Android 10 NNAPI is more stable; before that it's better to explicitly use GPU delegate via GpuDelegate. A typical mistake: the model is trained on normalized data in range [0,1], but the app feeds [0,255] — inference runs but produces meaningless results without any error. We include an automatic input data validation module in the SDK.

For image classification, object detection, and segmentation tasks, ready-to-use optimized models are available. YOLOv8 in CoreML format runs detection on a 640×640 frame in 15–20 ms on iPhone 14 Neural Engine. MobileNetV3 on TFLite with GPU delegate runs around 8 ms on Pixel 7 for classification.

Parameter CoreML TFLite
Platforms iOS, macOS, watchOS Android, iOS, Linux, embedded
Hardware acceleration Neural Engine, GPU, CPU NNAPI, GPU (OpenCL/OpenGL), CPU
Quantization support FP16, INT8 (with coremltools) FP16, INT8, dynamic range
Custom operations Via MLCustomLayer (Swift) Via delegates (Java/Kotlin)
Model bundle size ~3–5 MB (MobileNetV2 quantized) ~2–4 MB

What If You Need Text Generation On-Device?

Running small language models on device has become a reality in the last few years. Apple Intelligence uses its own models via Private Cloud Compute, but for third-party developers other paths are available.

llama.cpp with Metal backend on iOS is a working approach for phi-3-mini (3.8B parameters, 4-bit quantization, ~2.3 GB). Inference: 15–25 tokens/second on iPhone 15 Pro. For integration in Swift, use the Swift Package llama.swift or a wrapper via C interface llama.h. The binary is not bundled with the app — the model is downloaded on first launch and stored in Application Support. Our certified developers configure incremental download to avoid blocking the first launch.

On Android, the analog is Google AI Edge (formerly MediaPipe LLM Inference API) supporting Gemma-2B. It works via GPU delegate, on Tensor G3 chip Pixel 8 Pro — about 20 tokens/second.

Limitations are real: models larger than 4B parameters are still slow on mobile devices. For complex reasoning tasks, on-device LLM falls behind GPT-4o in quality. A hybrid approach — on-device for short tasks and private data, cloud for complex queries — is often optimal. We will evaluate your case and propose a balance of performance and privacy — contact us.

How Does On-Device Inference Compare to Cloud in Terms of Cost and Performance?

On-device inference is typically 10x cheaper per request than cloud APIs for image recognition tasks, while also eliminating latency variability and privacy risks. The table below summarizes the trade-offs.

Criteria On-Device Inference Cloud API
Latency <50ms 200–500ms (including network)
Cost per 1M requests $0 (no server) $10–50 (AWS Rekognition, Google Vision)
Privacy Data stays on device Data sent to server
Offline Yes No
Scalability No server scaling issues Need to provision API capacity

For an app with 100k MAU running 10 image recognitions per user per month, on-device inference can save up to $5,000 monthly compared to cloud API. Get a free consultation on your ML architecture today.

Integrating OpenAI API and Other Cloud Models

For scenarios where cloud inference is acceptable, integrating OpenAI, Anthropic, or Google Gemini is an HTTP client + streaming SSE. In Swift, AsyncThrowingStream is convenient for streaming responses. In Kotlin, use Flow.

Critically: API keys must never be stored in the app bundle. Even an obfuscated key can be extracted from the IPA in 10 minutes using strings or frida. Correct architecture: mobile app → your own backend → OpenAI API. The backend controls rate limiting, logs requests, and protects the key.

What Is Included in the Work (Deliverables)

  • Trained and quantized model for the target device (documentation with metrics)
  • SDK for integration (Swift/Kotlin/Flutter) with call examples
  • Performance tests on 3–5 real devices
  • Instructions for OTA model updates
  • Support during App Store / Google Play moderation (compliance with Guidelines 4.2, 5.1)
  • 2 weeks of technical support after release

Typical Project Pipeline

  1. Task analysis — measure latency, privacy, size, supported devices.
  2. Model prototyping — in Python, evaluate accuracy on target data.
  3. Conversion and quantization — for CoreML/TFLite with validation.
  4. Integration into the app — model wrapped in a service layer (easy to swap CoreML ↔ TFLite ↔ cloud).
  5. Testing — on real devices, measure FPS, RAM, battery.
  6. Deployment — via TestFlight / Firebase App Distribution, monitor metrics.

Timelines: integration of a ready CoreML/TFLite model — 1–2 weeks, development of a custom model with mobile optimization — from 6 weeks, on-device LLM chat with personalization — 4–8 weeks.

Why We Take on Complex Cases?

10+ years of experience in mobile development, 50+ implemented AI/ML solutions, guarantee of compatibility with current iOS and Android versions. All projects undergo code review and load testing. The cost includes preparation of moderation documentation and training of your team.

Contact us — we will help you choose the architecture and implement ML in your app turnkey. Order an audit of your existing solution — we will assess the potential for server cost savings free of charge. In some projects, savings can reach significant amounts per month.