In [1]:
import numpy as np
def _label_to_coords(label):
return label.reshape((-1, 2))
_label_to_coords(np.array(
['sholX1', 'sholY1', 'elboX1', 'elboY1', 'wrstX1', 'wrstY1', 'sholX2', 'sholY2', 'elboX2', 'elboY2', 'wrstX2', 'wrstY2']
)[[4, 5, 10, 11]])
Out[1]:
So, given the above, it seems that the wrist coordinates are in indices $\begin{bmatrix}4 & 5 & 10 & 11\end{bmatrix}$ (using zero-based indexing rather than Matlab-style indexing).
In [5]:
import h5py
def write_new_jointset(h5_path, mask, new_name):
with h5py.File(h5_path, 'r+') as fp:
masked_joints = fp['/joints'][:, mask]
fp[new_name] = masked_joints
wrist_mask = [4, 5, 10, 11]
# write_new_jointset('../cache/train-patches-mpii-fixed/samples-000001.h5', wrist_mask, '/wrists')
# write_new_jointset('../cache/val-patches-mpii-fixed/samples-000001.h5', wrist_mask, '/wrists')
In [ ]: