Example repository
Unity project, native plugin sources and a prebuilt APK.
Public Edge Impulse project
Clone the bottle-cap FOMO model into your own account.
What you’ll learn
- How to run an Edge Impulse FOMO model on-device from Unity through a native plugin (no cloud calls).
- How the same Android C++ SDK deployment powers a Meta Quest XR experience.
- How to feed pixels from a Unity camera into the model and act on the result in the scene.
How it works
A virtual “inspection camera” in Unity renders the bottle at the inspection point, hands the pixels to the Edge Impulse model, and reacts to the result.1
Deploy the model as a C++ library
In Edge Impulse Studio, go to Deployment → C++ library and build. A thin wrapper (
native/ei_fomo.cpp) exposes a classify entry point.2
Compile a native plugin per platform
Build the wrapper to
libei_fomo.so (Android arm64-v8a, for the Quest) and libei_fomo.dylib (macOS, for the Editor). Prebuilt libraries are committed in the repository.3
Run inference from Unity
EdgeImpulseFOMO.cs P/Invokes the plugin; the inspection station classifies each bottle’s cap and flags cap_incorrect as a defect.4
React in the scene
Defective bottles are pushed off the conveyor by a reject arm and shatter on impact, while
cap_correct bottles pass through.Requirements
- Unity 6000.0.32f1
- A Meta Quest 3 / 3S in developer mode (or an arm64 Android device)
- Packages (already in the project): URP, XR Interaction Toolkit, OpenXR, XR Hands
- To rebuild the native library from your own model: the Android NDK r23b
Quick start
Download the latest APK from the repository’s Releases page and sideload it onto a Quest 3 / 3S (or an arm64 Android device):Assets/Scenes/FactoryFloorDemo.unity, and press Play to run it in the XR Device Simulator. A single FactoryDemo Bootstrap object builds the whole scene in code, including the conveyor, inspection station, reject arm, and HUD, so it is easy to read and adapt.
Related
Android series
The NDK + C++ SDK deployment path this example builds on.
ExecuTorch
Deploy PyTorch models to Android with ExecuTorch and Edge Impulse.