from sticky_mitten_avatar.sticky_mitten_avatar.frame_data import FrameData
Data about the scene from the most recent frame about doing an action such as reach_for_target().
Use this data to plan what the next action should be.
Access this data from the StickyMittenAvatarController:
from sticky_mitten_avatar import StickyMittenAvatarController, Arm
c = StickyMittenAvatarController()
c.init_scene()
# Look towards the left arm.
c.rotate_camera_by(pitch=70, yaw=-45)
c.reach_for_target(target={"x": -0.2, "y": 0.21, "z": 0.385}, arm=Arm.left)
# Save the image.
c.frame.save_images(output_directory="dist")
c.end()image_passRendered image of the scene as a numpy array.
id_passImage pass of object color segmentation as a numpy array. Ifid_pass == Falsein theStickyMittenAvatarControllerconstructor, this will be None.
depth_passImage pass of depth values per pixel as a numpy array. Use the camera matrices to interpret this data. Depth values are encoded into the RGB image; seeget_depth_values().
projection_matrixThe camera projection matrix of the avatar's camera as a numpy array.camera_matrixThe camera matrix of the avatar's camera as a numpy array.
object_transformsThe dictionary of object transform data. Key = the object ID.
from sticky_mitten_avatar import StickyMittenAvatarController
c = StickyMittenAvatarController()
c.init_scene(scene="2a", layout=1)
for object_id in c.frame.object_transforms:
print(c.frame.object_transforms[object_id].position)avatar_transformThe transform data of the avatar.
from sticky_mitten_avatar import StickyMittenAvatarController
c = StickyMittenAvatarController()
c.init_scene(scene="2a", layout=1)
avatar_position = c.frame.avatar_transform.positionavatar_body_part_transformsThe transform data of each body part of the avatar. Key = body part ID.
from sticky_mitten_avatar import StickyMittenAvatarController
c = StickyMittenAvatarController()
c.init_scene(scene="2a", layout=1)
# Get the position and segmentation color of each body part.
for body_part_id in c.frame.avatar_body_part_transforms:
position = c.frame.avatar_body_part_transforms[body_part_id]
segmentation_color = c.static_avatar_info[body_part_id].segmentation_colorheld_objectsA dictionary of IDs of objects held in each mitten. Key = arm:
from sticky_mitten_avatar import StickyMittenAvatarController, Arm
c = StickyMittenAvatarController()
# Your code here.
# Prints all objects held by the left mitten.
print(c.frame.held_objects[Arm.left])def __init__(self, resp: List[bytes], avatar: Avatar)
| Parameter | Description |
|---|---|
| resp | The response from the build. |
| avatar | The avatar in the scene. |
def save_images(self, output_directory: Union[str, Path]) -> None
Save the ID pass (segmentation colors) and the depth pass to disk.
Images will be named: [frame_number]_[pass_name].[extension]
For example, the depth pass on the first frame will be named: 00000000_depth.png
The image pass is a jpg file and the other passes are png files.
| Parameter | Description |
|---|---|
| output_directory | The directory that the images will be saved to. |
def get_pil_images(self) -> dict
Convert each image pass to PIL images.
Returns: A dictionary of PIL images. Key = the pass name (img, id, depth); Value = The PIL image (can be None)
def get_depth_values(self) -> np.array
Convert the depth_pass to depth values.
Returns: A decoded depth pass as a numpy array of floats.