Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

3d-bodypose-deepstream

This is a modified fork, not the original NVIDIA sample. It is derived from deepstream-bodypose-3d in NVIDIA's deepstream_reference_apps repository — go there for the original, unmodified version. License is unchanged (Apache 2.0, see LICENSE). This fork adds USB webcam support and a per-frame performance-logging/benchmarking harness, built to compare this pipeline against a separate custom TensorRT-based multi-camera pose-estimation project under controlled, matched conditions. See "What's Different From Upstream" and "Branches" below for specifics.

What's Different From Upstream

  • USB webcam input — --input now also accepts /dev/video* device paths (in addition to the original file:// / rtsp:// sources), via a new v4l2src-based source bin, plus a live FPS counter overlaid in the on-screen display.
  • Per-frame performance logging — a new --save-perf <file> option writes a CSV of per-frame fps and latency (from nvstreammux's NTP timestamp to the OSD probe), along with running average fps, average latency, and peak latency, plus a summary line on shutdown.
  • --camera-id <label> — tags --save-perf CSV rows with a label, for distinguishing concurrent multi-instance runs.
  • run_multicam_bench.sh — drives two camera instances concurrently for a timed, side-by-side benchmark run.
  • sources/stat_plotter.py — generates FPS/latency-over-time and summary-stat plots from the CSVs produced above.
  • Branch-specific model/precision changes — see below.

Branches

Branch Models Purpose
master / usbcam Original NGC exports: INT8 PeopleNet, FP16 BodyPose3DNet (bodypose3dnet_accuracy.onnx), batch-size 8 Upstream's default model configuration, plus all the tooling above
fair FP16 PeopleNet, FP32 BodyPose3DNet (bodypose3dnet_performance.onnx), batch-size 8 Matches model/precision to a pipeline that can't use pre-quantized NGC exports, to isolate architecture as the only comparison variable
nobatch Same as fair, but BodyPose3DNet's TensorRT engine built with batch-size 1 instead of 8 Tests whether a wide batch-size optimization profile explains a latency gap observed against the other pipeline at matched precision

Introduction

The project contains 3D Body Pose application built using Deepstream SDK.

This application is built for KAMA: 3D Keypoint Aware Body Mesh Articulation. sample pose output

Prerequisites:

DeepStream SDK 9.0 installed which is available at http://developer.nvidia.com/deepstream-sdk Please follow instructions in the /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-app/README on how to install the prequisites for building Deepstream SDK apps.

The pretrained TAO models PeopleNet and BodyPose3DNet from NGC.

Installation

Follow https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html to setup the DeepStream SDK

  1. Preferably clone the app in /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/ and define project home as export BODYPOSE3D_HOME=<parent-path>/3d-bodypose-deepstream.

  2. Install Eigen development packages

  sudo apt install libeigen3-dev
  cd /usr/include
  sudo ln -sf eigen3/Eigen Eigen
  1. For Deepstream SDK version older than 6.2, copy and build custom NvDsEventMsgMeta into Deepstream SDK installation path. Copy and build custom NvDsEventMsgMeta into Deepstream SDK installation path. The custom NvDsEventMsgMeta structure handles pose3d and pose25d meta data.
# Copy deepstream sources
cp $BODYPOSE3D_HOME/sources/deepstream-sdk/eventmsg_payload.cpp /opt/nvidia/deepstream/deepstream/sources/libs/nvmsgconv/deepstream_schema
# Build new nvmsgconv library for custom Product metadata
cd /opt/nvidia/deepstream/deepstream/sources/libs/nvmsgconv
make; make install

Please note that this step is not necessary for Deepstream SDK version 6.2 or newer.

Build the applications

# Build custom nvinfer parser of BodyPose3DNet
cd $BODYPOSE3D_HOME/sources/nvdsinfer_custom_impl_BodyPose3DNet
make
# Build deepstream-pose-estimation-app
cd $BODYPOSE3D_HOME/sources
make

If the above steps are successful, deepstream-pose-estimation-app shall be built in the same directory. Under $BODYPOSE3D_HOME/sources/nvdsinfer_custom_impl_BodyPose3DNet, libnvdsinfer_custom_impl_BodyPose3DNet.so should be present as well.

Run the applications

deepstream-pose-estimation-app

Download the pretrained TAO models with the download script

cd $BODYPOSE3D_HOME
bash ./download_models.sh

The command line options of this application are listed below:

$ ./deepstream-pose-estimation-app -h
Usage:
  deepstream-pose-estimation-app [OPTION?] Deepstream BodyPose3DNet App

Help Options:
  -h, --help                        Show help options
  --help-all                        Show all help options
  --help-gst                        Show GStreamer Options

Application Options:
  -v, --version                     Print DeepStreamSDK version.
  --version-all                     Print DeepStreamSDK and dependencies version.
  --input                           [Required] Input video address in URI format by starting with "rtsp://" or "file://".
  --output                          Output video address. Either "rtsp://" or a file path is acceptable. If the value is "rtsp://", then the result video is published at "rtsp://localhost:8554/ds-test".
  --save-pose                       The file path to save both the pose25d and the recovered pose3d in JSON format.
  --conn-str                        Connection string for Gst-nvmsgbroker, e.g. <ip address>;<port>;<topic>.
  --publish-pose                    Specify the type of pose to publish. Acceptable value is either "pose3d" or "pose25d". If not specified, both "pose3d" and "pose25d" are published to the message broker.
  --tracker                         Specify the NvDCF tracker mode. The acceptable value is either "accuracy" or "perf". The default value is "accuracy".
  --fps                             Print FPS in the format of current_fps (averaged_fps).
  --width                           Input video width in pixels. The default value is 1280.
  --height                          Input video height in pixels. The default value is 720.
  --focal                           Camera focal length in millimeters. The default value is 800.79041.

Here are examples running this application:

  1. Below command processes an input video in URI format and renders the overlaid pose estimation in a window.
$ ./deepstream-pose-estimation-app --input file://$BODYPOSE3D_HOME/streams/bodypose.mp4

Please provide the absolute path to the source video file.

  1. When the data source is a video file, below command saves the output video with the skeleton overlay to $BODYPOSE3D_HOME/streams/bodypose_3dbp.mp4 and save the skeleton's keypoints to $BODYPOSE3D_HOME/streams/bodypose_3dbp.json.
$ ./deepstream-pose-estimation-app --input file://$BODYPOSE3D_HOME/streams/bodypose.mp4 --output $BODYPOSE3D_HOME/streams/bodypose_3dbp.mp4 --focal 800.0 --width 1280 --height 720 --fps --save-pose $BODYPOSE3D_HOME/streams/bodypose_3dbp.json

bodypose_3dbp.json contains the predicted 34 keypoints in both pose25d and pose3d space:

[{
  "num_frames_in_batch": 1,
  "batches": [{
    "batch_id": 0,
    "frame_num": 3,
    "ntp_timestamp": 1639431716322229000,
    "num_obj_meta": 6,
    "objects": [{
      "object_id": 3,
      "pose25d": [707.645203, 338.592499, -0.000448, 0.867188, ...],
      "pose3d": [297.649933, -94.196518, 3520.129883, 0.867188, ...]
    },{
    ...
    }]
  }]
}, {

pose25d contains 34x4 floats. A four-item group represents a keypoint's [x, y, zRel, conf] values. x and y are the keypoint's position in the image coordinate; zRel is the relative depth value from the skeleton's root keypoint, i.e. pelvis. x, y, zRel values are in millimeters. conf is the confidence value of the prediction.

pose3d also contains 34x4 floats. A four-item group represents a keypoint's [x, y, z, conf] values. x, y, z are the keypoint's 3D position in the world coordinate whose origin is the camera. x, y, z values are in millimeters. conf is the confidence value of the prediction.

  1. When the data source is an RTSP stream and the result is published to RTSP stream rtsp://localhost:8554/ds-test,
$ ./deepstream-pose-estimation-app --input rtsp://<ipa_address>:<port>/<topic> --output rtsp://
  1. In order to publish both pose3D and pose25D metadata to a message broker, please do
$ ./deepstream-pose-estimation-app --input file://$BODYPOSE3D_HOME/streams/bodypose.mp4 --conn-str "localhost;9092;test"

where \"localhost;9092;test\" is the connection string to the message broker localhost, port number 9092, and topic name test. Please apply double quotes around the connection string since ; is a reserved character in shell.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages