FORTH-ModelBasedTracker / PyOpenPose

Python bindings for the Openpose library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyOpenpose Render without ther original Image - Only the pose

DEKHTIARJonathan opened this issue · comments

Let's take the example of the repository:

import cv2
import os
import PyOpenPose as OP

OPENPOSE_ROOT = os.environ["OPENPOSE_ROOT"]

img = cv2.imread("galloping knights.jpg")

op = OP.OpenPose((656, 368), (368, 368), (1280, 720), "COCO", OPENPOSE_ROOT + os.sep + "models" + os.sep, 0, False)


op.detectPose(img)


viz = op.render(img)

cv2.imwrite("result.jpeg", viz)

# getKeypoints returns an array of matrices
# When POSE is requested the return array contains one entry with all persons.
persons = op.getKeypoints(op.KeypointType.POSE)[0]

print("Found", persons.shape[0],"persons.")
print("Result info:",persons.shape, persons.dtype)

print(persons[0])

Is there anyway to overlay the pose on a black background instead of the image itself ?

This would give something like this:

image

And doing this does not work:

result = viz - img
cv2.imwrite("result.jpeg", result)

I obtain a ton of artifacts

207

Thanks

Just provide an empty image to op.render
i.e

canvas = np.zeros_like(img)
viz = op.render(canvas)

Absolutely perfect :D

You should add an example showing this, I searched for this for hours ;)

Thanks a lot