Skip to content

+49 1626571232

info@openelab.io

🚀 Free Shipping from 50€ in EU / 80€ Worldwide

Detecting Human Falls Using OpenCV and Raspberry Pi - Part 1

26 Nov 2024 0 Comments
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.  

Raspberry Pi 4

Raspberry Pi 4B

View Product
Camera for Raspberry Pi

Camera for Raspberry Pi

View Product
 

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



✔ Copied!

 

Prerequisites

      

    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
    sudo  apt-get  update  
    sudo apt-get upgrade -y  
    
    
    
    ✔ Copied 
    2. Install prerequisites
      sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev    
      
      
      ✔ Copied!
      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   
      
      
      ✔ Copied!
      1. Verify the Python installation
      cd Python-3.7.1    
      sudo ./configure && sudo make && sudo make install     
      
      
      ✔ Copied!
      1. Create a Symbolic Link
          After installing Python 3.7, we can check the Python version.
      python --version  
      python3 --version   
      
      
      ✔ Copied!
      1. Error Issues

        sudo apt-get install libffi-dev     
        
        
        ✔ Copied!
            
            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  
          
          
          ✔ Copied!
          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
          
          
          ✔ Copied!
             
          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
          
          
          ✔ Copied!
          10. Test the Installation

            ls -al /usr/local/bin/python*
            python --version
            
            
            ✔ Copied!
                  
              11. Create a Virtual Environment
              python -m venv pytorch
              
              
              ✔ Copied!
                 Activate the virtual environment:
              source pytorch/bin/activate  
              
              
              ✔ Copied!
                 
                 Adapting the numpy Version:
                  
                   

               

              Installation and Execution

              1. Steps to Install OpenCV
              Download opencv-python and opencv-contrib-python
              2. Check the suitable OpenCV version for your Raspberry Pi using the following command:
                 

              3. Troubleshooting Installation Errors:
                   
                4. To install the package on the desktop, navigate as follows:

                    

                cd Desktop  
                ls  
                pip3 install 
                
                
                ✔ Copied!

                  5. Install numpy Dependency
                    sudo apt-get install python3-h5py  
                    pip3 install numpy (Tab)  
                    
                    
                    ✔ Copied!

                         

                    Dependencies

                    Install Other OpenCV 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  
                    
                    
                    ✔ Copied!
                        
                    When the confirmation screen appears, press Enter directly without typing "y":
                        
                        
                    Following the above steps, OpenCV should be successfully installed:
                      
                       
                    Install vscode:
                       
                           

                     

                    Prev Post
                    Next Post

                    Leave a comment

                    All blog comments are checked prior to publishing

                    Someone recently bought a

                    Thanks for subscribing!

                    This email has been registered!

                    Shop the look

                    Choose Options

                    Edit Option
                    Back In Stock Notification
                    this is just a warning
                    Login
                    Shopping Cart
                    0 items
                    RuffRuff App RuffRuff App by Tsun