5 Minutes tutorial to get OpenPose neural network working with OpenCV on NVidia GPU
Open Pose is a neural network for realtime multi-person 2D pose estimation is a key component in enabling machines to have an understanding of people in images and videos.
You can read full paper explanation here : https://arxiv.org/pdf/1812.08008.pdf
OpenCV 4.2.0 comes out with a full support ans sample to start use an OpenPose pretrained network on Caffe and make it very easy to deploy and test with your own videos
First of all you have to compile and install Opencv 4.2.0 in your system :
My workstation is based on Unbuntu 18.04 with Nvidia Geforce RTX 2080 nvidia dirvers 440.59 cuda 10.2 and cudnn 7.5.0 which is a minimum requirement to build OpenCV 4.2.0

Create a directory for example mkdir OpenCV-4.2.0 in your home and get inside
Download both opencv and opencv_contrib :
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.2.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.2.0.zip
Unzip both archives and rename directories to opencv and opencv_contrib :
mv opencv-4.2.0 opencv
mv opencv_contrib-4.2.0 opencv_contrib
cd opencv
mkdir build
cd build
Now you are ready to cmake Opencv-4.2.0 inside build directory, you need a cmake version 3.10 or newer or compilation will fail, update cmake in your system before proceed.
These are the flags I used on my system for cmake command to build with Opencv-4.2.0 with Cuda and Cudnn. I have excluded python builds because not interested in python environment on this machine, but you can turn INSTALL_PYTHON_EXAMPLES=ON to build them :
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv-4.2.0 \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D CUDA_ARCH_BIN=7.0 \
-D WITH_CUBLAS=1 \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
If cmake succefully recognized cuda and cudnn you should see something like this :
– NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
– NVIDIA GPU arch: 70
– NVIDIA PTX archs:
– cuDNN: YES (ver 7.5.0)
now you can run make command (suggest to check your proc capabilities on your machine using nproc command to speed up Opecv build on my machine I can go up to make -j24)
Once compilation is end you can install OpenCv 4.2.0 in your machine using command :
sudo make install
sudo ldconfig
Now that you have OpeCV installed on your system you can download marsk-rcnn.cpp OpenCV source demo here : https://github.com/spmallick/learnopencv/tree/master/OpenPose-Multi-Person
Git clone repository or download archive and follow instruction on page to dowload OpenPose Caffe model and weights trained on COCO Dataset.
Download my program file which is a modified version of learn-opencv openpose sample to inference multi person detection on a video here : https://github.com/MarcoGonnelli74/DeepLearning/blob/master/multi-person-openpose-video.cpp
To build you can use Eclipse or any other IDE you are used or just compile with command line command
Remember to include in your include paths : – I /usr/local/include/opencv4
Link following libraries -l :
opencv_imgproc
opencv_videoio
opencv_imgcodecs
opencv_core
opencv_dnn
opencv_highgui
Using library search path -L : /usr/local/opencv-4.2.0/lib
then run test program :
./multi-person-open-pose-video <path to your video>
Here’s my video sample running program on a test Video using Nvidia RTX 2080 GPU using cuda and cudnn acceleration enjoy :