(x)
return features_angles, features_lens
Change the representation of skeletons
            From xy positions to angle and length.
Change the representation of skeletons
            From xy positions to angle and length.
Change the representation of skeletons From xy positions to angle and length .
def joint_pos_2_angle_and_length(x):
        ''' Change the representation of skeletons
            From xy positions to angle and length.
        '''

        # ---------------------- Get joint positions ----------------------
        class JointPosExtractor(object):
            def __init__(self, x):
                self.x = x
                self.i = 0

            def get_next_point(self):
                p = [self.x[self.i], self.x[self.i+1]]
                self.i += 2
                return p
        tmp = JointPosExtractor(x)

        pneck = tmp.get_next_point()

        prshoulder = tmp.get_next_point()
        prelbow = tmp.get_next_point()
        prwrist = tmp.get_next_point()

        plshoulder = tmp.get_next_point()
        plelbow = tmp.get_next_point()
        plwrist = tmp.get_next_point()

        prhip = tmp.get_next_point()
        prknee = tmp.get_next_point()
        prankle = tmp.get_next_point()

        plhip = tmp.get_next_point()
        plknee = tmp.get_next_point()
        plankle = tmp.get_next_point()

        # ---------------------- Get joint angels ----------------------

        class Get12Angles(object):
            def __init__(self):
                self.j = 0
                self.f_angles = np.zeros((12,))
                self.x_lengths = np.zeros((12,))

            def set_next_angle_len(self, next_joint, base_joint, base_angle):
                angle = Math.calc_relative_angle_v2(
                    next_joint, base_joint, base_angle)
                dist = Math.calc_dist(next_joint, base_joint)
                self.f_angles[self.j] = angle
                self.x_lengths[self.j] = dist
                self.j += 1

        tmp2 = Get12Angles()

        tmp2.set_next_angle_len(prshoulder, pneck, PI)  # r-shoulder
        tmp2.set_next_angle_len(prelbow, prshoulder, PI/2)  # r-elbow
        tmp2.set_next_angle_len(prwrist, prelbow, PI/2)  # r-wrist

        tmp2.set_next_angle_len(plshoulder, pneck, 0)  # l-shoulder
        tmp2.set_next_angle_len(plelbow, plshoulder, PI/2)  # l-elbow
        tmp2.set_next_angle_len(plwrist, plelbow, PI/2)  # l-wrist

        tmp2.set_next_angle_len(prhip, pneck, PI/2+PI/18)
        tmp2.set_next_angle_len(prknee, prhip, PI/2)
        tmp2.set_next_angle_len(prankle, prknee, PI/2)

        tmp2.set_next_angle_len(plhip, pneck, PI/2-PI/18)
        tmp2.set_next_angle_len(plknee, plhip, PI/2)
        tmp2.set_next_angle_len(plankle, plknee, PI/2)

        # Output
        features_angles = tmp2.f_angles
        features_lens = tmp2.x_lengths
        return features_angles, features_lens
def joint_pos_2_angle_and_length ( x ) : # ---------------------- Get joint positions ---------------------- class JointPosExtractor ( object ) : def __init__ ( self , x ) : self . x = x self . i = 0 def get_next_point ( self ) : p = [ self . x [ self . i ] , self . x [ self . i + 1 ] ] self . i += 2 return p tmp = JointPosExtractor ( x ) pneck = tmp . get_next_point ( ) prshoulder = tmp . get_next_point ( ) prelbow = tmp . get_next_point ( ) prwrist = tmp . get_next_point ( ) plshoulder = tmp . get_next_point ( ) plelbow = tmp . get_next_point ( ) plwrist = tmp . get_next_point ( ) prhip = tmp . get_next_point ( ) prknee = tmp . get_next_point ( ) prankle = tmp . get_next_point ( ) plhip = tmp . get_next_point ( ) plknee = tmp . get_next_point ( ) plankle = tmp . get_next_point ( ) # ---------------------- Get joint angels ---------------------- class Get12Angles ( object ) : def __init__ ( self ) : self . j = 0 self . f_angles = np . zeros ( ( 12 , ) ) self . x_lengths = np . zeros ( ( 12 , ) ) def set_next_angle_len ( self , next_joint , base_joint , base_angle ) : angle = Math . calc_relative_angle_v2 ( next_joint , base_joint , base_angle ) dist = Math . calc_dist ( next_joint , base_joint ) self . f_angles [ self . j ] = angle self . x_lengths [ self . j ] = dist self . j += 1 tmp2 = Get12Angles ( ) tmp2 . set_next_angle_len ( prshoulder , pneck , PI ) # r-shoulder tmp2 . set_next_angle_len ( prelbow , prshoulder , PI / 2 ) # r-elbow tmp2 . set_next_angle_len ( prwrist , prelbow , PI / 2 ) # r-wrist tmp2 . set_next_angle_len ( plshoulder , pneck , 0 ) # l-shoulder tmp2 . set_next_angle_len ( plelbow , plshoulder , PI / 2 ) # l-elbow tmp2 . set_next_angle_len ( plwrist , plelbow , PI / 2 ) # l-wrist tmp2 . set_next_angle_len ( prhip , pneck , PI / 2 + PI / 18 ) tmp2 . set_next_angle_len ( prknee , prhip , PI / 2 ) tmp2 . set_next_angle_len ( prankle , prknee , PI / 2 ) tmp2 . set_next_angle_len ( plhip , pneck , PI / 2 - PI / 18 ) tmp2 . set_next_angle_len ( plknee , plhip , PI / 2 ) tmp2 . set_next_angle_len ( plankle , plknee , PI / 2 ) # Output features_angles = tmp2 . f_angles features_lens = tmp2 . x_lengths return features_angles , features_lens