从这可以找到答案
从github的Issue中得到了一种解决办法,需要修改一下tf-pose中的estimator.py文件,其中TfPoseEstimator类中有一个函数为draw_humans,将在其中添加一个list来保存点的坐标即可。需要添加以下三行代码,其中,flat就是存放坐标的list
flat = [0.0 for i in range(36)]
....
flat[i*2] = center[0]
flat[i*2+1] = center[1]
修改完毕后为该函数增加一个返回值或是在函数中直接输出,更改后的代码如下
def draw_humans(npimg, humans, imgcopy=False):
if imgcopy:
npimg = np.copy(npimg)
image_h, image_w = npimg.shape[:2]
centers = {}
#添加一个数组记录坐标 作为返回值返回
flat = [0.0 for i in range(36)]
for human in humans:
# draw point
for i in range(common.CocoPart.Background.value):
if i not in human.body_parts.keys():
continue
body_part = human.body_parts[i]
center = (int(body_part.x * image_w + 0.5), int(body_part.y * image_h + 0.5)