Back to All
Developer Blog

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.

Showing the workflow of the project
Fig 1: Showing the workflow of the project

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.

Create a new project and start data collection.
Fig 2: Create a new project and start data collection.

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.

Resources on how to add/collect the data
Fig 3: Resources on how to add/collect the data
  • 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.

Labeling the data
Fig 4: Labeling the data

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:

  1. Go to the Deployment tab
  2. Choose TensorFlow Lite (C++)
  3. 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 Linux

Import the Project to Android Studio

Choose the project to import

  1. Open Android Studio.
  2. Select Open an existing Android Studio project.
  3. Navigate to the cloned repository and select it.

Download CPP Project from Edge Impulse

  1. Go to Edge Impulse Studio.
  2. Export your trained model as a C++ library.
  3. Download the exported model.

Integrate the Model with the Project

  1. Extract the downloaded C++ library.
  1. 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

  1. Obtain the test feature set from Edge Impulse Studio test impulse tab.
  2. 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

  1. In Android Studio, click on Build > Make Project.
  2. 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!

Additional Resources

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries ("Qualcomm"). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.

About the Author
Akshaya Hassan Nagendra
Akshaya Hassan NagendraSoftware Applications Engineer, Tech Evangelist with Qualcomm Developer Program
Qualcomm relentlessly innovates to deliver intelligent computing everywhere, helping the world tackle some of its most important challenges. Our leading-edge AI, high performance, low-power computing, and unrivaled connectivity deliver proven solutions that transform major industries. At Qualcomm, we are engineering human progress.

Stay connected

Get the latest Qualcomm and industry information delivered to your inbox.

Subscribe
Manage your subscription

© Qualcomm Technologies, Inc. and/or its affiliated companies.

Snapdragon and Qualcomm branded products are products of Qualcomm Technologies, Inc. and/or its subsidiaries. Qualcomm patented technologies are licensed by Qualcomm Incorporated.

Note: Certain services and materials may require you to accept additional terms and conditions before accessing or using those items.

References to "Qualcomm" may mean Qualcomm Incorporated, or subsidiaries or business units within the Qualcomm corporate structure, as applicable.

Qualcomm Incorporated includes our licensing business, QTL, and the vast majority of our patent portfolio. Qualcomm Technologies, Inc., a subsidiary of Qualcomm Incorporated, operates, along with its subsidiaries, substantially all of our engineering, research and development functions, and substantially all of our products and services businesses, including our QCT semiconductor business.

Materials that are as of a specific date, including but not limited to press releases, presentations, blog posts and webcasts, may have been superseded by subsequent events or disclosures.

Nothing in these materials is an offer to sell or license any of the services or materials referenced herein.