Detecting Human Falls Using OpenCV and Raspberry Pi - Part 1
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
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
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
-
Update the Raspberry Pi system
sudo apt-get update sudo apt-get upgrade -y
sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz tar zxvf Python-3.7.1.tgz
-
Verify the Python installation
cd Python-3.7.1 sudo ./configure && sudo make && sudo make install
-
Create a Symbolic Link
python --version python3 --version
-
Error Issues
sudo apt-get install libffi-dev
python --version python3 --version
Check the locations of the python and python3.7 commands:
which python which python3
sudo mv /usr/bin/python /usr/bin/python2.7.13 sudo ln -s /usr/local/bin/python3 /usr/bin/python
ls -al /usr/local/bin/python* python --version
python -m venv pytorch
source pytorch/bin/activate
Installation and Execution
1. Steps to Install OpenCV-
opencv-python url: piwheels - opencv-python
-
opencv-contrib-python url: piwheels - opencv-contrib-python
3. Troubleshooting Installation Errors:
cd Desktop ls pip3 install
5. Install numpy Dependency
sudo apt-get install python3-h5py pip3 install numpy (Tab)
Dependencies
sudo apt-get install libhdf5-dev sudo apt-get install libatlas-base-dev sudo apt-get install libjasper-dev sudo apt-get install libqt4-test sudo apt-get install libqtgui4 sudo apt-get update
Following the above steps, OpenCV should be successfully installed: