ROS 2 package for running OpenPifPaf-based skeleton detection on an image stream and producing:
- raw per-frame skeleton metadata on
/skeleton_detection/frame - annotated image frames on
/skeleton_output - an annotated MP4 on disk
- a JSON metadata log on disk
The package supports two common workflows:
- publish frames from a local MP4 and run skeleton detection on that stream
- subscribe to a live RealSense color topic and run skeleton detection in real time
By default, the detector uses the parameters in [config/skeleton_detection.yaml]:
/skeleton_detection/framepublishes oneskeleton_detection/msg/SkeletonFramemessage per input frame./skeleton_outputpublishes asensor_msgs/Imagecontaining the annotated frame with skeletons, bounding boxes, and tracking IDs drawn on top.output_fpscontrols the saved MP4 playback rate and the top-level metadata fps value. It does not throttle the detector callback.
From the workspace root:
source /opt/ros/humble/setup.bash
colcon build --packages-select skeleton_detection
source install/setup.bashThe detector itself is launched the same way in both workflows:
source src/skeleton_detection_pifpaf/pifpaf_env/bin/activate
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch skeleton_detection skeleton_detection.launch.pyThe two environment variables above keep the detector headless and avoid Qt plugin crashes while it renders annotated frames internally.
Use this when you want to run skeleton detection on a static video file on disk.
- Open [config/camera_reader.yaml]and set the MP4 path you want to read.
- Make sure the detector
input_topicin [config/skeleton_detection.yaml]matches the image topic published by the camera reader. A common choice for offline playback is/dummy_camera/image_raw. - Launch the detector in a one terminal.
- Launch the MP4 reader in another terminal.
Terminal 1, detector:
source src/skeleton_detection_pifpaf/pifpaf_env/bin/activate
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch skeleton_detection skeleton_detection.launch.pyTerminal 2, MP4 reader:
source src/skeleton_detection_pifpaf/pifpaf_env/bin/activate
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch skeleton_detection camera_reader.launch.pyUse this when a RealSense driver is already publishing a live color stream to /camera/camera/color/image_raw.
- Start your RealSense ROS driver so the live color topic is available.
- Keep
input_topic: /camera/camera/color/image_rawin [config/skeleton_detection.yaml] - Launch the detector.
Example detector terminal:
source src/skeleton_detection_pifpaf/pifpaf_env/bin/activate
source /opt/ros/humble/setup.bash
source install/setup.bash
export QT_QPA_PLATFORM=offscreen
export MPLBACKEND=Agg
ros2 launch skeleton_detection skeleton_detection.launch.pyIf you use Ubuntu 22.04:
ros2 run realsense2_camera realsense2_camera_nodeIf you use Intel's standard ROS RealSense driver, a common launch looks like:
source /opt/ros/humble/setup.bash
ros2 launch realsense2_camera rs_launch.pyIf your camera publishes a different topic name, update input_topic in [config/skeleton_detection.yaml]to match it.
The most reliable setup is:
- run the detector in the shell you use for OpenPifPaf
- run
rqtin a separate clean ROS shell
Terminal 3, rqt viewer shell:
source src/skeleton_detection_pifpaf/pifpaf_env/bin/activate
src/skeleton_detection_pifpaf/pifpaf_env/bin/python3 /opt/ros/humble/bin/rqt
Inside rqt:
- Open
Plugins > Visualization > Image View. - Open
Plugins > Visualization > Image Viewa second time. - Dock the two image panes side by side in the same
rqtwindow. - Set the left pane topic to
/camera/camera/color/image_raw. - Set the right pane topic to
/skeleton_output. - Save the perspective if you want to reopen the same layout later.
This gives you a single rqt window with the raw input image on the left and the processed skeleton output on the right.
which python3If the command returns
/home/smores/anaconda3/bin/python3run
export VIRTUAL_ENV=/home/smores/anomaly_detection_ws/src/skeleton_detection_pifpaf/pifpaf_env
export PATH="$VIRTUAL_ENV/bin:$PATH"
hash -r
which python3