openpose

本文档详细介绍了在Ubuntu系统中编译安装OpenPose的步骤,包括下载源码、配置子模块、解决依赖问题、编译错误以及安装过程。同时,提供了OpenPose的测试和使用方法,包括不同输入输出参数的设置和JSON输出格式的解析。在安装过程中可能会遇到的问题,如找不到boost_system库,以及CUDA版本匹配等,都给出了相应的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

openpose编译安装

  • 下载开源包

    git clone https://github.com.cnpmjs.org/CMU-Perceptual-Computing-Lab/openpose
    
  • 修改子模块的配置文件.gitmodules
    在这里插入图片描述

  • 同步子模块信息

    git submodule sync
    
  • 下载子模块

    git submodule update --init --recursive
    
  • 下载模型

    cd openpose/models
    ./getModels.sh
    

    在这里插入图片描述

  • 启动cmake-gui界面

    cd openpose
    makedir build
    cmake-gui
    
  • 配置路径
    在这里插入图片描述

  • 出错
    在这里插入图片描述

  • 安装libgoogle-glog-dev
    root用户下安装:

    apt-get install libgoogle-glog-dev # install
    apt-get remove libgoogle-glog-dev # uninstall
    

    非root用户下安装:

    #打开sudoer文件
    visudo
    #添加
    xxx    ALL=(ALL:ALL) ALL
    #退出
    ctl+x
    #安装
    sudo apt-get install libgoogle-glog-dev
    
  • 点击configure,重新配置生成。

  • 编译

    cd build
    make -j`nproc`
    

    执行make时会出现找不到boost_system的问题,可以重新编译boost,如果boost和cmake有关联,需要删掉,因为cmake可以不用安装直接解压添加环境变量使用,如果重新编译cmake会出现cmake和boost相关联,并且root用户也安装了boost库,在编译的过程中就不知道调用哪个boost库,从而导致出现问题。

注意:如果环境中是cuda-9.0,cmake-gui配置时,需要注意cuda选项是否是cuda-9.0,我的默认是cuda-8.0,不纠正该选项会出现找不到xxx.cu.o文件问题。

  • 错误
    在这里插入图片描述
    查看启动的进程

    ps aux | wc -l
    

    通过该命令可以看到进程数一直在增加,查看输出一直在重复进行的输出如下信息。
    在这里插入图片描述
    重新下载openpose源码重新编译,不会重复出现重复Rerunning cmake after building Caffe submodule模块,运行成功。
    在这里插入图片描述

  • 生成

    # 安装到默认目录
    make install 
    # 安装到指定目录
    make install DESTDIR=/mnt/disk2/xxx/smb-share/soft/openpose 
    
  • 测试
    在openpose根目录下执行如下命令

    ./build/examples/openpose/openpose.bin  --video examples/media/video.avi
    

openpose 使用

输入输出参数

  • 输入参数

    # 输入参数
    # Running on Images, Video, or Webcam
    --image_dir : image path
    --video : video path
    --camera : camera number
    # Face and Hands
    --face : detect face point
    --hand : detect hand point
    # Not Running All GPUs
    --num_gpu : sets the number of total GPUs
    --num_gpu_start : the first GPU to use
    # Maximum Accuracy Configuration
    # this command provides the most accurate results we have been able to achieve for body, hand and face keypoint detection.
    --net_resolution
    --scale_number
    --scale_gap
    
    # Running on Images, Video, or Webcam
    ./build/examples/openpose/openpose.sh --image_dir examples/media/
    ./build/examples/openpose/openpose.sh --video examples/media/video.avi
    ./build/example/openpose/openpose.sh --camera 0
    # Face and Hands
    ./build/examples/openpose/openpose.bin --image_dir examples/media/ --face --hand
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --face --hand
    ./build/examples/openpose/openpose.bin --face --hand
    # Not Running All GPUs
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --num_gpu 2 --num_gpu_start 1
    # Maximum Accuracy Configuration
    # Ubuntu and Mac: Body
    ./build/examples/openpose/openpose.bin --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25
    # Ubuntu and Mac: Body + Hand + Face
    ./build/examples/openpose/openpose.bin --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25 --hand --hand_scale_number 6 --hand_scale_range 0.4 --face
    

    在这里插入图片描述

  • 输出参数

    # 输出参数
    # Different Outputs(JSON, Images, Video, UI)
    --write_json : output json path
    --write_video : output video path
    --write_images : output image path
    --write_images_format : write images format
    --display : disable the UI visualization or not
    --render_pose : overlay skeletons with the input images or not
    # Only Skeleton without Background Image
    --disable_blending : visualize/save the skeleton without the original image overlaid or blended 
    
    # Different Outputs(JSON, Images, Video, UI)
    # Save the skeletons in a set of JSON files
    # Ubuntu and Mac (same flags for Windows)
    ./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_json output_jsons/
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output_jsons/
    ./build/examples/openpose/openpose.bin --write_json output_jsons/
    # Save on disk the visual output of OpenPose (the images with the skeletons overlaid) as an output video or set of images 
    # Ubuntu and Mac (same flags for Windows)
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_video output/result.avi
    ./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_video output/result.avi
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_images output_images/
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_images output_images/ --write_images_format jpg
    ./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_images output_images/
    ./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_images output_images/ --write_images_format jpg
    # You can also disable the UI visualization
    # Ubuntu and Mac (same flags for Windows)
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_images output_images/ --display 0
    # To speed up OpenPose even further 
    # Ubuntu and Mac (same flags for Windows)
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output_jsons/ --display 0 --render_pose 0
    # Only Skeleton without Background Image
    # Ubuntu and Mac (same flags for Windows)
    # Only body
    ./build/examples/openpose/openpose.bin --video examples/media/video.avi --disable_blending
    

输入输出文件

  • JSON-UI Mapping
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    • JSON Output Format
      在这里插入图片描述

      # 官网给出的
      {
          "version":1.1,
          "people":[
              {
                  "pose_keypoints_2d":[582.349,507.866,0.845918,746.975,631.307,0.587007,...],
                  "face_keypoints_2d":[468.725,715.636,0.189116,554.963,652.863,0.665039,...],
                  "hand_left_keypoints_2d":[746.975,631.307,0.587007,615.659,617.567,0.377899,...],
                  "hand_right_keypoints_2d":[617.581,472.65,0.797508,0,0,0,723.431,462.783,0.88765,...]
                  "pose_keypoints_3d":[582.349,507.866,507.866,0.845918,507.866,746.975,631.307,0.587007,...],
                  "face_keypoints_3d":[468.725,715.636,715.636,0.189116,715.636,554.963,652.863,0.665039,...],
                  "hand_left_keypoints_3d":[746.975,631.307,631.307,0.587007,631.307,615.659,617.567,0.377899,...],
                  "hand_right_keypoints_3d":[617.581,472.65,472.65,0.797508,472.65,0,0,0,723.431,462.783,0.88765,...]
              }
          ],
          // If `--part_candidates` enabled
          "part_candidates":[
              {
                  "0":[296.994,258.976,0.845918,238.996,365.027,0.189116],
                  "1":[381.024,321.984,0.587007],
                  "2":[313.996,314.97,0.377899],
                  "3":[238.996,365.027,0.189116],
                  "4":[283.015,332.986,0.665039],
                  "5":[457.987,324.003,0.430488,283.015,332.986,0.665039],
                  "6":[],
                  "7":[],
                  "8":[],
                  "9":[],
                  "10":[],
                  "11":[],
                  "12":[],
                  "13":[],
                  "14":[293.001,242.991,0.674305],
                  "15":[314.978,241,0.797508],
                  "16":[],
                  "17":[369.007,235.964,0.88765]
              }
          ]
      }
      
      # 测试结果
      {
          "version": 1.3,
          "people": [
              {
                  "person_id": [
                      -1
                  ],
                  "pose_keypoints_2d": [
                      93.4962,
                      38.5496,
                      0.830378,
                      87.8299,
                      87.1173,
                      0.796927,
                      49.1132,
                      82.1957,
                      0.658523,
                      42.7829,
                      149.15,
                      0.651932,
                      46.2776,
                      206.192,
                      0.696771,
                      125.866,
                      89.957,
                      0.669954,
                      132.251,
                      152.643,
                      0.68547,
                      148.421,
                      209.705,
                      0.542522,
                      71.6597,
                      210.421,
                      0.323036,
                      0,
                      0,
                      0,
                      0,
                      0,
                      0,
                      120.965,
                      207.594,
                      0.36855,
                      0,
                      0,
                      0,
                      0,
                      0,
                      0,
                      87.1342,
                      30.8119,
                      0.918732,
                      103.341,
                      31.5191,
                      0.871637,
                      75.8563,
                      34.322,
                      0.829309,
                      111.12,
                      37.8224,
                      0.789115
                  ],
                  "face_keypoints_2d": [
                      
                  ],
                  "hand_left_keypoints_2d": [
                      
                  ],
                  "hand_right_keypoints_2d": [
                      
                  ],
                  "pose_keypoints_3d": [
                      
                  ],
                  "face_keypoints_3d": [
                      
                  ],
                  "hand_left_keypoints_3d": [
                      
                  ],
                  "hand_right_keypoints_3d": [
                      
                  ]
              }
          ]
      }
      

参考资料
Ubuntu 16.04 安装 OpenPose 1.6.0 全教程,附显卡以及训练框架详细安装步骤
Github 项目 - OpenPose 在 Ubuntu 的安装
make install到指定安装目录
OpenPose安装过程中遇到的问题
ubuntu下OpenPose的安装、使用、初步介绍
ubuntu18编译安装opencv3.4.3, caffe和openpose, 踩坑记录
OpenPose Doc - Demo
OpenPose Doc - Output

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值