openpose represents the first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints (in total 135 keypoints) on single images. This project was deployed on a Jetson Nano card (NVIDIA). But, the same steps can be followed to deploy it on a laptop.
- System Configuration
- Installing Prerequisites
- Building OpenPose
- Running OpenPose
- Resources
This step is highly recommended if you're facing errors caused by lack of RAM. If it's not the case, you can skip this step. First we have to turn off all swap processes :
sudo swapoff -a
Now, we will define the swap size:
sudo dd if=/dev/zero of=/swapfile bs=1G count=3
In my case, I chose the block size (bs) to be equal to 1Gb and the number of blocks(count) to be equal to 3. So, the swap size is defined to be 3Gb. You can define those 2 attributes as you like. Then, we have to change the permissions of the swapfile :
sudo chmod 600 /swapfile
Make the file usable as swap:
sudo mkswap /swapfile
Then, activate the swapfile :
sudo swapon /swapfile
Open the file /etc/fstab:
sudo gedit /etc/fstab
and add the new swapfile if it isn’t already there :
/swapfile none swap sw 0 0
To be sure that everything went right, run this command to check the swap :
grep SwapTotal /proc/meminfo
Anaconda should NOT be installed on your system because it uses a protobuf version that is not compatible with Caffe. So, we have to remove Anaconda and all its files :
rm -rf anaconda3/
First, we have to download the .deb file from this Link. Then, run these commands :
cd Downloads
sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
Now, we open the bashrc file :
sudo gedit ~/.bashrc
Then, we add these lines at the bottom of the file :
# Add this to your .bashrc file
export CUDA_HOME=/usr/local/cuda
# Adds the CUDA compiler to the PATH
export PATH=$CUDA_HOME/bin:$PATH
# Adds the libraries
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
To make sure that there's no errors occured, type these commands :
source ~/.bashrc
nvcc --version
Now, you should see something like this :
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on ...
Cuda compilation tools, release 10.0, Vxxxxx
First, we have to download CuDNN version 7.5 from this Link (CuDNN Library for Linux). Then, unzip it and copy its content in the cuda folder (default /usr/local/cuda/). You can use the cp command to do so :
sudo cp -r <source_path> <destination_path>
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig
sudo apt update
sudo apt install python3-pip
pip3 –version
sudo apt-get install python3-numpy
cd path/to/openpose/root/folder
sudo bash ./scripts/ubuntu/install_deps.sh ## Prerequisites
sudo apt install caffe-cuda
Uninstall the current CMake version :
sudo apt purge cmake-qt-gui
Install OpenSSL :
sudo apt install libssl-dev
Install the following package :
sudo apt-get install qtbase5-dev
Download the latest release of CMake from this Link (called cmake-X.X.X.tar.gz). Unzip it , go inside that folder and open a terminal :
./configure –qt-gui #make sure no errors occurred
./bootstrap && make -j`nproc` && sudo make install -j`nproc`
sudo apt-get install libopencv-dev
pkg-config --modversion opencv #check the version
sudo apt-get update -y
sudo apt-get install -y libatlas-base-dev
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose
cd 3rdparty
git clone https://github.com/CMU-Perceptual-Computing-Lab/caffe.git
git clone https://github.com/pybind/pybind11.git
The authors of OpenPose provided pretrained models. You can find them in this Link. In this demo we will use the Body_25 pretrained model. So, you have to download it then place it into models/pose/body_25.
Open CMake , specify the source directory path and the build directory path , then click "configure" (enable BUILD_PYTHON Flag) and finally click "generate". Run the make command in the build directory :
cd build
make -j`nproc`
Go to the OpenPose root directory and open a terminal :
./build/examples/openpose/openpose.bin --video examples/media/video.avi
Go to the OpenPose root directory and open a terminal :
./build/examples/openpose/openpose.bin
OpenPose official implemetation (Caffe)
Guide for installing OpenPose by Erica Zheng
Tutorial for increasing swap size
Commands for installing CUDA 10.0
- Email: [email protected]
- Linkedin: https://linkedin.com/in/mohamedrekik