Tag Archives: AI

AI on the Edge LESSON 17: Decorating and Annotating Video Frames in openCV

Welcome to AI on the Edge – Lesson 17: Decorating and Annotating Video Frames in OpenCV. In this lesson we take our live video stream from the Raspberry Pi camera and start making it really useful and professional-looking. Now that we can grab frames and display them, it’s time to learn how to draw directly on top of those frames. We’re talking rectangles, lines, arrows, circles, and crisp text overlays — all the visual elements you’ll need when you start adding real AI like face detection or object recognition.
You’ll see exactly how to use OpenCV’s drawing functions to create clean, scalable annotations that look great whether you’re running at 320×180 for maximum speed or higher resolutions like 1280×720. We cover how to control line thickness, use filled shapes, position text properly, and most importantly, how to make all your drawings scale automatically with your chosen resolution so everything stays nicely proportioned.
By the end of this lesson you’ll have the skills to draw bounding boxes around detected objects, add confidence scores, label people or items, draw tracking lines — basically anything you need to show what your AI is seeing. This is one of those foundational skills that you’ll use over and over again in your computer vision projects.As always, I encourage you to type the code along with me in the video, then start playing with colors, sizes, positions, and messages. Change things around, break it, and make it your own. That’s the best way to really learn this stuff.
So fire up your Raspberry Pi 5, grab that camera, and let’s start turning raw video frames into clear, informative, and great-looking annotated output!

 

AI on the Edge LESSON 15: Use the Raspberry Pi Camera in openCV to Create Live Video

Hey everyone, welcome to Lesson 15 of the AI on the Edge series!

In today’s lesson, we take a very important step forward. We finally bring the Raspberry Pi Camera into our OpenCV world so we can capture live video and start building real computer vision projects.  Today we learn how to pull live frames directly from the official Raspberry Pi camera using picamera2 and display them smoothly with OpenCV.

This lesson is all about building a clean, reliable foundation. I walk you through how to properly configure the Pi Camera with the modern picamera2 library — setting the resolution to 1280×720, choosing the right format, and pushing the frame rate up to 60fps. Then we bring those frames straight into OpenCV so we can see live video in a window. You’ll also learn why we use RGB888 format and how to organize your code so it stays clean as our projects get more complex.

Getting reliable live video from the Pi Camera is one of those foundational skills that opens the door to everything we’re going to do in this class — face detection, object tracking, color tracking, motion detection, and all the exciting AI projects still ahead. Once you have solid camera access, the real fun begins.

I kept this lesson straightforward on purpose. I want you to have a rock-solid base that you can build upon without fighting technical problems later. By the end of this video, you’ll have a clean, responsive live video stream running from your Raspberry Pi Camera, ready for all the computer vision magic we’re about to add in the coming lessons.

So fire up your Raspberry Pi, grab your camera module, and let’s get that live video rolling! As always, I encourage you to type the code along with me and experiment with it. Change the resolution, try different frame rates, and make it your own.

Are you ready? Let’s dive in!

In today’s lesson, this is the code which we developed:

This is the schematic we are using in these lessons:

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

AI on the Edge LESSON 14: Control LED Color With Voice Commands on Raspberry Pi 5

In Lesson 14 of AI on the Edge, we’re doing something really fun and powerful — we’re building a voice-controlled RGB LED that listens to you, changes colors on command, and even talks back with some personality! This is true edge AI running 100% locally on your Raspberry Pi with the Fusion HAT. No cloud, no internet, just fast, private, and responsive voice interaction right on your desk.

You simply speak a color — red, green, blue, cyan, magenta, yellow, off, or even quit — and the RGB LED instantly springs to life with beautiful color. But that’s not all. Every time you give a command, the system replies with a fun, playful spoken response using the Piper text-to-speech engine. It turns your Raspberry Pi into a charming little LED companion that feels alive and interactive.In this lesson, you’ll learn how to combine local Speech-to-Text with the STT library and natural-sounding Text-to-Speech with Piper. You’ll master PWM control of a full-color RGB LED through the Fusion HAT, and you’ll see how to use Python threading plus a queue to keep the voice listening running smoothly in the background without ever locking up your main program. The code is clean, well-structured, and includes proper startup greetings, graceful shutdown, and excellent resource cleanup — exactly the kind of solid practices we love in this series.What makes this project extra special is how it brings everything together. You get real-time voice recognition, instant hardware response, and spoken feedback — all happening locally on the edge. It’s fast, it’s private, and it’s incredibly satisfying to watch that LED light up exactly as you command while your Pi chats back at you.

Go ahead and watch the full Lesson 14 video, grab the complete code from the description, and build this project step by step with me. Once you have it running, I want you to play with it! Add new colors, create your own funny responses, or start thinking about how you could combine this voice control with sensors or other hardware in future projects.

This is the kind of hands-on, creative AI application that makes learning so exciting. You’re not just watching — you’re building real, useful skills that put you in the driver’s seat with artificial intelligence.

Fire up that Raspberry Pi, get your Fusion HAT ready, and let’s make some colors shine while the Pi talks back. I can’t wait to see what you create with this one!

Happy building, everyone — I’ll see you in the next lesson!

This is the schematic we are using for the project:

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

This is the code we developed in the video:

 

AI on the Edge LESSON 12: Introduction to Python Threading on the Raspberry Pi

Hey everyone, and welcome back to the AI on the Edge series!

In today’s lesson, we’re tackling one of the most important programming concepts you’ll need as we build more advanced AI and robotics projects — Python Threading.

Up until now, our programs have been pretty linear — they do one thing at a time. But as our projects get smarter and more interactive, we often need several things happening at the same time. That’s exactly where threading comes in. In this lesson, I give you a gentle, practical introduction to threading by creating a program that blinks an LED while simultaneously listening for your commands to change the blink speed — all without one task blocking the other.

You’ll see how to create a separate thread that handles user input while the main program continues blinking the LED smoothly. We also use a Queue to safely pass data between the threads. This is a foundational skill that becomes incredibly valuable later in the class when we need to run voice recognition, camera processing, sensor reading, and motor control all at the same time.

I designed this lesson to be very beginner-friendly. If you’ve never used threading before, don’t worry — I walk you through every line of code and explain why we do things the way we do. By the end of this video, you’ll have a solid understanding of how to launch background threads, manage shared variables safely, and keep your main program responsive.

This lesson is a big stepping stone in our AI on the Edge journey. The ability to run multiple tasks concurrently is what separates simple scripts from real-world intelligent systems that can listen, think, and act at the same time.

So grab your SunFounder Fusion AI Hat, hook up an LED, and get ready to take your Raspberry Pi programming skills to the next level. Once you understand threading, a whole new world of possibilities opens up!

As always, I strongly encourage you to code along with me in the video and then experiment on your own. Try adding more LEDs, change the commands, or combine it with things we’ve learned in previous lessons. That hands-on practice is where the real learning happens.

I’m really excited for you to learn this one — it’s going to make the rest of the class a lot more fun and powerful!

In today’s lesson, this is the code we developed.

 

AI on the Edge LESSON 8: Text to Speech (TTS) on the Raspberry Pi

In this video lesson I will show you how to get the Raspberry Pi to speak to you in plain English. This is our first dabbling with AI. In earlier lessons we have discussed that one of our first objectives will be to begin to audibly interact with our project through speech. The first step will be to get the Pi to talk to us. Then in future lessons we will show how to get the Pi to listen to us.

In this lesson we demonstrated simple Text to Speech (TTS) with this code.

Remember this program requires use of the AI Educational OS we flashed in LESSON #2.

As we say in the video, the first time you run the program you will get a permission error. This is because the model folders are inside a system folder and must be created as a ‘superuser’ using ‘sudo’. As shown in the video, you need to open a terminal window, and type in these commands at the command prompt (Put them in one at a time):

You only need to do that one time. Next time you run the program, all will work properly.

Then, in order to hear all the different voice models Piper offers, you can run this program, and each voice will introduce itself to you.

 

Remember in these early lessons we are using this circuit to demo our programs. Please leave this circuit put together.

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