Hi👋, welcome to this tutorial on using the Raspberry Pi 4B to detect if a person has fallen! This project series will be divided into three parts, and today you will enter the first part, which focuses on how to prepare, run the code, and implement the core functionality.
Next, we will walk you through the following steps 📜, diving deep into the source code and making it easy for you to get started with this project! Ready? Let’s get started 🚀!
- 📝 Project Overview
-✨ Features
-🏗 Project Structure
-🚀 Installation and Running
-🔧 Usage Instructions
-🔮 Next Episode Preview
-Note: This project is a modification of the KNN 3D Human Skeleton Recognition project, demonstrating the complete tutorial on how to run it on the Raspberry Pi.
Project OverviewThis project uses Raspberry Pi to the first connect to the PC via SSH and transfer important files like VSCode. Then, after importing the code package into VSCode on the Raspberry Pi, the code is run in sequence. First, the train code is executed to extract and train human key points, and the key point positions are saved to a CSV file. Using this CSV file, we can test the code by uploading a video or opening the Raspberry Pi camera. By standing in front of the camera and performing actions, the system will detect if a fall has occurred. If a fall is detected, it will display "fall"; if no fall is detected and the key points are normal, it will display "normal."
This article also provides detailed instructions on installing VSCode for programming, using FileZilla for file transfer, and using MobaXterm for remote connection to the Raspberry Pi.
The article will summarize common error issues encountered and address Python version incompatibility problems.
Features-📏 Detect human key points.
-🎉 Determine if a fall has occurred, improving the rescue rate.
Project Description Files│── test.py # Camera testing code
│── First_train.py # Step 1: Training file
│── second_KNN.py # Step 2: Calling the KNN model
│── Third_testing.py # Step 3: Open the camera for testing or upload a video
│── GIF # Result display
PrerequisitesSoftware Dependencies: Arduino IDE、VScode or text.
Hardware Requirements: USB-C data cable, Raspberry Pi 4B, Camera for Raspberry Pi, etc.
Library Dependencies:opencv、pandas.
Arduino IDE Installation StepsPython Version Compatibility Issue
⚠️ Important: Do not uninstall the pre-installed Python version on Raspberry Pi OS, as it will cause system instability.
Currently, the Python version provided in the Raspberry Pi system is the latest (Python 3.11). If compatibility issues arise, here are steps to reinstall and adjust the Python version
Recommended Version:
Installing Python 3.7 is suggested for better stability and compatibility with Raspberry Pi applications.
1. Update the Raspberry Pi systemsudo apt-get update
sudo apt-get upgrade -y
2. Install prerequisitessudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev
3. Download and install Python 3.7
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
tar zxvf Python-3.7.1.tgz
4. Verify the Python installation
cd Python-3.7.1
sudo ./configure && sudo make && sudo make install
5. Create a Symbolic Link
After installing Python 3.7, we can check the Python version.
python --version
python3 --version
6.Error Issues
sudo apt-get install libffi-dev
Solution: “ModuleNotFoundError: No module named '_ctypes'”
7. Create a Symbolic Link
After installing Python 3.7, you can check the Python version:
python --version
python3 --version
8.To simplify usage, create a symbolic link for Python 3.7.1 pointing to the Python command.
Check the locations of the python and python3.7 commands:
which python
which python3
9.Create the symbolic link:
sudo mv /usr/bin/python /usr/bin/python2.7.13
sudo ln -s /usr/local/bin/python3 /usr/bin/python
10. Test the Installation
ls -al /usr/local/bin/python*
python --version
11. Create a Virtual Environment
python -m venv pytorch
Activate the virtual environment:
source pytorch/bin/activate
Adapting the numpy Version: