This tutorial shows how to run Edge Impulse computer vision models on a live Android camera feed. Frames are captured using CameraX, converted to the format your model expects, and passed to the Edge Impulse C++ classifier via JNI. Results (classification labels, bounding boxes, or anomaly regions) are drawn back over the camera preview in real time. The app supports image classification, object detection with bounding boxes, and visual anomaly detection. You switch between them by deploying a different model; the inference code structure is the same.Documentation Index
Fetch the complete documentation index at: https://docs.edgeimpulse.com/llms.txt
Use this file to discover all available pages before exploring further.

What you’ll build
An Android app that captures camera frames in real time, runs on-device inference, and renders classification labels, object detection bounding boxes, or anomaly heatmap regions as a visual overlay.Prerequisites
Before starting, make sure you have:- A trained vision model in Edge Impulse: image classification, object detection, or visual anomaly detection
- Android Studio with NDK 27.0.12077973 and CMake 3.22.1 installed
- An Android device with a camera running API 24 or later
1. Clone the repository
2. Download TensorFlow Lite libraries
3. Export your model
In Edge Impulse Studio:- Go to Deployment
- Select Android (C++ library)
- Enable EON Compiler (recommended: reduces memory and improves performance)
- Click Build and download the
.zip
4. Integrate the model
Extract the downloaded.zip and copy all files except CMakeLists.txt into the project:
5. Build and run
- Open the project in Android Studio
- Build → Make Project
- Connect your Android device
- Run the app and grant the camera permission when prompted
How it works
Camera frames flow from CameraX into anImageAnalysis use case, where they’re converted to RGB and passed to the C++ classifier. Results come back as a structured object and are rendered by a custom overlay view.
Camera setup
CameraX binds a preview stream and a frame analysis pipeline to the activity lifecycle. TheSTRATEGY_KEEP_ONLY_LATEST backpressure strategy drops frames the classifier isn’t ready to process, keeping the preview smooth:
Image processing
Each frame is converted to an RGB byte array on a background coroutine. TheImageProxy is closed immediately after reading to free the camera buffer:
Native inference
The image data crosses the JNI boundary as a byte array and is fed into the Edge Impulse classifier as a signal:Bounding box overlay
For object detection, a customView subclass draws bounding boxes and labels directly over the camera preview:
Customization
Adjust the confidence threshold
Limit inference frequency
If the classifier is slower than the camera frame rate, you can throttle inference to run at a fixed interval:Bounding box alignment
If bounding boxes appear offset from detected objects, scale them to match model and view dimensions:Troubleshooting
Low frame rate or laggy preview
Low frame rate or laggy preview
- Reduce inference frequency (run every 200–300 ms instead of every frame)
- Lower the camera resolution via
setTargetResolution() - Verify XNNPACK is not disabled in CMakeLists
- Consider a smaller model architecture
Objects not detected reliably
Objects not detected reliably
- If confidence is consistently low, try lowering the threshold slightly
- Poor lighting is a common cause if the model wasn’t trained on similar conditions
- Check that your camera resolution matches the model’s input resolution; a large mismatch degrades accuracy
App crashes on startup
App crashes on startup
- Verify TFLite libraries were downloaded and are in
app/src/main/cpp/tensorflow-lite/ - Confirm model files (
edge-impulse-sdk/,model-parameters/,tflite-model/) are all present incpp/ - Check that NDK and CMake versions match the prerequisites