Skip to content

KeyError: 'POSE_WORLD_LANDMARKS' Crash on reduce_poses_to_intersection #29

@cleong110

Description

@cleong110

Here's the current code:

def reduce_poses_to_intersection(
    poses: Iterable[Pose],
    progress=False,
) -> List[Pose]:
    poses = list(poses)  # get a list, no need to copy

    # look at the first pose
    component_names = {c.name for c in poses[0].header.components}
    points = {c.name: set(c.points) for c in poses[0].header.components}

    # remove anything that other poses don't have
    for pose in tqdm(poses[1:], desc="reduce poses to intersection", disable=not progress):
        component_names.intersection_update({c.name for c in pose.header.components})
        for component in pose.header.components:
            points[component.name].intersection_update(set(component.points))

    # change datatypes to match get_components, then update the poses
    points_dict = {}
    for c_name in points.keys():
        points_dict[c_name] = list(points[c_name])
    poses = [pose.get_components(list(component_names), points_dict) for pose in poses]
    return poses

It crashed on this line:

            points[component.name].intersection_update(set(component.points))

This happens, I think, when an entire component is gone from one of the poses, but not all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions