Detect Jenga blocks in real-time: a hands-on guide with Edge Impulse and TensorFlow Lite
You’re playing Jenga. A block moves.
You’ve got your camera, your Jenga tower, and a dream: build a device/application that can detect exactly which block was removed, or if the tower is stable. No cloud. No lag. Just real‑time block detection on the edge. Sounds cool? Let’s get there.
In this guide, I’ll take you through everything you need — from collecting images, training a model with Edge Impulse’s FOMO, to turning that model into a C++ TFLite library and running it live on Android.
Overview
Step |
Tool/Tech |
Data Collection |
Edge Impulse Studio (Web or Mobile) |
Model |
FOMO (Fast Object Detection) |
Output Format |
TensorFlow Lite (C++ library) |
Deployment |
Android (via Android Studio) |
Inference |
On-device, real-time |
Sign up for Developer monthly newsletter
Join thousands of developers around the globe who receive latest news and updates from our monthly curated newsletter.
Step 1: Set Up Your Project in Edge Impulse
Head to edgeimpulse.com and create a new project. Name it something like:
Jenga_Ondevice
Choose Object Detection as the project type. This will configure your project to use bounding boxes and image-based training workflows.
Step 2: Collect Diverse, Labelled Data
What You'll Need:
- A camera (phone, webcam, or embedded device)
- A physical Jenga tower (or similar blocks)
- Edge Impulse mobile app or web uploader
Collecting Data:
Use Edge Impulse’s Data Acquisition tab or mobile app:
- Capture images in varied lighting conditions (natural light, indoor lighting, shadows)
Come for support, stay for the community
Get support from experts, connect with like-minded developers, and access exclusive virtual events.
- Vary distance: close-ups and far shots
- Vary angles: side views, top-down, diagonals
- Include 3 key states:
- Stable: Block in place
- Removed: Block visibly pulled out
- Empty: No block in the space
Tip: Capture at least 100 images per class to start.
Step 3: Label with Bounding Boxes
Use the Labeling tool in Edge Impulse:
- Draw tight bounding boxes around visible Jenga blocks
- Label them according to their state: e.g. "stable", "removed", "empty"
Label consistency is crucial. Bounding box quality directly affects detection accuracy. If possible, zoom in and label small blocks precisely.
Step 4: Design the Impulse with FOMO
Here’s where the Edge Impulse pipeline kicks in.
Add Processing Blocks:
- Image resize: e.g. 96x96 or 160x160
- Color depth: RGB (for visual patterns)
Add Learning Block:
- Select FOMO (Object Detection)
FOMO uses a single-shot detection (SSD)-style head with stride convolution, meaning it outputs a grid of class probabilities and locations in one pass. It's efficient and perfect for low-powered devices.
Train the Model:
- Set training parameters:
- Epochs: 50–100
- Learning rate: 0.001 (start here)
- Validation split: 20–30%
- Use data augmentation: flip, rotate, brightness changes
Monitor:
- Loss curve
- mAP (mean Average Precision)
- Confusion matrix
You’re aiming for balanced precision across classes.
Step 5: Export as TensorFlow Lite C++ Library
Once satisfied with performance:
- Go to the Deployment tab
- Choose TensorFlow Lite (C++)
- Click Build and download the archive
Inside the zip:
- .tflite model file
- C++ header + source wrappers
- Build scripts to integrate with embedded or Android systems
Step 6: Integrate the Model with the Project
- Extract the downloaded C++ library.
- Copy only the below extracted files into the example-android-inferencing/example_static_buffer/app/src/main/cpp directory, dont copy the CMake.txt file.
edge-impulse-sdk/
model-parameters/
tflite-model/
Cloning the Base Repository
We created an example repository that contains an Android Studio project with C++ support. Clone or download this repository:
git clone https://github.com/edgeimpulse/example-android-inferencing.git
cd example-android-inferencing
Run the Windows / Linux / OSX script to fetch resources
cd example-android-inferencing/example_static_buffer/app/src/main/cpp/tflite
sh download_tflite_libs.bat # download_tflite_libs.sh for OSX and LinuxImport the Project to Android Studio
Choose the project to import
- Open Android Studio.
- Select Open an existing Android Studio project.
- Navigate to the cloned repository and select it.
Download CPP Project from Edge Impulse
- Go to Edge Impulse Studio.
- Export your trained model as a C++ library.
- Download the exported model.
Integrate the Model with the Project
- Extract the downloaded C++ library.
- Copy the extracted files into the example-android-inferencing/example_static_buffer/app/src/main/cpp directory, dont copy the CMake.txt file.
Paste in the Test Feature Set for the CPP Test
- Obtain the test feature set from Edge Impulse Studio test impulse tab.
- Paste the test feature set into the raw_features array the native_lib.cpp licated in the cpp directory.
std::vector<float> raw_features = {
// Copy raw features here (e.g. from the 'Model testing' page)
};
Build and Run the Project
- In Android Studio, click on Build > Make Project.
- Once the build is successful, run the project on an Android device or emulator.
Step 7: Test, Iterate, Improve
You’ll quickly spot challenges:
- False positives under poor lighting
- Occlusion when hands block view
- Confusing “Removed” vs. “Empty”
Fixes:
- Add more training data for edge cases
- Retrain with weighted class loss
- Fine-tune model hyperparameters
Final Thoughts — Building Something Resilient
What you’re doing here is building a full pipeline:
Image capture → Labeling → Training → Export → On‑device inference
Edge Impulse + FOMO + TFLite makes this pipeline fast and manageable. And once you’re past the initial training & setup, you can focus your energy on refining, optimizing, and making the detection system robust to real‑world variation.
Now: go build something awesome. Maybe a smart camera that warns when the tower is unstable. Or a game scoreboard that auto‑reports which block was pulled. The possibilities are block‑by‑block endless.
You’ve created a real-time, on-device system capable of understanding the state of a Jenga tower — block by block.
This workflow can be adapted for:
- Board game automation
- Warehouse item tracking
- Embedded visual inspection
Have you tested the guide and want to share how it’s working? Join our Developer Discord and share your project with us for the chance to be highlighted!

