(self, key)
return proto
Returns a trajectory protocol buffer message for the specified key.
Returns a trajectory protocol buffer message for the specified key.
Returns a trajectory protocol buffer message for the specified key .
def _get_proto_for_key(self, key):
    """Returns a trajectory protocol buffer message for the specified key."""
    if isinstance(key, str):
      key = key.encode('utf-8')

    h5_trajectory = self._h5_file[key]
    num_steps = h5_trajectory.attrs['num_steps']

    proto = mocap_pb2.FittedTrajectory()
    proto.identifier = key
    self._fill_primitive_proto_fields(proto, h5_trajectory,
                                      skip_fields=('identifier',))

    for _ in range(num_steps):
      proto.timesteps.add()

    h5_walkers = h5_trajectory['walkers']
    for walker_id in range(len(h5_walkers)):
      h5_walker = h5_walkers['walker_{:d}'.format(walker_id)]
      walker_proto = proto.walkers.add()
      self._fill_primitive_proto_fields(walker_proto, h5_walker)
      self._fill_repeated_proto_message_fields(
          walker_proto.scaling.subtree,
          h5_walker['scaling'], h5_prefix='subtree')
      self._fill_repeated_proto_message_fields(
          walker_proto.markers.marker,
          h5_walker['markers'], h5_prefix='marker')

      walker_fields = dict()
      for field in mocap_pb2.WalkerPose.DESCRIPTOR.fields:
        walker_fields[field.name] = np.asarray(h5_walker[field.name])

      for timestep_id, timestep in enumerate(proto.timesteps):
        walker_timestep = timestep.walkers.add()
        for k, v in walker_fields.items():
          getattr(walker_timestep, k).extend(v[:, timestep_id])

    h5_props = h5_trajectory['props']
    for prop_id in range(len(h5_props)):
      h5_prop = h5_props['prop_{:d}'.format(prop_id)]
      prop_proto = proto.props.add()
      self._fill_primitive_proto_fields(prop_proto, h5_prop)

      prop_fields = dict()
      for field in mocap_pb2.PropPose.DESCRIPTOR.fields:
        prop_fields[field.name] = np.asarray(h5_prop[field.name])

      for timestep_id, timestep in enumerate(proto.timesteps):
        prop_timestep = timestep.props.add()
        for k, v in prop_fields.items():
          getattr(prop_timestep, k).extend(v[:, timestep_id])

    return proto
def _get_proto_for_key ( self , key ) : if isinstance ( key , str ) : key = key . encode ( 'utf-8' ) h5_trajectory = self . _h5_file [ key ] num_steps = h5_trajectory . attrs [ 'num_steps' ] proto = mocap_pb2 . FittedTrajectory ( ) proto . identifier = key self . _fill_primitive_proto_fields ( proto , h5_trajectory , skip_fields = ( 'identifier' , ) ) for _ in range ( num_steps ) : proto . timesteps . add ( ) h5_walkers = h5_trajectory [ 'walkers' ] for walker_id in range ( len ( h5_walkers ) ) : h5_walker = h5_walkers [ 'walker_{:d}' . format ( walker_id ) ] walker_proto = proto . walkers . add ( ) self . _fill_primitive_proto_fields ( walker_proto , h5_walker ) self . _fill_repeated_proto_message_fields ( walker_proto . scaling . subtree , h5_walker [ 'scaling' ] , h5_prefix = 'subtree' ) self . _fill_repeated_proto_message_fields ( walker_proto . markers . marker , h5_walker [ 'markers' ] , h5_prefix = 'marker' ) walker_fields = dict ( ) for field in mocap_pb2 . WalkerPose . DESCRIPTOR . fields : walker_fields [ field . name ] = np . asarray ( h5_walker [ field . name ] ) for timestep_id , timestep in enumerate ( proto . timesteps ) : walker_timestep = timestep . walkers . add ( ) for k , v in walker_fields . items ( ) : getattr ( walker_timestep , k ) . extend ( v [ : , timestep_id ] ) h5_props = h5_trajectory [ 'props' ] for prop_id in range ( len ( h5_props ) ) : h5_prop = h5_props [ 'prop_{:d}' . format ( prop_id ) ] prop_proto = proto . props . add ( ) self . _fill_primitive_proto_fields ( prop_proto , h5_prop ) prop_fields = dict ( ) for field in mocap_pb2 . PropPose . DESCRIPTOR . fields : prop_fields [ field . name ] = np . asarray ( h5_prop [ field . name ] ) for timestep_id , timestep in enumerate ( proto . timesteps ) : prop_timestep = timestep . props . add ( ) for k , v in prop_fields . items ( ) : getattr ( prop_timestep , k ) . extend ( v [ : , timestep_id ] ) return proto