(self, x)
return res
Fill the NaN elements in x with
            their relative-to-neck position in the preious x.
        Argument:
            x {np.array}: a skeleton that has a neck and at least a thigh.
Fill the NaN elements in x with
            their relative-to-neck position in the preious x.
        Argument:
            x {np.array}: a skeleton that has a neck and at least a thigh.
Fill the NaN elements in x with their relative - to - neck position in the preious x . Argument : x { np . array } : a skeleton that has a neck and at least a thigh .
def _fill_invalid_data(self, x):
        ''' Fill the NaN elements in x with
            their relative-to-neck position in the preious x.
        Argument:
            x {np.array}: a skeleton that has a neck and at least a thigh.
        '''
        res = x.copy()

        def get_px_py_px0_py0(x):
            px = x[0::2]  # list of x
            py = x[1::2]  # list of y
            px0, py0 = get_joint(x, NECK)  # neck
            return px, py, px0, py0
        cur_px, cur_py, cur_px0, cur_py0 = get_px_py_px0_py0(x)
        cur_height = ProcFtr.get_body_height(x)

        is_lack_knee = check_joint(x, L_KNEE) or check_joint(x, R_KNEE)
        is_lack_ankle = check_joint(x, L_ANKLE) or check_joint(x, R_ANKLE)
        if (self._pre_x is None) or is_lack_knee or is_lack_ankle:
            # If preious data is invalid or there is no knee or ankle,
            # then fill the data based on the STAND_SKEL_NORMED.
            for i in range(TOTAL_JOINTS*2):
                if res[i] == NaN:
                    res[i] = (cur_px0 if i % 2 == 0 else cur_py0) + \
                        cur_height * STAND_SKEL_NORMED[i]
            return res

        pre_px, pre_py, pre_px0, pre_py0 = get_px_py_px0_py0(self._pre_x)
        pre_height = ProcFtr.get_body_height(self._pre_x)

        scale = cur_height / pre_height

        bad_idxs = np.nonzero(cur_px == NaN)[0]
        if not len(bad_idxs):  # No invalid data
            return res

        cur_px[bad_idxs] = cur_px0 + (pre_px[bad_idxs] - pre_px0) * scale
        cur_py[bad_idxs] = cur_py0 + (pre_py[bad_idxs] - pre_py0) * scale
        res[::2] = cur_px
        res[1::2] = cur_py
        return res
def _fill_invalid_data ( self , x ) : res = x . copy ( ) def get_px_py_px0_py0 ( x ) : px = x [ 0 : : 2 ] # list of x py = x [ 1 : : 2 ] # list of y px0 , py0 = get_joint ( x , NECK ) # neck return px , py , px0 , py0 cur_px , cur_py , cur_px0 , cur_py0 = get_px_py_px0_py0 ( x ) cur_height = ProcFtr . get_body_height ( x ) is_lack_knee = check_joint ( x , L_KNEE ) or check_joint ( x , R_KNEE ) is_lack_ankle = check_joint ( x , L_ANKLE ) or check_joint ( x , R_ANKLE ) if ( self . _pre_x is None ) or is_lack_knee or is_lack_ankle : # If preious data is invalid or there is no knee or ankle, # then fill the data based on the STAND_SKEL_NORMED. for i in range ( TOTAL_JOINTS * 2 ) : if res [ i ] == NaN : res [ i ] = ( cur_px0 if i % 2 == 0 else cur_py0 ) + cur_height * STAND_SKEL_NORMED [ i ] return res pre_px , pre_py , pre_px0 , pre_py0 = get_px_py_px0_py0 ( self . _pre_x ) pre_height = ProcFtr . get_body_height ( self . _pre_x ) scale = cur_height / pre_height bad_idxs = np . nonzero ( cur_px == NaN ) [ 0 ] if not len ( bad_idxs ) : # No invalid data return res cur_px [ bad_idxs ] = cur_px0 + ( pre_px [ bad_idxs ] - pre_px0 ) * scale cur_py [ bad_idxs ] = cur_py0 + ( pre_py [ bad_idxs ] - pre_py0 ) * scale res [ : : 2 ] = cur_px res [ 1 : : 2 ] = cur_py return res