# 姿态估计

# 简介

姿势估计是一项涉及识别图像中特定点的位置的任务,这些点通常称为关键点。关键点可以代表对象的各个部分,例如关节、地标或其他独特特征。关键点的位置通常表示为一组 2D [x, y] 或 3D [x, y, visible] 坐标。

姿势估计模型的输出是一组点,这些点代表图像中对象上的关键点,通常还包括每个点的置信度分数。当您需要识别场景中对象的特定部分及其彼此之间的位置时,姿势估计是一个不错的选择。

# 安装

# Maven

在项目的 pom.xml 中添加以下依赖,详细引入方式参考 Maven 引入

如需引入全部功能,请使用 【不推荐 ❌】 all 模块。

<dependency>
    <groupId>cn.smartjavaai</groupId>
    <artifactId>vision</artifactId>
    <version>1.0.24</version>
</dependency>

# 获取姿态估计模型

PoseModelConfig config = new PoseModelConfig();
config.setModelEnum(PoseModelEnum.YOLOV8N_POSE_PT);
config.setModelPath("/Users/wenjie/Documents/develop/model/vision/pose/yolo11n-pose-onnx/yolo11n-pose.onnx");
config.setThreshold(0.25f);
PoseModel poseModel = PoseDetModelFactory.getInstance().getModel(config);

# PoseModelConfig参数说明

字段名称 字段类型 默认值 说明
modelEnum PoseModelEnum 姿态估计模型枚举
modelPath String 模型路径
threshold double 0.5 置信度阈值,分数低于这个值的结果将被过滤掉。值越高越严格,越低越宽松
device DeviceEnum CPU 指定运行设备,支持 CPU/GPU
gpuId int 0 gpu设备ID 当device为GPU时生效
predictorPoolSize int 默认为cpu核心数 模型预测器线程池大小
customParams Map<String, Object> 个性化配置(按模型类型动态解析)

# 姿态估计模型

模型名称 引擎 模型开源网站
YOLO11N-POSE OnnxRuntime Github (opens new window)
YOLO8N-POSE OnnxRuntime Github (opens new window)
SIMPLE_POSE MXNet

# PoseModel API 方法说明

# 姿态估计

Image图片源请查看文档Image使用说明

R<Joints[]> detect(Image image);

# Joints[]字段说明

  • 返回并非json格式,仅用于字段讲解
[
  {
    "joints": [ //关键点信息
      {
        "confidence": 0.149567112326622, //关键点置信度分数
        "x": 0.2890557646751404, // 关键点横坐标
        "y": 0.49486082792282104 // 关键点纵坐标
      },
      {
        "confidence": 0.09941571950912476,
        "x": 0.2867705523967743,
        "y": 0.4900684356689453
      }
    ]
  },
  {
    "joints": [
      {
        "confidence": 0.149567112326622,
        "x": 0.2890557646751404,
        "y": 0.49486082792282104
      },
      {
        "confidence": 0.09941571950912476,
        "x": 0.2867705523967743,
        "y": 0.4900684356689453
      }
    ]
  }
]

# 检测并绘制结果

该接口支持对图像进行检测,并将检测结果绘制在图像上,同时返回检测结果信息。

R<Joints[]> detectAndDraw(String imagePath, String outputPath);
Image detectAndDraw(Image image);

# 使用说明
  • imagePath:待检测图像的文件路径。
  • outputPath:绘制检测结果后图像的保存路径。
  • image:待检测的 Image 对象。

# 模型下载

百度网盘:https://pan.baidu.com/s/12JY1DfBVCOis8D93P7OjYg?pwd=1234 提取码: 1234

# 完整示例代码

示例代码 (opens new window)

# 离线使用

离线使用请看文档