Tag Archives: AI fusion Kit

AI on the Edge LESSON 54: Custom Hand Gesture Recognition and Dynamic NeoPixel Control

Welcome back, everyone! This is Paul McWhorter from TopTechBoy.com, and welcome to Lesson 54 in our AI on the Edge series.

In this lesson, we are taking our hand gesture recognition system to the next level by connecting it directly to real physical hardware! We’re going to take the normalized vector distance calculations and MediaPipe hand-tracking models we’ve been building over the past few lessons, and use them to drive a 12-LED NeoPixel Ring via SPI on the Raspberry Pi in real time.

If you’re following along in the series, pull up a chair, get yourself a nice hot cup of iced coffee, and let’s get right into it!

What We Are Building Today

In previous lessons, we learned how to extract 3D landmark coordinates from MediaPipe, scale them by the palm length to achieve scale-invariant gesture tracking, and store those relative Euclidean distances into a pickle database (gestureNEOPIXEL.pkl).

In Lesson 54, we map those live gesture detections directly to non-blocking LED animation patterns:

  1. Fist: Pulses a dynamic red “charge” sine wave.

  2. Open Palm: Drives the NeoPixel ring at full intensity white beacon.

  3. Peace Sign (✌️): Runs a dual-spinner pattern with opposing green and blue tracer LEDs over a low background red glow.

  4. Thumbs Up: Illumination of a solid, bright green “success” status.

  5. Point: Sweeps a fast green radar chaser dot across a red background array.

  6. Rock / Metal (🤘): Generates a smooth, sinusoidal cyan-to-green energy pulse.

  7. OK Sign: Cycles through a full spectrum RGB rainbow wheel.

  8. Unknown / Default: Gracefully turns off all LEDs.

Hardware Setup & Wiring (SPI Interface)

To ensure high frame rates without flickering, we drive our NeoPixels over the SPI bus using the neopixel_spi library.

Wiring Diagram Guide

  • NeoPixel VCC: Connect to 5V power supply (ensure adequate power if driving high brightness).

  • NeoPixel GND: Common ground with the Raspberry Pi GND pin.

  • NeoPixel DIN (Data In): Connect to GPIO 10 (SPI0 MOSI) on the Raspberry Pi pinout (Physical Pin 19).

Note: Ensure SPI is enabled in your Raspberry Pi system configuration (sudo raspi-config -> Interfaces -> SPI).

⌨️ Interactive Keyboard Controls

While running the main video processing loop, you can dynamically manage your trained gestures directly from your keyboard without interrupting the camera feed:

  • SPACE: Capture and train/overwrite the current gesture showing on screen.

  • T: Prompt the terminal to type in and add a brand-new gesture name on the fly.

  • D: Prompt the terminal to remove/delete an existing gesture from the active dataset.

  • Q: Cleanly turn off all NeoPixel LEDs, save the updated gesture data, and terminate the program.

Complete Python Source Code

Below is the complete, fully commented Python script for Lesson 54.

Homework Assignment

Your homework for this lesson is to modify the updateNeoPixels() function to add two new custom hand gestures of your own creation! Try implementing custom animations like a warm candle flicker or a pulsating dual-color pattern. Leave a link to your solution videos in the comments below!

AI on the Edge LESSON 37: Using RTSP and IP Cameras in OpenCV on Raspberry Pi 5

The code below shows the work we did in this lesson.

AI on the Edge Lesson 37: Using RTSP and IP Cameras in OpenCV on Raspberry Pi 5

Hey guys! Welcome back to our AI on the Edge series. In our previous lessons, we’ve had a blast working with standard USB webcams, but if you are building a real-world computer vision application, an automation rig, or a security monitoring setup around your home or farm, USB cables just aren’t going to cut it. You need to pull video feeds from remote IP cameras using the Real-Time Streaming Protocol (RTSP).

Today, we are taking that exact step on the Raspberry Pi 5, connecting to an IP camera, streaming the feed smoothly into OpenCV, and—most importantly—solving the dreaded latency problem that plagues RTSP feeds.

The Big Challenge: Conquering RTSP Latency

If you’ve ever tried pulling an RTSP stream into OpenCV straight out of the box, you’ve probably noticed something frustrating: the video lags behind real-time, sometimes by several seconds or even tens of seconds.

Why does that happen? Because by default, FFmpeg and OpenCV buffer incoming frames to ensure smooth playback. But when you are doing computer vision, AI inferencing, or real-time tracking on the edge, you don’t want old history—you want right now.

To fix that, we pass the cv2.CAP_FFMPEG backend flag and immediately flush the buffer by setting the property to 0. This forces OpenCV to drop the backlog and grab the absolute newest frame available from the camera stream, keeping your Pi 5 processing live data in real-time.

Understanding the Script Structure

Let’s break down the key parts of today’s implementation:

  • Credentials & Resolution: We import a separate secret file to keep our camera IP addresses, usernames, and passwords safe and out of public repositories. We lock our resolution at 1280×720 to balance crisp detail with the Pi 5’s processing overhead.
  • Smooth FPS Calculation: Instead of a jittery raw frame-rate readout, we use an exponential moving average to give us a stable, readable performance metric on screen.
  • The Display Window: We configure a GUI window using OpenCV’s window flags so we can easily position and resize our output feed on the desktop.

Drop Your Questions Below

Working with network streams can sometimes be tricky depending on your specific camera’s firmware, codec settings, and network stability. If you run into any connection drops or lag spikes on your Raspberry Pi 5, drop a comment on the video!

Keep building, stay creative, and I will see you guys in Lesson 38!

Here is the code developed in the video

 

AI on the Edge LESSON 11: Control LED on Raspberry Pi With Voice Commands

In today’s lesson, we’re taking our first exciting step into giving our Raspberry Pi the ability to understand and respond to our voice. That’s right — we’re going to control a physical LED using nothing but spoken commands! This is a huge milestone in the class because it marks the beginning of building truly interactive AI projects that can listen to us and take action in the real world.

Using the SunFounder Fusion AI Hat’s built-in microphone and the excellent STT (Speech-to-Text) library, we create a simple but powerful voice assistant that can turn an LED on and off with commands like “on”, “off”, and “quit”. I walk you through every single line of the code so you can clearly see how we capture voice input, process the command, and control real hardware.

This lesson is intentionally straightforward because I want you to build a strong foundation. Once you understand how to take a voice command and turn it into physical action, we can start adding more complexity — like controlling multiple devices, adjusting brightness, or even combining voice control with computer vision in future lessons.

One of the things I love most about this project is how it makes the Raspberry Pi feel “alive.” Instead of clicking buttons or typing commands, you can now talk directly to your project. This is the kind of interaction that makes edge AI projects so much fun and so powerful.

By the end of this lesson, you’ll have a working voice-controlled LED and the confidence to start expanding your voice control skills. This is exactly the kind of capability we need as we move forward in the AI on the Edge journey — giving our intelligent systems natural, human-friendly ways to interact with us.

So grab your Fusion AI Hat, hook up that LED, and let’s turn your Raspberry Pi into a voice-controlled device! As always, I strongly encourage you to code along with me in the video and then play around with the program. Try adding more commands, control multiple LEDs, or even have it say something back to you.

This is where things start getting really fun. Let’s get that LED responding to your voice!

This is the schematic of the circuit we are using for our AI class. We go into great detail on this schematic in LESSON #5 if you want to learn more about it.

Fusion Hat Circuit Diagram
This is the circuit we will use moving forward in the class

Now this is the code we developed in this lesson:

 

AI on the Edge LESSON 5: Understanding Fusion AI Hat+ For Raspberry Pi

In today’s lesson we will become familiar with the capabilities of the Fusion AI Hat+ for the Raspberry Pi. This hat will be a core part of our class moving forward. The hat makes it easy to get data from the outside world, and to control things in the outside would. We will get an understanding of the core capabilities of the board, and your homework will be to build the first circuit with the board.  This schematic shows the various parts of the board:

Fusion AI Hat for Raspberry Pi Schematic

Then for the homework, we need you to go ahead and build this circuit. This circuit will allow us to learn how to make Digital Output commands, PWM commands, and how to read analog inputs.

Fusion Hat Circuit Diagram
This is the circuit we will use moving forward in the class