Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Ryzen-AI-CVML-Library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ corresponding,
header file under the **include/** folder, where `feature-name` is the name
of the desired Ryzen AI feature.

For example, the definitions for the Ryzen AI Depth Estimation feature are
For example, the definitions for the Ryzen AI Body Pose feature are
available after adding a line similar to the following example:

#include <cvml-body-pose.h>

Similarly, the definitions for the Ryzen AI Depth Estimation feature are
available after adding a line similar to the following example:

#include <cvml-depth-estimation.h>
Expand Down Expand Up @@ -392,6 +397,7 @@ Date | Revision | Notes
November 30, 2023 | 1.0 | Initial revision
April 2, 2024 | 1.1 | Include driver/copyright info
March 7, 2025 | 1.2 | Minor updates and notes
June 14, 2026 | 1.3 | Add Body Pose feature

[Back to top](#top)

Expand Down
123 changes: 123 additions & 0 deletions Ryzen-AI-CVML-Library/include/cvml-body-pose.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
*/

#ifndef EDGEML_FEATURES_BODY_POSE_INCLUDE_CVML_BODY_POSE_H_
#define EDGEML_FEATURES_BODY_POSE_INCLUDE_CVML_BODY_POSE_H_

#include "cvml-api-common.h"
#include "cvml-context.h"
#include "cvml-image.h"
#include "cvml-types.h"

using amd::cvml::Array;
using amd::cvml::Context;
using amd::cvml::Image;
using amd::cvml::Person;

namespace amd {
namespace cvml {

/**
* Body Pose Detection feature class.
*
* The body pose feature takes in an image or video stream as input. For each frame,
* it returns predictions for up to 6 people in the frame containing:
*
* - Bounding box (x, y, width, height) in image space
* - 17 landmark coordinates (x, y, z) in image space
* - Confidence score for each landmark (0.0 to 1.0)
* - Confidence score for the overall person (0.0 to 1.0)
*
* The landmarks correspond to 17 unique joint positions on the human body in accordance with
* the COCO-Pose dataset (see \a BodyPose::Keypoint). Any landmark that is occluded or falls outside
* of the frame will have its associated confidence score set to -1. Unless 3D detection is enabled,
* the z coordinate of each landmark is set to 0.
*
* If the input streaming mode != ONE_SHOT, the API may enable additional postprocessing to smoothen
* detections across frames.
*
* Example
*
* // create Ryzen AI context
* auto context = amd::cvml::CreateContext();
*
* // create body pose feature
* amd::cvml::BodyPose feature(context);
*
* // iterate over input frames
* for (auto frame ... ) {
* // encapsulate input image
* amd::cvml::Image img( ... );
*
* // detect people/poses
* auto output = feature.Generate(img);
* }
*/
class CVML_SDK_EXPORT BodyPose {
AMD_CVML_INTERFACE(BodyPose);

public:
/**
* Constructor
*
* @param context Pointer to CVML SDK context
*/
explicit BodyPose(Context* context);

/**
* Defines the landmark indices of the Array<Point3i> landmarks
* within a \a Person object
*/
enum class Keypoint {
kNose, ///< Nose
kLeftEye, ///< Left eye
kRightEye, ///< Right eye
kLeftEar, ///< Left ear
kRightEar, ///< Right ear
kLeftShoulder, ///< Left shoulder
kRightShoulder, ///< Right shoulder
kLeftElbow, ///< Left elbow
kRightElbow, ///< Right elbow
kLeftWrist, ///< Left wrist
kRightWrist, ///< Right wrist
kLeftHip, ///< Left hip
kRightHip, ///< Right hip
kLeftKnee, ///< Left knee
kRightKnee, ///< Right knee
kLeftAnkle, ///< Left ankle
kRightAnkle, ///< Right ankle
kNumPoints ///< Total number of returned landmarks
};

/**
* Main feature entry point.
*
* Applications/clients should call this function once for every
* frame in the video or live stream.
*
* @param img amd::cvml::Image object containing input image
* @return the Array of Person structs representing detected people
*/
Array<Person> Generate(const Image& img);

/**
* Set the detection threshold for people within a scene.
*
* Detected persons under the specified threshold are not returned by
* the \a Generate() function.
*
* @param threshold Person detection threshold, from 0.0 to 1.0
*/
void SetDetectionThreshold(float threshold);

class Impl;

protected:
Impl* impl_; ///< Implementation of body pose interface.
};

} // namespace cvml
} // namespace amd

#endif // EDGEML_FEATURES_BODY_POSE_INCLUDE_CVML_BODY_POSE_H_
23 changes: 23 additions & 0 deletions Ryzen-AI-CVML-Library/samples/cvml-sample-body-pose/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.

set(FEATURE_NAME cvml-sample-body-pose)
project(${FEATURE_NAME})

list(APPEND CMAKE_MODULE_PATH ${OPENCV_INSTALL_ROOT} ${AMD_CVML_SDK_ROOT} "${CMAKE_CURRENT_SOURCE_DIR}/../..")

find_package(OpenCV REQUIRED)
find_package(RyzenAILibrary REQUIRED)

file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

include_directories(${OpenCV_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../common-sample-utils/include)

add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${RyzenAILibrary_LIBS}
common-sample-utils
)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${AMD_CVML_SDK_ROOT}/samples/${FEATURE_NAME})
install(TARGETS ${PROJECT_NAME} DESTINATION ${AMD_CVML_SDK_ROOT}/samples/${FEATURE_NAME})
28 changes: 28 additions & 0 deletions Ryzen-AI-CVML-Library/samples/cvml-sample-body-pose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# `cvml-sample-body-pose`

This sample demonstrates the implementation of AMD's Body Pose feature.
It detects up to 6 people per frame and returns 17 keypoints per person (bounding box, landmark coordinates, and confidence scores) using the COCO-Pose keypoint convention.
Results are visually overlaid on the output image or video.

## Usage

```sh
cvml-sample-body-pose.exe [-i path_to_image/video] [-o output image/video filename] [-h]
Options
-i: Run body pose on the given image or video. (Optional)
-o: Specify output image or video file name e.g., .mp4 or .jpg. (Optional)
-h: Show usage.
If no arguments are provided, the application attempts to capture input from camera index 0.

Examples
Run the sample with an image input without output file:
cvml-sample-body-pose.exe -i my_image.jpg

Run the sample with a video input and save the result to an output video file:
cvml-sample-body-pose.exe -i my_video.mp4 -o output_video.mp4

Run the sample to capture the camera feed and save the result to a video file:
cvml-sample-body-pose.exe -o output_video.mp4

Note
If the user runs the application without any arguments, it will use the camera as an input.
Loading