In [1]:
%pylab inline
import cv2
import os
import PyOpenPose as OP
OPENPOSE_ROOT = os.environ["OPENPOSE_ROOT"]


Populating the interactive namespace from numpy and matplotlib

In [2]:
img = cv2.imread("galloping knights.jpg")

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

In [4]:
op.detectPose(img)

In [5]:
viz = op.render(img)
plt.imshow(viz[:,:,::-1])


Out[5]:
<matplotlib.image.AxesImage at 0x7f1a479ed4d0>

In [6]:
# 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


Found 7 persons.
Result info: (7, 18, 3) float32

In [7]:
persons[0]


Out[7]:
array([[  4.27277740e+02,   1.67776505e+02,   8.89688432e-01],
       [  4.29296234e+02,   2.39926682e+02,   8.83322179e-01],
       [  3.80480438e+02,   2.30232269e+02,   7.97119617e-01],
       [  3.47257477e+02,   3.10269958e+02,   8.44593704e-01],
       [  4.07810699e+02,   3.41460693e+02,   6.95256352e-01],
       [  4.78067230e+02,   2.42029984e+02,   8.42094123e-01],
       [  4.89832825e+02,   3.31672455e+02,   1.22733541e-01],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  3.82465271e+02,   4.19522491e+02,   4.37827229e-01],
       [  3.66845612e+02,   5.65870300e+02,   1.98075041e-01],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  4.54627014e+02,   4.05852142e+02,   3.05945158e-01],
       [  4.13639832e+02,   5.73658081e+02,   1.07373245e-01],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  4.15659180e+02,   1.59973541e+02,   8.74267697e-01],
       [  4.40982880e+02,   1.61876343e+02,   9.15453196e-01],
       [  4.07790771e+02,   1.63952316e+02,   2.97507375e-01],
       [  4.60444916e+02,   1.71679474e+02,   7.99877286e-01]], dtype=float32)

In [ ]: