off-the shelf multiple view multi-person pose estimation:
In this work we address the problem of estimating multiple 3D human poses from a set of calibrated cameras. Estimating 3D human poses from multiple views has several compelling properties: humans can be projected into a joint global coordinate space, sets of cameras can cover a much larger area than a single camera could, and ambiguities, occlusions and motion blurs can be resolved by other views. We propose a bottom-up approach where we first triangulate geometrically reasonable 2D joint pairs from which we then build a sparse graph with edges between close-by joints of the same type and edges between joints that form limbs. Partitioning this graph yields a set of 3D human pose estimations. Our approach is robust and can handle situations where each camera only has a small field of view with people only partially visible. We obtain competitive results for single person 3D pose estimation and state-of-the art results for multi-person 3D pose estimation.
import cv2
from poseestimation import model
from mvpose import settings, pose
from mvpose.geometry.camera import ProjectiveCamera
# pose estimation model
pe = model.PoseEstimator()
# the system uses [mm] as world coordinates. Thus, if your calibrated
# cameras use another meaure you need to provide the appropriate scale.
# For example, assuming the cameras are calibrated in [m] we need to
# scale as follows:
params = settings.get_settings(scale_to_mm=1000)
imread = lambda p: cv2.cvtColor(cv2.imread(p), cv2.COLOR_BGR2RGB))
# load 'n' frames
Im = [
imread('/path/cam1.jpg'),
imread('/path/cam2.jpg'),
...,
imread('/path/camn.jpg')
]
heatmaps, pafs = pe.predict_pafs_and_heatmaps(Im)
# prepare cameras
# K := {3x3} camera calibration matrix
# rvec := {1x3} rodrigues vector for rotation
# tvec := {1x3} translation vector
# distCoef := {1x5} distortion coefficient (can be [0, 0, 0, 0, 0])
# w,h := width/height if images
Calib = [
ProjectiveCamera(K1, rvec1, tvec1, distCoef1, w, h),
ProjectiveCamera(K2, rvec2, tvec2, distCoef2, w, h),
...,
ProjectiveCamera(Kn, rvecn, tvecn, distCoefn, w, h)
]
detections = pose.estimate(Calib, heatmaps, pafs, settings=params)
print('number of detected people: ', len(detections))
# each detection consists of 17 joints (MSCOCO-style) that either represent a
# 3D location or 'None', in case of no detection of the joint.
The software is developed using Python 3.6 and we recommend to use Anaconda Python. The following additional (non-standard) libraries are needed:
scikit image: image manipulation
conda install -c anaconda scikit-image
google or-tools: for solving optimization problems
pip install --user --upgrade ortools
poseestimation: for the part affinity fields
pip install git+https://github.com/jutanke/easy_multi_person_pose_estimation
numba: enables high performance functions in Python using NumPy
conda install -c numba numba
c3d: for reading 3d data
pip install c3d
pak: for loading some of the datasets
pip install git+https://github.com/justayak/pppr.git
pip install git+https://github.com/justayak/pak.git
opencv3.X: for common computer vision tasks (reproject 3d points, etc) We recommend to compile your own version of OpenCV for your python setup. At the cmake-stage you can choose whatever additional flags you like (cuda, opencvcontrib, etc.) -- however, keep the ones written below as they are. You might need to install additional packages (e.g. ffmpeg, libpng, etc.) before you are able to successfully build OpenCV (check out the OpenCV documentation for your OS for further instructions). (Remarks: The version of OpenCV does not matter too much as long as it is 3.X. However, the version bundled with anaconda (I tested with cv2 version 3.1) is apparently not compiled against ffmpeg so you cannot load video files. if you want to be on the 'safe' side compile it on your own!)
git clone https://github.com/opencv/opencv.git
cd opencv && git checkout 3.4.0
mkdir build && cd build
cmake -DBUILD_opencv_java=OFF \
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-DPYTHON3_EXECUTABLE=$(which python3) \
-DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..
make -j4
make install
cselect: select colors
pip install git+https://github.com/jutanke/cselect.git