mmpose/apis/inference_3d.py
def _collate_pose_sequence(pose_results, with_track_id=True):
    """Reorganize multi-frame pose detection results into individual pose
    sequences.

    Notes:
        T: The temporal length of the pose detection results
        N: The number of the person instances
        K: The number of the keypoints
        C: The channel number of each keypoint

    Args:
        pose_results (List[List[Dict]]): Multi-frame pose detection results
            stored in a nested list. Each element of the outer list is the
            pose detection results of a single frame, and each element of the
            inner list is the pose information of one person, which contains:
                keypoints (ndarray[K, 2 or 3]): x, y, [score]
                track_id (int): unique id of each person, required when
                    ``with_track_id==True``
                bbox ((4, ) or (5, )): left, top, right, bottom, [score],
                    required when ``with_bbox==True``
        with_track_id (bool): If True, the element in pose_results is expected
            to contain "track_id", which will be used to gather the pose
            sequence of a person from multiple frames. Otherwise, the pose
            results in each frame are expected to have a consistent number and
            order of identities. Default is True.
    """
    T = len(pose_results)
    assert T > 0

    N = len(pose_results[-1])  # use identities in the last frame
    if N == 0:
        return []

    K, C = pose_results[-1][0]['keypoints'].shape

    track_ids = None
    if with_track_id:
        track_ids = [res['track_id'] for res in pose_results[-1]]

    pose_sequences = []
    for idx in range(N):
        pose_seq = dict(keypoints=np.zeros((T, K, C), dtype=np.float32))
        # gather static information
        for k, v in pose_results[-1][idx].items():
            if k != 'keypoints':
                pose_seq[k] = v
        pose_sequences.append(pose_seq)

    for t, frame in enumerate(pose_results):
        if with_track_id:
            id2idx = {res['track_id']: idx for idx, res in enumerate(frame)}
            indices = (id2idx.get(tid, None) for tid in track_ids)
        else:
            indices = range(N)

        for idx, idx_frame in enumerate(indices):
            if idx_frame is None:
                continue
            pose_sequences[idx]['keypoints'][t] = frame[idx_frame]['keypoints']

    return pose_sequences
Reorganize multi-frame pose detection results into individual pose
    sequences.

    Notes:
        T: The temporal length of the pose detection results
        N: The number of the person instances
        K: The number of the keypoints
        C: The channel number of each keypoint

    Args:
        pose_results (List[List[Dict]]): Multi-frame pose detection results
            stored in a nested list. Each element of the outer list is the
            pose detection results of a single frame, and each element of the
            inner list is the pose information of one person, which contains:
                keypoints (ndarray[K, 2 or 3]): x, y, [score]
                track_id (int): unique id of each person, required when
                    ``with_track_id==True``
                bbox ((4, ) or (5, )): left, top, right, bottom, [score],
                    required when ``with_bbox==True``
        with_track_id (bool): If True, the element in pose_results is expected
            to contain "track_id", which will be used to gather the pose
            sequence of a person from multiple frames. Otherwise, the pose
            results in each frame are expected to have a consistent number and
            order of identities. Default is True.
    
Reorganize multi-frame pose detection results into individual pose
sequences.

The temporal length of the pose detection results
N: The number of the person instances
K: The number of the keypoints
C: The channel number of each keypoint
Reorganize multi - frame pose detection results into individual pose sequences . The temporal length of the pose detection results N : The number of the person instances K : The number of the keypoints C : The channel number of each keypoint
def _collate_pose_sequence(pose_results, with_track_id=True):
    T = len(pose_results)
    assert T > 0
    N = len(pose_results[-1])  
    if N == 0:
        return []
    K, C = pose_results[-1][0]['keypoints'].shape
    track_ids = None
    if with_track_id:
        track_ids = [res['track_id'] for res in pose_results[-1]]
    pose_sequences = []
    for idx in range(N):
        pose_seq = dict(keypoints=np.zeros((T, K, C), dtype=np.float32))
        for k, v in pose_results[-1][idx].items():
            if k != 'keypoints':
                pose_seq[k] = v
        pose_sequences.append(pose_seq)
    for t, frame in enumerate(pose_results):
        if with_track_id:
            id2idx = {res['track_id']: idx for idx, res in enumerate(frame)}
            indices = (id2idx.get(tid, None) for tid in track_ids)
        else:
            indices = range(N)
        for idx, idx_frame in enumerate(indices):
            if idx_frame is None:
                continue
            pose_sequences[idx]['keypoints'][t] = frame[idx_frame]['keypoints']
    return pose_sequences
def _collate_pose_sequence ( pose_results , with_track_id = True ) : T = len ( pose_results ) assert T > 0 N = len ( pose_results [ - 1 ] ) if N == 0 : return [ ] K , C = pose_results [ - 1 ] [ 0 ] [ 'keypoints' ] . shape track_ids = None if with_track_id : track_ids = [ res [ 'track_id' ] for res in pose_results [ - 1 ] ] pose_sequences = [ ] for idx in range ( N ) : pose_seq = dict ( keypoints = np . zeros ( ( T , K , C ) , dtype = np . float32 ) ) for k , v in pose_results [ - 1 ] [ idx ] . items ( ) : if k != 'keypoints' : pose_seq [ k ] = v pose_sequences . append ( pose_seq ) for t , frame in enumerate ( pose_results ) : if with_track_id : id2idx = { res [ 'track_id' ] : idx for idx , res in enumerate ( frame ) } indices = ( id2idx . get ( tid , None ) for tid in track_ids ) else : indices = range ( N ) for idx , idx_frame in enumerate ( indices ) : if idx_frame is None : continue pose_sequences [ idx ] [ 'keypoints' ] [ t ] = frame [ idx_frame ] [ 'keypoints' ] return pose_sequences
Reorganize multi-frame pose detection results into individual pose
sequences.
Reorganize multi - frame pose detection results into individual pose sequences .
"""Reorganize multi-frame pose detection results into individual pose
    sequences.

    Notes:
        T: The temporal length of the pose detection results
        N: The number of the person instances
        K: The number of the keypoints
        C: The channel number of each keypoint

    Args:
        pose_results (List[List[Dict]]): Multi-frame pose detection results
            stored in a nested list. Each element of the outer list is the
            pose detection results of a single frame, and each element of the
            inner list is the pose information of one person, which contains:
                keypoints (ndarray[K, 2 or 3]): x, y, [score]
                track_id (int): unique id of each person, required when
                    ``with_track_id==True``
                bbox ((4, ) or (5, )): left, top, right, bottom, [score],
                    required when ``with_bbox==True``
        with_track_id (bool): If True, the element in pose_results is expected
            to contain "track_id", which will be used to gather the pose
            sequence of a person from multiple frames. Otherwise, the pose
            results in each frame are expected to have a consistent number and
            order of identities. Default is True.
    """ # use identities in the last frame # gather static information
pose_results
Multi-frame pose detection results
stored in a nested list. Each element of the outer list is the
pose detection results of a single frame, and each element of the
inner list is the pose information of one person, which contains:
keypoints (ndarray[K, 2 or 3]): x, y, [score]
track_id (int): unique id of each person, required when
``with_track_id==True``
bbox ((4, ) or (5, )): left, top, right, bottom, [score],
required when ``with_bbox==True``
Multi - frame pose detection results stored in a nested list . Each element of the outer list is the pose detection results of a single frame and each element of the inner list is the pose information of one person which contains : keypoints ( ndarray [ K 2 or 3 ] ) : x y [ score ] track_id ( int ) : unique id of each person required when ` ` with_track_id == True ` ` bbox (( 4 ) or ( 5 )) : left top right bottom [ score ] required when ` ` with_bbox == True ` `
with_track_id
If True, the element in pose_results is expected
to contain "track_id", which will be used to gather the pose
sequence of a person from multiple frames. Otherwise, the pose
results in each frame are expected to have a consistent number and
order of identities. Default is True.
If True the element in pose_results is expected to contain " track_id " which will be used to gather the pose sequence of a person from multiple frames . Otherwise the pose results in each frame are expected to have a consistent number and order of identities . Default is True .