Category Archives: Python

Object Detection Using YOLO and RTSP Camera on Raspberry Pi 5

 

OK guys, you spoke, and I listened. You all are asking for a lesson on how to do object detection on a Pi 5 using YOLO and an IP Camera. Well, you are about to get what you asked for. We will make this work, or we will DIE TRYING. Never fear, once you watch the video you will both understand and be able to do it on your own. First, I am assuming you watched our previous lesson where I showed you how to do the basic install and setup of YOLO. If not, never fear, I have the commands below. NOTE: This tutorial is geared towards bookworm OS. I strongly suggest you start with a fresh bookworm SC card, as there are many dependencies, and it is most likely to work if you start exactly where I am starting . . . with a fresh OS. Thes these are the commands I shared last week to get YOLO up and working: (just open a terminal, and paste these commands one at a time)

Now, I will explain this code, and will help you configure it for your cameras, but you will need to open up thonny, and paste in the following code as a start. IMPORTANT, as mentioned above, you need to set interpreter in thonny to the virtual environment set up in the process above. If this is not familiar to you, go back and watch last weeks lesson (click previous at the bottom of this post). Without further adue, here is the code we will work with today:

The video explains everything, please watch it!

 

Ultimate 9-axis Program for Easily and Accurately Calibrating a 9-axis IMU on Arduino

In this video lesson we show how to easily calibrate a 9-axis IMU. We are using the GY-87 IMU module which contains a MPU6050 for measuring acceleration and rotational velocity, and the QMC5883L magnetometer. In this work, we have three programs. The first is simple arduino program for measuring and printing the data from the 9 sensors. Then, the second program is a python program on your PC which will allow you to simply and accurately calibrate the 9 sensors, from the data coming from the first program. Then the third program is a program on the arduino that reads the data from the sensors, and then uses the calibration data that was generated to create accurate, calibrated sensor data.

This is the schematic of the circuit we are working with:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

Then this is the arduino code we use to calibrate the sensors:

This next program is to be run on your PC. It is a python program that will read the data coming from the arduino, and will then help you calibrate your sensors.

Then finally we take the calibration parameters from the python program, and incorporate them on the Arduino side to allow reading the data from the sensors, and reporting calibrated numbers. Remember, in the program below, you should use your calibration parameters instead of mine. That is, edit the program below for your specific calibration numbers.

 

Python Program to Convert GPS Log file into a KML File for Display on Google Earth

In this video lesson we show you how you can transfer data from your Raspberry Pi Pico W GPS Project to your PC for display on Google Earth. This program transfers the Pi Pico GPS Log file to your PC, and as the transfer is done, the program converts the log.txt file into a .kml file for display on Google Earth.

 

Improving Digital Compass Accuracy With a Low Pass Filter

In this video lesson we add a low pass filter to our calibration and digital compass program. This allows more precise calibration, and removes the jitter from the digital compass display. We continue to use the QMC5883L 3-Axis Magnetometer, which is on our GY-87 IMU module. We are using the following schematic for our project:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

We collect the data using the GY-87 connected to an Arduino. Below is the simple program which takes the magnetometer data and sends it to the serial port.

The code for the Python side to do the calibration and display a Digital Compass is:

 

Calibrated Compass Display in Python and PyQt5

In this video lesson we develop a Graphical Digital Compass using python and PyQt5. The data comes from a QMC5883L magnetometer connected to an arduino. The magnetometer is on the GY-87 IMU module. The arduino sends the raw data to python. With the raw data in Python, we then calibrate the sensor, and create a graphical representation of a digital compass. The circuit schematic we are using is:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

The simple program for collecting the raw data on Arduino is:

On the python side, this is the code we developed which both calibrates the magnetometers, and displays a Digital Compass.