Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Detecting Human Falls Using OpenCV and Raspberry Pi - Part 1  (Read 887 times)

0 Members and 4 Guests are viewing this topic.

OpenELAB

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 16
  • Last login:December 06, 2024, 04:11:24 am
  • I want to build my own arcade controls!
Detecting Human Falls Using OpenCV and Raspberry Pi - Part 1
« on: November 27, 2024, 04:33:59 am »
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: [Select]
│── 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

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: [Select]
sudo  apt-get  update 
sudo apt-get upgrade -y 

2. Install prerequisites
Code: [Select]
sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev   

3. Download and install Python 3.7
Code: [Select]
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
Code: [Select]
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.
Code: [Select]
python --version 
python3 --version   

6.Error Issues

Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
which python
which python3

9.Create the symbolic link:
Code: [Select]
sudo mv /usr/bin/python /usr/bin/python2.7.13
sudo ln -s /usr/local/bin/python3 /usr/bin/python

 10. Test the Installation

Code: [Select]
ls -al /usr/local/bin/python*
python --version

11. Create a Virtual Environment
Code: [Select]
python -m venv pytorch
  Activate the virtual environment:
Code: [Select]
source pytorch/bin/activate 
  Adapting the numpy Version: