
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 a FOMO model on-device from Unity through a native plugin
- How to use an Android C++ library deployment in a Meta Quest XR app
- How to pass pixels from a Unity camera to 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, passes the pixels to the model, and reacts to the result.1
Deploy the model as a C++ library
In Edge Impulse Studio, go to Deployment, select C++ library, and build. A wrapper in
native/ei_fomo.cpp exposes a classify function.2
Compile a native plugin for each platform
Build the wrapper as
libei_fomo.so (Android arm64-v8a, for the Quest) and libei_fomo.dylib (macOS, for the Unity Editor). The repository includes prebuilt copies of both.3
Run inference from Unity
EdgeImpulseFOMO.cs calls the plugin through P/Invoke. The inspection station classifies each bottle’s cap and treats cap_incorrect as a defect.4
React in the scene
The reject arm pushes defective bottles off the conveyor, and
cap_correct bottles pass through.Requirements
- Unity 6000.0.32f1
- A Meta Quest 3 or 3S in developer mode, or an arm64 Android device
- URP, XR Interaction Toolkit, OpenXR, and XR Hands (already included in the project)
- Android NDK r23b, to rebuild the native library with your own model
Quick start
Download the latest APK from the repository’s Releases page and sideload it onto a Quest 3 or 3S, or an arm64 Android device:Assets/Scenes/FactoryFloorDemo.unity, and press Play. One FactoryDemo Bootstrap object builds the whole scene in code, including the conveyor, inspection station, reject arm, and HUD, so you can read and adapt it in one place.
Related
Android series
The NDK and C++ SDK deployment path this example builds on.
ExecuTorch
Deploy PyTorch models to Android with ExecuTorch and Edge Impulse.