Python 脚本调用 OpenPose最简单案例
时间: 2023-03-31 12:03:02 浏览: 250
你可以使用以下代码来调用 OpenPose:
```
import cv2
import os
import sys
import numpy as np
import argparse
# 加载 OpenPose 模型
sys.path.append('/path/to/openpose/python')
from openpose import pyopenpose as op
# 设置 OpenPose 参数
params = dict()
params["model_folder"] = "/path/to/openpose/models/"
params["model_pose"] = "BODY_25"
params["net_resolution"] = "-1x368"
params["output_resolution"] = "-1x-1"
params["display"] =
params["disable_blending"] = False
params["alpha_pose"] = .6
params["scale_gap"] = .3
params["scale_number"] = 1
params["render_threshold"] = .05
params["num_gpu_start"] =
params["disable_multi_thread"] = False
# 初始化 OpenPose
opWrapper = op.WrapperPython()
opWrapper.configure(params)
opWrapper.start()
# 加载图像
imageToProcess = cv2.imread("/path/to/image.jpg")
# 运行 OpenPose
datum = op.Datum()
datum.cvInputData = imageToProcess
opWrapper.emplaceAndPop([datum])
# 获取关键点坐标
keypoints = datum.poseKeypoints
# 打印关键点坐标
print(keypoints)
```
这个脚本会加载 OpenPose 模型,然后读取一张图片,运行 OpenPose 并获取关键点坐标。
阅读全文