Main > Raspberry Pi & Dev Board

Detecting Human Falls Using OpenCV and Raspberry Pi - Part 1

(1/1)

OpenELAB:
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 Overview

This 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


--- Code: ---│── 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
--- End code ---

Prerequisites

Software 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 Steps

Python 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 system

--- Code: ---sudo  apt-get  update 
sudo apt-get upgrade -y 
--- End code ---

2. Install prerequisites

--- Code: ---sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev   
--- End code ---


3. Download and install Python 3.7

--- Code: ---wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz 
tar zxvf Python-3.7.1.tgz   
--- End code ---

4. Verify the Python installation

--- Code: ---cd Python-3.7.1   
sudo ./configure && sudo make && sudo make install 
--- End code ---

5. Create a Symbolic Link
    After installing Python 3.7, we can check the Python version.

--- Code: ---python --version 
python3 --version   
--- End code ---

6.Error Issues


--- Code: ---sudo apt-get install libffi-dev   
--- End code ---
Solution: “ModuleNotFoundError: No module named '_ctypes'”


7. Create a Symbolic Link
    After installing Python 3.7, you can check the Python version:

--- Code: ---python --version
python3 --version 
--- End code ---

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:

--- Code: ---which python
which python3
--- End code ---

9.Create the symbolic link:

--- Code: ---sudo mv /usr/bin/python /usr/bin/python2.7.13
sudo ln -s /usr/local/bin/python3 /usr/bin/python
--- End code ---

 10. Test the Installation


--- Code: ---ls -al /usr/local/bin/python*
python --version
--- End code ---

11. Create a Virtual Environment

--- Code: ---python -m venv pytorch
--- End code ---

  Activate the virtual environment:

--- Code: ---source pytorch/bin/activate 
--- End code ---

  Adapting the numpy Version:

Navigation

[0] Message Index

Go to full version