Tag Archives: Artificial Intelligenge

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 16: Control Pan/Tilt Camera Position Using Voice Commands

In AI on the Edge Lesson 16, we take a big step forward by combining voice recognition with physical motion. In this project, you will build a voice-controlled pan/tilt camera system. Using simple spoken commands such as “right,” “left,” “up,” “down,” and “quit,” you can move the Raspberry Pi camera in real time. This lesson brings together the Fusion HAT+ servo control, the Speech-to-Text (STT) capabilities we explored earlier, live video streaming with picamera2 and OpenCV, and multithreading to keep everything running smoothly.
The hardware setup is straightforward. We connect two servos to the Fusion HAT+ — one for pan (horizontal movement) on pin 2 and one for tilt (vertical movement) on pin 3. The Raspberry Pi Camera is mounted on a pan/tilt mechanism so it can physically follow your voice commands. We start the camera at a neutral position (pan = 0°, tilt = -20°) and define step sizes so the movement feels responsive but controlled.
The Python code uses two main threads: one for continuous voice listening and another for displaying the live video feed. In the listening thread, we create an STT object and continuously wait for voice input. When a command is recognized, we adjust the pan or tilt angle accordingly and immediately send the new position to the appropriate servo. The main loop captures frames from the Pi Camera, flips them for correct orientation, displays them in an OpenCV window, and checks for the ‘q’ key to exit gracefully.
This project demonstrates several important concepts working together: real-time voice command processing, servo motor control, camera streaming with picamera2 at 1280×720 resolution and 60 fps, and proper use of threading so that listening and video display do not block each other. You will also notice how we use global variables carefully to share the current pan and tilt positions between the threads.
By the end of this lesson, you will have a working voice-controlled camera that you can point anywhere you want just by talking to it. This is an excellent foundation for more advanced projects such as voice-controlled object tracking, security cameras, or interactive AI assistants that can both see and move.The complete code is provided below, along with explanations of the key sections. Feel free to experiment with different step sizes (xDelta and yDelta), starting angles, or even add new voice commands once you are comfortable with the basic version.
This is the code developed in the video lesson:

 

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.