first commit

This commit is contained in:
Zhiming Hu 2025-04-30 14:15:00 +02:00
parent 99ce0acafb
commit 8f6b6a34e7
73 changed files with 11656 additions and 0 deletions

View file

@ -0,0 +1,26 @@
## Code to process the HOT3D dataset
## Usage:
Step 1: Follow the instructions at the official repository https://github.com/facebookresearch/hot3d to prepare the environment and download the dataset. You should also enable jupyter because the processing codes are run on jupyter.
Step 2: Set 'dataset_path', 'dataset_processed_path', 'object_library_path', and 'mano_hand_model_path' in 'hot3d_aria_preprocessing.ipynb', put 'hot3d_aria_preprocessing.ipynb', 'hot3d_aria_scene.csv', 'hot3d_objects.csv', and 'utils' into the official repository ('hot3d/hot3d/'), and run it to process the dataset.
Step 3: It is optional but highly recommended to set 'data_path', 'object_library_path', and 'mano_hand_model_path' in 'hot3d_aria_visualisation.ipynb', put 'hot3d_aria_visualisation.ipynb' and 'mano_hand_pose_init' into the official repository ('hot3d/hot3d/'), and run it to visualise and get familiar with the dataset.
## Citations
```bibtex
@inproceedings{hu25hoigaze,
title={HOIGaze: Gaze Estimation During Hand-Object Interactions in Extended Reality Exploiting Eye-Hand-Head Coordination},
author={Hu, Zhiming and Haeufle, Daniel and Schmitt, Syn and Bulling, Andreas},
booktitle={Proceedings of the 2025 ACM Special Interest Group on Computer Graphics and Interactive Techniques},
year={2025}}
@article{banerjee2024introducing,
title={Introducing HOT3D: An Egocentric Dataset for 3D Hand and Object Tracking},
author={Banerjee, Prithviraj and Shkodrani, Sindi and Moulon, Pierre and Hampali, Shreyas and Zhang, Fan and Fountain, Jade and Miller, Edward and Basol, Selen and Newcombe, Richard and Wang, Robert and others},
journal={arXiv preprint arXiv:2406.09598},
year={2024}}
```

View file

@ -0,0 +1,565 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "bbfb8da4-14a5-44d8-b9b0-d66f032f09fb",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.nice(5)\n",
"import rerun as rr\n",
"import numpy as np\n",
"from math import tan\n",
"import time\n",
"from utils import remake_dir\n",
"import pandas as pd\n",
"from dataset_api import Hot3dDataProvider\n",
"from data_loaders.loader_object_library import load_object_library\n",
"from data_loaders.mano_layer import MANOHandModel\n",
"from data_loaders.loader_masks import combine_mask_data, load_mask_data, MaskData\n",
"from data_loaders.loader_hand_poses import Handedness, HandPose\n",
"from data_loaders.loader_object_library import ObjectLibrary\n",
"from data_loaders.headsets import Headset\n",
"from projectaria_tools.core.stream_id import StreamId\n",
"from projectaria_tools.core.sensor_data import TimeDomain, TimeQueryOptions\n",
"from projectaria_tools.core.sophus import SE3\n",
"\n",
"\n",
"dataset_path = '/datasets/public/zhiming_datasets/hot3d/aria/'\n",
"dataset_processed_path = '/scratch/hu/pose_forecast/hot3d_hoigaze/'\n",
"object_library_path = '/datasets/public/zhiming_datasets/hot3d/assets/'\n",
"mano_hand_model_path = '/datasets/public/zhiming_datasets/hot3d/mano_v1_2/models/'\n",
"remake_dir(dataset_processed_path)\n",
"dataset_info = pd.read_csv('hot3d_aria_scene.csv')\n",
"valid_frame_length = 60 # 60 frames -> 2 seconds, dropout the recordings that are too short\n",
"\n",
"# init the object library\n",
"if not os.path.exists(object_library_path):\n",
" print(\"invalid library path.\")\n",
" print(\"please do update the path to VALID values for your system.\")\n",
" raise\n",
"object_library = load_object_library(object_library_folderpath=object_library_path)\n",
"\n",
"# load the bounding box information of the objects\n",
"object_info = pd.read_csv('hot3d_objects.csv')\n",
"object_bbx = {}\n",
"for i, uid in enumerate(object_info['object_uid']): \n",
" bbx_x_min = object_info['bbx_x_min'][i]\n",
" bbx_x_max = object_info['bbx_x_max'][i]\n",
" bbx_y_min = object_info['bbx_y_min'][i]\n",
" bbx_y_max = object_info['bbx_y_max'][i]\n",
" bbx_z_min = object_info['bbx_z_min'][i]\n",
" bbx_z_max = object_info['bbx_z_max'][i]\n",
" bbx = [bbx_x_min, bbx_x_max, bbx_y_min, bbx_y_max, bbx_z_min, bbx_z_max]\n",
" object_bbx[str(uid)] = bbx\n",
" \n",
"# init the HANDs model. If None, the UmeTrack HANDs model will be used\n",
"mano_hand_model = None\n",
"if mano_hand_model_path is not None:\n",
" mano_hand_model = MANOHandModel(mano_hand_model_path)\n",
" \n",
"for i, seq in enumerate(dataset_info['sequence_name']):\n",
" scene = dataset_info['scene'][i]\n",
" print(\"\\nprocessing {}th seq: {}, scene: {}...\".format(i+1, seq, scene))\n",
" seq_path = dataset_path + seq + '/'\n",
" if not os.path.exists(seq_path):\n",
" print(\"invalid input sequence path.\")\n",
" print(\"please do update the path to VALID values for your system.\")\n",
" raise\n",
" save_path = dataset_processed_path + seq + '_' + scene + '_'\n",
"\n",
" # segment the sequence into valid and invalid parts using the masks \n",
" mask_list = [\n",
" \"masks/mask_object_pose_available.csv\",\n",
" \"masks/mask_hand_pose_available.csv\", \n",
" \"masks/mask_headset_pose_available.csv\",\n",
" #\"masks/mask_object_visibility.csv\", \n",
" #\"masks/mask_hand_visible.csv\",\n",
" #\"masks/mask_good_exposure.csv\",\n",
" \"masks/mask_qa_pass.csv\"]\n",
" \n",
" # load the referred masks\n",
" mask_data_list = []\n",
" for it in mask_list:\n",
" if os.path.exists(os.path.join(seq_path, it)):\n",
" ret = load_mask_data(os.path.join(seq_path, it))\n",
" mask_data_list.append(ret)\n",
" # combine the masks (you can choose logical \"and\"/\"or\")\n",
" combined_masks = combine_mask_data(mask_data_list, \"and\")\n",
" masks = []\n",
" for value in combined_masks.data['214-1'].values():\n",
" masks.append(value)\n",
" print(\"valid frames: {}/{}\".format(sum(masks), len(masks)))\n",
" \n",
" # initialize hot3d data provider\n",
" hot3d_data_provider = Hot3dDataProvider(\n",
" sequence_folder=seq_path,\n",
" object_library=object_library,\n",
" mano_hand_model=mano_hand_model)\n",
" #print(f\"data_provider statistics: {hot3d_data_provider.get_data_statistics()}\") \n",
" # alias over the HAND pose data provider\n",
" hand_data_provider = hot3d_data_provider.mano_hand_data_provider if hot3d_data_provider.mano_hand_data_provider is not None else hot3d_data_provider.umetrack_hand_data_provider\n",
" # alias over the Object pose data provider\n",
" object_pose_data_provider = hot3d_data_provider.object_pose_data_provider\n",
" # alias over the HEADSET/Device pose data provider\n",
" device_pose_provider = hot3d_data_provider.device_pose_data_provider\n",
" # alias over the Device data provider\n",
" device_data_provider = hot3d_data_provider.device_data_provider\n",
" device_calibration = device_data_provider.get_device_calibration()\n",
" transform_device_cpf = device_calibration.get_transform_device_cpf()\n",
" # retrieve a list of timestamps for the sequence (in nanoseconds)\n",
" timestamps = device_data_provider.get_sequence_timestamps()\n",
" \n",
" # segment valid data\n",
" index = 0\n",
" valid_frames = 0\n",
" start_frames = []\n",
" end_frames = []\n",
" while(index<len(masks)):\n",
" value = masks[index] \n",
" if value == True:\n",
" start = index\n",
" start_frames.append(start)\n",
" #print(\"start at: {}\".format(start))\n",
" while(value == True):\n",
" index += 1\n",
" if index<len(masks):\n",
" value = masks[index]\n",
" else:\n",
" break \n",
" end = index-1\n",
" end_frames.append(end)\n",
" #print(\"end at: {}\".format(end))\n",
" valid_frames += end - start + 1 \n",
" else:\n",
" index += 1\n",
" \n",
" segment_num = len(start_frames)\n",
" local_time = time.asctime(time.localtime(time.time()))\n",
" print('\\nprocessing starts at ' + local_time) \n",
" for i in range(segment_num):\n",
" start_frame = start_frames[i]\n",
" end_frame = end_frames[i]\n",
" frame_length = end_frame - start_frame + 1\n",
" if frame_length < valid_frame_length:\n",
" continue\n",
" print(\"start frame: {}, end frame: {}, length: {}\".format(start_frame, end_frame, frame_length))\n",
" \n",
" timestamps_data = np.zeros((frame_length, 1))\n",
" head_data = np.zeros((frame_length, 10)) # head_direction (3) + head_translation (3) + head_rotation (4, quat_xyzw)\n",
" gaze_data = np.zeros((frame_length, 6)) # gaze_direction (3) + gaze_center_in_world (3) \n",
" hand_data = np.zeros((frame_length, 44)) # left_hand (22) + right_hand (22), hand = wrist_pose (7, translation (3) + rotation (4)) + joint_angles (15) \n",
" hand_joint_data = np.zeros((frame_length, 122)) # left_hand (20*3) + right_hand (20*3) + attended_hand_gt + attended_hand_baseline (closest_hand) \n",
" hand_joint_initial_data = np.zeros((frame_length, 122)) # left_hand (20*3) + right_hand (20*3) + attended_hand_gt + closest_hand\n",
" object_data = np.zeros((frame_length, 48)) # object_data (8) * 6 objects (at most 6 objects), object_data = object_uid (1) + object_pose (7, translation (3) + rotation (4)) \n",
" object_bbx_data = np.zeros((frame_length, 144)) # bounding box information: 6 objects (at most 6 objects) * 8 vertexes * 3\n",
" object_bbx_left_hand_data = np.zeros((frame_length, 144)) # bounding box information of the objects ranked using distances to the left hand\n",
" object_bbx_right_hand_data = np.zeros((frame_length, 144)) # bounding box information of the objects ranked using distances to the right hand\n",
" object_bbx_left_hand_initial_data = np.zeros((frame_length, 144)) # bounding box information of the objects ranked using distances to the left hand\n",
" object_bbx_right_hand_initial_data = np.zeros((frame_length, 144)) # bounding box information of the objects ranked using distances to the right hand\n",
" \n",
" # extract the valid frames\n",
" for frame in range(start_frame, end_frame+1):\n",
" timestamp_ns = timestamps[frame]\n",
" timestamps_data[frame-start_frame] = timestamp_ns\n",
" \n",
" # extract head data\n",
" headset_pose3d_with_dt = device_pose_provider.get_pose_at_timestamp(\n",
" timestamp_ns=timestamp_ns,\n",
" time_query_options=TimeQueryOptions.CLOSEST,\n",
" time_domain=TimeDomain.TIME_CODE) \n",
" headset_pose3d = headset_pose3d_with_dt.pose3d\n",
" T_world_device = headset_pose3d.T_world_device\n",
" # use cpf pose as head pose, see https://facebookresearch.github.io/projectaria_tools/docs/data_formats/coordinate_convention/3d_coordinate_frame_convention\n",
" T_world_cpf = T_world_device @ transform_device_cpf \n",
" head_translation = T_world_cpf.translation()[0]\n",
" head_center_in_cpf = np.array([0, 0, 1.0], dtype = np.float64)\n",
" head_center_in_world = T_world_cpf @ head_center_in_cpf\n",
" head_center_in_world = head_center_in_world.reshape(3, )\n",
" head_direction = head_center_in_world - head_translation\n",
" head_direction = np.array([x / np.linalg.norm(head_direction) for x in head_direction]) \n",
" head_rotation = np.roll(T_world_cpf.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w\n",
" head_data[frame-start_frame, 0:3] = head_direction\n",
" head_data[frame-start_frame, 3:6] = head_translation\n",
" head_data[frame-start_frame, 6:10] = head_rotation\n",
" \n",
" # extract eye gaze data\n",
" aria_eye_gaze_data = device_data_provider.get_eye_gaze(timestamp_ns) \n",
" yaw = aria_eye_gaze_data.yaw\n",
" pitch = aria_eye_gaze_data.pitch\n",
" depth = aria_eye_gaze_data.depth\n",
" if depth == 0:\n",
" depth = 1\n",
" gaze_center_in_cpf = np.array([tan(yaw), tan(pitch), 1.0], dtype = np.float64)*depth\n",
" gaze_center_in_world = T_world_cpf @ gaze_center_in_cpf\n",
" gaze_center_in_world = gaze_center_in_world.reshape(3, )\n",
" gaze_direction = gaze_center_in_world - head_translation\n",
" gaze_direction = np.array([x / np.linalg.norm(gaze_direction) for x in gaze_direction])\n",
" # in rare cases, yaw, pitch is nan\n",
" if np.isnan(np.sum(gaze_direction)):\n",
" # use previous frame as an alternative\n",
" gaze_direction = gaze_data[frame-start_frame-1, 0:3]\n",
" gaze_center_in_world = gaze_data[frame-start_frame-1, 3:6]\n",
" gaze_data[frame-start_frame, 0:3] = gaze_direction\n",
" gaze_data[frame-start_frame, 3:6] = gaze_center_in_world\n",
" \n",
" # extract hand data\n",
" hand_poses_with_dt = hand_data_provider.get_pose_at_timestamp(\n",
" timestamp_ns=timestamp_ns,\n",
" time_query_options=TimeQueryOptions.CLOSEST,\n",
" time_domain=TimeDomain.TIME_CODE) \n",
" hand_pose_collection = hand_poses_with_dt.pose3d_collection\n",
" left_hand = hand_pose_collection.poses[Handedness.Left]\n",
" left_hand_translation = left_hand.wrist_pose.translation()[0]\n",
" left_hand_rotation = np.roll(left_hand.wrist_pose.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w\n",
" left_hand_joint_angles = left_hand.joint_angles\n",
" left_hand_joints = hand_data_provider.get_hand_landmarks(left_hand).numpy().reshape(-1)\n",
" left_hand_initial = HandPose(Handedness.Left, left_hand.wrist_pose, np.zeros(15))\n",
" left_hand_initial_joints = hand_data_provider.get_hand_landmarks(left_hand_initial).numpy().reshape(-1) \n",
" right_hand = hand_pose_collection.poses[Handedness.Right]\n",
" right_hand_translation = right_hand.wrist_pose.translation()[0]\n",
" right_hand_rotation = np.roll(right_hand.wrist_pose.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w\n",
" right_hand_joint_angles = right_hand.joint_angles\n",
" right_hand_joints = hand_data_provider.get_hand_landmarks(right_hand).numpy().reshape(-1)\n",
" right_hand_initial = HandPose(Handedness.Right, right_hand.wrist_pose, np.zeros(15))\n",
" right_hand_initial_joints = hand_data_provider.get_hand_landmarks(right_hand_initial).numpy().reshape(-1)\n",
" \n",
" left_hand_direction = np.mean(left_hand_joints.reshape((20, 3)), axis=0) - head_translation\n",
" left_hand_direction = np.array([x / np.linalg.norm(left_hand_direction) for x in left_hand_direction]) \n",
" left_hand_distance_to_gaze = np.arccos(np.sum(gaze_direction*left_hand_direction))\n",
" right_hand_direction = np.mean(right_hand_joints.reshape((20, 3)), axis=0) - head_translation\n",
" right_hand_direction = np.array([x / np.linalg.norm(right_hand_direction) for x in right_hand_direction]) \n",
" right_hand_distance_to_gaze = np.arccos(np.sum(gaze_direction*right_hand_direction))\n",
" if left_hand_distance_to_gaze < right_hand_distance_to_gaze:\n",
" hand_joint_data[frame-start_frame, 120:121] = 0\n",
" else:\n",
" hand_joint_data[frame-start_frame, 120:121] = 1\n",
"\n",
" left_hand_initial_direction = np.mean(left_hand_initial_joints.reshape((20, 3)), axis=0) - head_translation\n",
" left_hand_initial_direction = np.array([x / np.linalg.norm(left_hand_initial_direction) for x in left_hand_initial_direction]) \n",
" left_hand_initial_distance_to_gaze = np.arccos(np.sum(gaze_direction*left_hand_initial_direction))\n",
" right_hand_initial_direction = np.mean(right_hand_initial_joints.reshape((20, 3)), axis=0) - head_translation\n",
" right_hand_initial_direction = np.array([x / np.linalg.norm(right_hand_initial_direction) for x in right_hand_initial_direction]) \n",
" right_hand_initial_distance_to_gaze = np.arccos(np.sum(gaze_direction*right_hand_initial_direction))\n",
" if left_hand_initial_distance_to_gaze < right_hand_initial_distance_to_gaze:\n",
" hand_joint_initial_data[frame-start_frame, 120:121] = 0\n",
" else:\n",
" hand_joint_initial_data[frame-start_frame, 120:121] = 1\n",
" \n",
" hand_data[frame-start_frame, 0:3] = left_hand_translation\n",
" hand_data[frame-start_frame, 3:7] = left_hand_rotation\n",
" hand_data[frame-start_frame, 7:22] = left_hand_joint_angles\n",
" hand_data[frame-start_frame, 22:25] = right_hand_translation\n",
" hand_data[frame-start_frame, 25:29] = right_hand_rotation\n",
" hand_data[frame-start_frame, 29:44] = right_hand_joint_angles\n",
" hand_joint_data[frame-start_frame, 0:60] = left_hand_joints\n",
" hand_joint_data[frame-start_frame, 60:120] = right_hand_joints\n",
" hand_joint_initial_data[frame-start_frame, 0:60] = left_hand_initial_joints\n",
" hand_joint_initial_data[frame-start_frame, 60:120] = right_hand_initial_joints\n",
" \n",
" # extract object data\n",
" object_poses_with_dt = object_pose_data_provider.get_pose_at_timestamp(\n",
" timestamp_ns=timestamp_ns,\n",
" time_query_options=TimeQueryOptions.CLOSEST,\n",
" time_domain=TimeDomain.TIME_CODE)\n",
" objects_pose3d = object_poses_with_dt.pose3d_collection.poses\n",
" object_num = len(objects_pose3d)\n",
" objects_distance_to_left_hand = {}\n",
" objects_distance_to_right_hand = {} \n",
" objects_distance_to_left_hand_initial = {}\n",
" objects_distance_to_right_hand_initial = {}\n",
" objects_pose3d_dict = {}\n",
" item = 0\n",
" for (object_uid, object_pose3d) in objects_pose3d.items():\n",
" object_translation = object_pose3d.T_world_object.translation()[0] \n",
" object_distance_to_left_hand = np.mean(np.linalg.norm(left_hand_joints.reshape((20, 3))-object_translation, axis=1))\n",
" object_distance_to_right_hand = np.mean(np.linalg.norm(right_hand_joints.reshape((20, 3))-object_translation, axis=1))\n",
" object_distance_to_left_hand_initial = np.mean(np.linalg.norm(left_hand_initial_joints.reshape((20, 3))-object_translation, axis=1))\n",
" object_distance_to_right_hand_initial = np.mean(np.linalg.norm(right_hand_initial_joints.reshape((20, 3))-object_translation, axis=1)) \n",
" objects_distance_to_left_hand[object_uid] = object_distance_to_left_hand \n",
" objects_distance_to_right_hand[object_uid] = object_distance_to_right_hand\n",
" objects_distance_to_left_hand_initial[object_uid] = object_distance_to_left_hand_initial\n",
" objects_distance_to_right_hand_initial[object_uid] = object_distance_to_right_hand_initial\n",
" objects_pose3d_dict[object_uid] = object_pose3d.T_world_object \n",
" item += 1\n",
" \n",
" objects_distance_to_left_hand_sorted = sorted(objects_distance_to_left_hand.items(), key = lambda kv:(kv[1], kv[0]))\n",
" objects_distance_to_right_hand_sorted = sorted(objects_distance_to_right_hand.items(), key = lambda kv:(kv[1], kv[0])) \n",
" left_object_closest_uid = objects_distance_to_left_hand_sorted[0][0]\n",
" left_object_closest_distance = objects_distance_to_left_hand_sorted[0][1]\n",
" right_object_closest_uid = objects_distance_to_right_hand_sorted[0][0]\n",
" right_object_closest_distance = objects_distance_to_right_hand_sorted[0][1]\n",
" if left_object_closest_distance < right_object_closest_distance:\n",
" hand_joint_data[frame-start_frame, -1] = 0\n",
" else:\n",
" hand_joint_data[frame-start_frame, -1] = 1\n",
"\n",
" objects_distance_to_left_hand_initial_sorted = sorted(objects_distance_to_left_hand_initial.items(), key = lambda kv:(kv[1], kv[0]))\n",
" objects_distance_to_right_hand_initial_sorted = sorted(objects_distance_to_right_hand_initial.items(), key = lambda kv:(kv[1], kv[0]))\n",
" left_initial_object_closest_uid = objects_distance_to_left_hand_initial_sorted[0][0]\n",
" left_initial_object_closest_distance = objects_distance_to_left_hand_initial_sorted[0][1]\n",
" right_initial_object_closest_uid = objects_distance_to_right_hand_initial_sorted[0][0]\n",
" right_initial_object_closest_distance = objects_distance_to_right_hand_initial_sorted[0][1]\n",
" if left_initial_object_closest_distance < right_initial_object_closest_distance:\n",
" hand_joint_initial_data[frame-start_frame, -1] = 0\n",
" else:\n",
" hand_joint_initial_data[frame-start_frame, -1] = 1\n",
" \n",
" item = 0\n",
" for object_uid in objects_pose3d_dict:\n",
" object_pose3d = objects_pose3d_dict[object_uid]\n",
" object_translation = object_pose3d.translation()[0]\n",
" object_rotation = np.roll(object_pose3d.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w \n",
" object_data[frame-start_frame, item*8:item*8+1] = object_uid\n",
" object_data[frame-start_frame, item*8+1:item*8+4] = object_translation\n",
" object_data[frame-start_frame, item*8+4:item*8+8] = object_rotation\n",
" bbx = object_bbx[object_uid]\n",
" #print(\"uid: {}, bbx: {}\".format(object_uid, bbx))\n",
" x_min = bbx[0]\n",
" x_max = bbx[1]\n",
" y_min = bbx[2]\n",
" y_max = bbx[3]\n",
" z_min = bbx[4]\n",
" z_max = bbx[5]\n",
" bbx_vertex = np.array([x_min, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, ) \n",
" object_bbx_data[frame-start_frame, item*24:item*24+3] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+3:item*24+6] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+6:item*24+9] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+9:item*24+12] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+12:item*24+15] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+15:item*24+18] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+18:item*24+21] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_data[frame-start_frame, item*24+21:item*24+24] = bbx_vertex \n",
" item += 1\n",
" \n",
" for item in range(len(objects_distance_to_left_hand_sorted)):\n",
" object_uid = objects_distance_to_left_hand_sorted[item][0]\n",
" object_pose3d = objects_pose3d_dict[object_uid] \n",
" object_translation = object_pose3d.translation()[0]\n",
" object_rotation = np.roll(object_pose3d.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w \n",
" bbx = object_bbx[object_uid]\n",
" #print(\"uid: {}, bbx: {}\".format(object_uid, bbx))\n",
" x_min = bbx[0]\n",
" x_max = bbx[1]\n",
" y_min = bbx[2]\n",
" y_max = bbx[3]\n",
" z_min = bbx[4]\n",
" z_max = bbx[5]\n",
" bbx_vertex = np.array([x_min, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, ) \n",
" object_bbx_left_hand_data[frame-start_frame, item*24:item*24+3] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+3:item*24+6] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+6:item*24+9] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+9:item*24+12] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+12:item*24+15] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+15:item*24+18] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+18:item*24+21] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_data[frame-start_frame, item*24+21:item*24+24] = bbx_vertex \n",
"\n",
" for item in range(len(objects_distance_to_right_hand_sorted)):\n",
" object_uid = objects_distance_to_right_hand_sorted[item][0]\n",
" object_pose3d = objects_pose3d_dict[object_uid] \n",
" object_translation = object_pose3d.translation()[0]\n",
" object_rotation = np.roll(object_pose3d.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w \n",
" bbx = object_bbx[object_uid]\n",
" #print(\"uid: {}, bbx: {}\".format(object_uid, bbx))\n",
" x_min = bbx[0]\n",
" x_max = bbx[1]\n",
" y_min = bbx[2]\n",
" y_max = bbx[3]\n",
" z_min = bbx[4]\n",
" z_max = bbx[5]\n",
" bbx_vertex = np.array([x_min, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, ) \n",
" object_bbx_right_hand_data[frame-start_frame, item*24:item*24+3] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+3:item*24+6] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+6:item*24+9] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+9:item*24+12] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+12:item*24+15] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+15:item*24+18] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+18:item*24+21] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_data[frame-start_frame, item*24+21:item*24+24] = bbx_vertex \n",
"\n",
" for item in range(len(objects_distance_to_left_hand_initial_sorted)):\n",
" object_uid = objects_distance_to_left_hand_initial_sorted[item][0]\n",
" object_pose3d = objects_pose3d_dict[object_uid] \n",
" object_translation = object_pose3d.translation()[0]\n",
" object_rotation = np.roll(object_pose3d.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w \n",
" bbx = object_bbx[object_uid]\n",
" #print(\"uid: {}, bbx: {}\".format(object_uid, bbx))\n",
" x_min = bbx[0]\n",
" x_max = bbx[1]\n",
" y_min = bbx[2]\n",
" y_max = bbx[3]\n",
" z_min = bbx[4]\n",
" z_max = bbx[5]\n",
" bbx_vertex = np.array([x_min, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, ) \n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24:item*24+3] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+3:item*24+6] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+6:item*24+9] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+9:item*24+12] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+12:item*24+15] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+15:item*24+18] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+18:item*24+21] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_left_hand_initial_data[frame-start_frame, item*24+21:item*24+24] = bbx_vertex \n",
"\n",
" for item in range(len(objects_distance_to_right_hand_initial_sorted)):\n",
" object_uid = objects_distance_to_right_hand_initial_sorted[item][0]\n",
" object_pose3d = objects_pose3d_dict[object_uid] \n",
" object_translation = object_pose3d.translation()[0]\n",
" object_rotation = np.roll(object_pose3d.rotation().to_quat()[0], -1) # change from w,x,y,z to x,y,z,w \n",
" bbx = object_bbx[object_uid]\n",
" #print(\"uid: {}, bbx: {}\".format(object_uid, bbx))\n",
" x_min = bbx[0]\n",
" x_max = bbx[1]\n",
" y_min = bbx[2]\n",
" y_max = bbx[3]\n",
" z_min = bbx[4]\n",
" z_max = bbx[5]\n",
" bbx_vertex = np.array([x_min, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, ) \n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24:item*24+3] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+3:item*24+6] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+6:item*24+9] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_min, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+9:item*24+12] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+12:item*24+15] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_max], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+15:item*24+18] = bbx_vertex\n",
" bbx_vertex = np.array([x_max, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+18:item*24+21] = bbx_vertex\n",
" bbx_vertex = np.array([x_min, y_max, z_min], dtype = np.float64) \n",
" bbx_vertex = (object_pose3d @ bbx_vertex).reshape(3, )\n",
" object_bbx_right_hand_initial_data[frame-start_frame, item*24+21:item*24+24] = bbx_vertex \n",
" \n",
" # save the data\n",
" timestamps_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_timestamps.npy'\n",
" head_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_head.npy'\n",
" gaze_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_gaze.npy'\n",
" hand_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_hand.npy' \n",
" hand_joint_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_handjoints.npy'\n",
" hand_joint_initial_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_inithandjoints.npy'\n",
" object_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_objects.npy'\n",
" object_bbx_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_object_bbx.npy'\n",
" object_bbx_left_hand_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_object_bbxleft.npy'\n",
" object_bbx_right_hand_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_object_bbxright.npy'\n",
" object_bbx_left_hand_initial_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_object_initbbxleft.npy'\n",
" object_bbx_right_hand_initial_path = save_path + str(start_frame) + \"_\" + str(end_frame) + '_object_initbbxright.npy'\n",
" \n",
" np.save(timestamps_path, timestamps_data)\n",
" np.save(head_path, head_data)\n",
" np.save(gaze_path, gaze_data)\n",
" np.save(hand_path, hand_data)\n",
" np.save(hand_joint_path, hand_joint_data)\n",
" np.save(hand_joint_initial_path, hand_joint_initial_data)\n",
" np.save(object_path, object_data)\n",
" np.save(object_bbx_path, object_bbx_data)\n",
" np.save(object_bbx_left_hand_path, object_bbx_left_hand_data)\n",
" np.save(object_bbx_right_hand_path, object_bbx_right_hand_data)\n",
" np.save(object_bbx_left_hand_initial_path, object_bbx_left_hand_initial_data)\n",
" np.save(object_bbx_right_hand_initial_path, object_bbx_right_hand_initial_data)\n",
" \n",
" local_time = time.asctime(time.localtime(time.time()))\n",
" print('\\nprocessing ends at ' + local_time)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec30e81d-8812-4665-be58-00a7e0aa1915",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View file

@ -0,0 +1,137 @@
sequence_name,scene
P0001_10a27bf7,room
P0001_15c4300c,kitchen
P0001_23fa0ee8,office
P0001_4bf4e21a,room
P0001_550ea2ac,room
P0001_624f2ba9,kitchen
P0001_83b755aa,room
P0001_8d136980,room
P0001_95eabc0a,kitchen
P0001_9b6feab7,office
P0001_9c030609,room
P0001_a68492d5,kitchen
P0001_a9d6c83d,room
P0001_b2bcbe28,room
P0001_f6cc0cc8,office
P0001_f71fc9b1,room
P0002_016222d1,kitchen
P0002_2ea9af5b,kitchen
P0002_59a84a3a,kitchen
P0002_65085bfc,kitchen
P0002_c68438ce,kitchen
P0003_1fa0bb65,room
P0003_5766eae8,kitchen
P0003_743d3087,office
P0003_c701bd11,office
P0003_cbd17f20,kitchen
P0003_e3a74169,kitchen
P0003_ebdc6ff7,kitchen
P0003_f4730606,kitchen
P0009_02511c2f,room
P0009_0e02bf39,kitchen
P0009_1b21bb01,kitchen
P0009_247b5403,kitchen
P0009_24af5475,room
P0009_37e30628,office
P0009_5bb7cc2a,room
P0009_5f2583e0,room
P0009_88a58b3b,room
P0009_8c0caf6c,kitchen
P0009_8c95667c,room
P0009_911a4ba5,room
P0009_927973d7,office
P0009_9e03121a,kitchen
P0009_b1e71d7f,room
P0009_b7d8c222,kitchen
P0009_cf323827,room
P0009_e27ad19f,room
P0009_e71e2f24,kitchen
P0009_ea91844d,office
P0010_0ecbf39f,kitchen
P0010_1573a837,office
P0010_160e551c,room
P0010_1c9fe708,kitchen
P0010_41c4c626,kitchen
P0010_573b2de6,office
P0010_6d15aa57,room
P0010_8ff3e5c4,room
P0010_924e574e,kitchen
P0010_99385ad8,room
P0010_b152143e,office
P0010_e481fd15,room
P0010_fd1891a8,room
P0011_0c2d00ed,kitchen
P0011_11475e24,kitchen
P0011_2255f410,kitchen
P0011_30a5b61d,room
P0011_451a7734,room
P0011_47878e48,office
P0011_4dcdcfec,office
P0011_72efb935,kitchen
P0011_76ea6d47,kitchen
P0011_7a8886e7,room
P0011_7c7e8d86,room
P0011_a497658f,office
P0011_ad5f7dee,room
P0011_b0c895c1,kitchen
P0011_ccc678c7,room
P0011_cd22f5e0,kitchen
P0011_cee8fe4f,room
P0011_d0f907a0,office
P0011_dbf1ebb7,room
P0011_e5cb6a80,kitchen
P0011_ff7cfc3a,kitchen
P0012_0323d770,room
P0012_0a21e4c2,room
P0012_119de519,room
P0012_130a66e1,office
P0012_1c45bbd9,office
P0012_44c5f677,kitchen
P0012_476bae57,kitchen
P0012_6e4f7815,office
P0012_73e66984,room
P0012_915e71c6,office
P0012_af3dab9a,room
P0012_b8fc4c1b,kitchen
P0012_c06d939b,kitchen
P0012_c4353c31,room
P0012_ca1f6626,room
P0012_d6272ce1,office
P0012_d85e10f6,kitchen
P0012_db543fe8,kitchen
P0012_e846d3cc,kitchen
P0012_e97d31b6,kitchen
P0012_f1a33781,room
P0012_f7e3880b,room
P0014_0de48e2c,room
P0014_1fdca00e,office
P0014_24cb3bf0,kitchen
P0014_65c6a968,office
P0014_6db96fd0,kitchen
P0014_8254f925,kitchen
P0014_84ea2dcc,kitchen
P0014_9a25ec6a,office
P0014_9b7a0725,room
P0014_e40eec5d,kitchen
P0014_f7ba43e0,room
P0015_179e1b84,kitchen
P0015_1eb4f17f,kitchen
P0015_367cc58d,room
P0015_3a9bb2ae,room
P0015_3c7f5241,room
P0015_3f46732d,room
P0015_42b8b389,room
P0015_4e5d1c14,room
P0015_53358a64,office
P0015_60573a3b,kitchen
P0015_745920f0,kitchen
P0015_7e95628d,room
P0015_7fc6548d,kitchen
P0015_b0c5102b,room
P0015_c3e1f590,kitchen
P0015_cc5dfd13,room
P0015_cc739faa,room
P0015_dbe00981,room
P0015_e3f96b3f,office
P0015_e7458eb3,office
1 sequence_name scene
2 P0001_10a27bf7 room
3 P0001_15c4300c kitchen
4 P0001_23fa0ee8 office
5 P0001_4bf4e21a room
6 P0001_550ea2ac room
7 P0001_624f2ba9 kitchen
8 P0001_83b755aa room
9 P0001_8d136980 room
10 P0001_95eabc0a kitchen
11 P0001_9b6feab7 office
12 P0001_9c030609 room
13 P0001_a68492d5 kitchen
14 P0001_a9d6c83d room
15 P0001_b2bcbe28 room
16 P0001_f6cc0cc8 office
17 P0001_f71fc9b1 room
18 P0002_016222d1 kitchen
19 P0002_2ea9af5b kitchen
20 P0002_59a84a3a kitchen
21 P0002_65085bfc kitchen
22 P0002_c68438ce kitchen
23 P0003_1fa0bb65 room
24 P0003_5766eae8 kitchen
25 P0003_743d3087 office
26 P0003_c701bd11 office
27 P0003_cbd17f20 kitchen
28 P0003_e3a74169 kitchen
29 P0003_ebdc6ff7 kitchen
30 P0003_f4730606 kitchen
31 P0009_02511c2f room
32 P0009_0e02bf39 kitchen
33 P0009_1b21bb01 kitchen
34 P0009_247b5403 kitchen
35 P0009_24af5475 room
36 P0009_37e30628 office
37 P0009_5bb7cc2a room
38 P0009_5f2583e0 room
39 P0009_88a58b3b room
40 P0009_8c0caf6c kitchen
41 P0009_8c95667c room
42 P0009_911a4ba5 room
43 P0009_927973d7 office
44 P0009_9e03121a kitchen
45 P0009_b1e71d7f room
46 P0009_b7d8c222 kitchen
47 P0009_cf323827 room
48 P0009_e27ad19f room
49 P0009_e71e2f24 kitchen
50 P0009_ea91844d office
51 P0010_0ecbf39f kitchen
52 P0010_1573a837 office
53 P0010_160e551c room
54 P0010_1c9fe708 kitchen
55 P0010_41c4c626 kitchen
56 P0010_573b2de6 office
57 P0010_6d15aa57 room
58 P0010_8ff3e5c4 room
59 P0010_924e574e kitchen
60 P0010_99385ad8 room
61 P0010_b152143e office
62 P0010_e481fd15 room
63 P0010_fd1891a8 room
64 P0011_0c2d00ed kitchen
65 P0011_11475e24 kitchen
66 P0011_2255f410 kitchen
67 P0011_30a5b61d room
68 P0011_451a7734 room
69 P0011_47878e48 office
70 P0011_4dcdcfec office
71 P0011_72efb935 kitchen
72 P0011_76ea6d47 kitchen
73 P0011_7a8886e7 room
74 P0011_7c7e8d86 room
75 P0011_a497658f office
76 P0011_ad5f7dee room
77 P0011_b0c895c1 kitchen
78 P0011_ccc678c7 room
79 P0011_cd22f5e0 kitchen
80 P0011_cee8fe4f room
81 P0011_d0f907a0 office
82 P0011_dbf1ebb7 room
83 P0011_e5cb6a80 kitchen
84 P0011_ff7cfc3a kitchen
85 P0012_0323d770 room
86 P0012_0a21e4c2 room
87 P0012_119de519 room
88 P0012_130a66e1 office
89 P0012_1c45bbd9 office
90 P0012_44c5f677 kitchen
91 P0012_476bae57 kitchen
92 P0012_6e4f7815 office
93 P0012_73e66984 room
94 P0012_915e71c6 office
95 P0012_af3dab9a room
96 P0012_b8fc4c1b kitchen
97 P0012_c06d939b kitchen
98 P0012_c4353c31 room
99 P0012_ca1f6626 room
100 P0012_d6272ce1 office
101 P0012_d85e10f6 kitchen
102 P0012_db543fe8 kitchen
103 P0012_e846d3cc kitchen
104 P0012_e97d31b6 kitchen
105 P0012_f1a33781 room
106 P0012_f7e3880b room
107 P0014_0de48e2c room
108 P0014_1fdca00e office
109 P0014_24cb3bf0 kitchen
110 P0014_65c6a968 office
111 P0014_6db96fd0 kitchen
112 P0014_8254f925 kitchen
113 P0014_84ea2dcc kitchen
114 P0014_9a25ec6a office
115 P0014_9b7a0725 room
116 P0014_e40eec5d kitchen
117 P0014_f7ba43e0 room
118 P0015_179e1b84 kitchen
119 P0015_1eb4f17f kitchen
120 P0015_367cc58d room
121 P0015_3a9bb2ae room
122 P0015_3c7f5241 room
123 P0015_3f46732d room
124 P0015_42b8b389 room
125 P0015_4e5d1c14 room
126 P0015_53358a64 office
127 P0015_60573a3b kitchen
128 P0015_745920f0 kitchen
129 P0015_7e95628d room
130 P0015_7fc6548d kitchen
131 P0015_b0c5102b room
132 P0015_c3e1f590 kitchen
133 P0015_cc5dfd13 room
134 P0015_cc739faa room
135 P0015_dbe00981 room
136 P0015_e3f96b3f office
137 P0015_e7458eb3 office

View file

@ -0,0 +1,296 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "bbfb8da4-14a5-44d8-b9b0-d66f032f09fb",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.nice(5)\n",
"import rerun as rr\n",
"import numpy as np\n",
"from math import tan\n",
"import time\n",
"from utils import remake_dir\n",
"import pandas as pd\n",
"from data_loaders.ManoHandDataProvider import MANOHandDataProvider\n",
"from data_loaders.loader_object_library import load_object_library\n",
"from data_loaders.mano_layer import MANOHandModel\n",
"from data_loaders.loader_hand_poses import Handedness, HandPose\n",
"from data_loaders.hand_common import LANDMARK_CONNECTIVITY\n",
"from data_loaders.loader_object_library import ObjectLibrary\n",
"from data_loaders.headsets import Headset\n",
"from projectaria_tools.core.stream_id import StreamId\n",
"from projectaria_tools.core.sensor_data import TimeDomain, TimeQueryOptions\n",
"from projectaria_tools.core.sophus import SE3\n",
"from projectaria_tools.utils.rerun_helpers import ToTransform3D\n",
"\n",
"\n",
"data_path = '/scratch/hu/pose_forecast/hot3d_hoigaze/P0001_10a27bf7_room_721_890_'\n",
"timestamps_path = data_path + 'timestamps.npy'\n",
"head_path = data_path + 'head.npy'\n",
"gaze_path = data_path + 'gaze.npy'\n",
"hand_path = data_path + 'hand.npy'\n",
"hand_joint_path = data_path + 'handjoints.npy'\n",
"object_path = data_path + 'objects.npy'\n",
"object_bbx_path = data_path + 'object_bbx.npy'\n",
"object_library_path = '/datasets/public/zhiming_datasets/hot3d/assets/'\n",
"mano_hand_model_path = '/datasets/public/zhiming_datasets/hot3d/mano_v1_2/models/'\n",
"\n",
"show_bbx = False\n",
"show_hand_mesh = True\n",
"# init the object library\n",
"if not os.path.exists(object_library_path):\n",
" print(\"invalid object library path.\")\n",
" print(\"please follow the instructions at https://github.com/facebookresearch/hot3d to Download the HOT3D Assets Dataset\") \n",
" raise \n",
"object_library = load_object_library(object_library_folderpath=object_library_path)\n",
"\n",
"# init the HANDs model\n",
"if not os.path.exists(mano_hand_model_path):\n",
" print(\"invalid mano hand model path.\")\n",
" print(\"please follow the instructions at https://github.com/facebookresearch/hot3d to Download the MANO files\")\n",
" raise\n",
"mano_hand_model = MANOHandModel(mano_hand_model_path)\n",
"\n",
"timestamps_data = np.load(timestamps_path)\n",
"head_data = np.load(head_path) # head_direction (3) + head_translation (3) + head_rotation (4, quat_xyzw)\n",
"gaze_data = np.load(gaze_path) # gaze_direction (3) + gaze_center_in_world (3)\n",
"hand_data = np.load(hand_path) # left_hand (22) + right_hand (22), hand = wrist_pose (7, translation (3) + rotation (4)) + joint_angles (15)\n",
"hand_joint_data = np.load(hand_joint_path) # left_hand (20*3) + right_hand (20*3)\n",
"object_data = np.load(object_path) # object_data (8) * 6 objects (at most 6 objects), object_data = object_uid (1) + object_pose (7, translation (3) + rotation (4))\n",
"object_bbx_data = np.load(object_bbx_path) # bounding box information: 6 objects (at most 6 objects) * 8 vertexes * 3\n",
"frame_length = len(head_data)\n",
"\n",
"# alias over the HAND pose data provider\n",
"hand_data_provider = MANOHandDataProvider('./mano_hand_pose_init/mano_hand_pose_trajectory.jsonl', mano_hand_model)\n",
"# keep track of what 3D assets have been loaded/unloaded so we will load them only when needed\n",
"object_cache_status = {}\n",
"\n",
"# Init a rerun context\n",
"rr.init(\"hot3d-aria\")\n",
"rec = rr.memory_recording()\n",
"\n",
"def log_pose(\n",
" pose: SE3,\n",
" label: str,\n",
" static=False\n",
") -> None:\n",
" rr.log(label, ToTransform3D(pose, False), static=static)\n",
"\n",
"\n",
"for i in range(frame_length):\n",
" timestamp_ns = timestamps_data[i, 0]\n",
" rr.set_time_nanos(\"synchronization_time\", int(timestamp_ns))\n",
" rr.set_time_sequence(\"timestamp\", int(timestamp_ns))\n",
" \n",
" head_direction = head_data[i, 0:3]\n",
" head_translation = head_data[i, 3:6]\n",
" head_rotation = head_data[i, 6:10] \n",
" gaze_direction = gaze_data[i, 0:3]\n",
" gaze_center_in_world = gaze_data[i, 3:6]\n",
" left_hand_translation = hand_data[i, 0:3]\n",
" left_hand_rotation = hand_data[i, 3:7]\n",
" left_hand_joint_angles = hand_data[i, 7:22]\n",
" left_hand_joints = hand_joint_data[i, 0:60].reshape((20, 3))\n",
" right_hand_translation = hand_data[i, 22:25]\n",
" right_hand_rotation = hand_data[i, 25:29]\n",
" right_hand_joint_angles = hand_data[i, 29:44]\n",
" right_hand_joints = hand_joint_data[i, 60:120].reshape((20, 3))\n",
" left_hand_wrist_pose = SE3.from_quat_and_translation(left_hand_rotation[-1], left_hand_rotation[:-1], left_hand_translation)\n",
" left_hand_pose = HandPose(Handedness.Left, left_hand_wrist_pose, left_hand_joint_angles)\n",
" right_hand_wrist_pose = SE3.from_quat_and_translation(right_hand_rotation[-1], right_hand_rotation[:-1], right_hand_translation)\n",
" right_hand_pose = HandPose(Handedness.Right, right_hand_wrist_pose, right_hand_joint_angles)\n",
" \n",
" # use cpf pose as head pose, see https://facebookresearch.github.io/projectaria_tools/docs/data_formats/coordinate_convention/3d_coordinate_frame_convention\n",
" T_world_cpf = SE3.from_quat_and_translation(head_rotation[-1], head_rotation[:-1], head_translation)\n",
" log_pose(pose=T_world_cpf, label=\"world/head_pose\")\n",
" #rr.log(\n",
" #\"world/head_direction\",\n",
" #rr.Points3D([head_translation], radii=[0.003]),\n",
" #rr.Arrows3D(vectors=[head_direction*0.4], colors=[[0, 0.8, 0.8, 0.5]]))\n",
" #log_pose(pose=left_hand_wrist_pose, label=\"world/left_hand_pose\")\n",
" #log_pose(pose=right_hand_wrist_pose, label=\"world/right_hand_pose\")\n",
" \n",
" rr.log(\n",
" \"world/gaze_direction\",\n",
" rr.Points3D([head_translation], radii=[0.003]),\n",
" rr.Arrows3D(vectors=[gaze_direction*0.4], colors=[[0, 0.8, 0.2, 0.5]]))\n",
" #print(\"frame: {}, gaze: {}\".format(i+1119, gaze_direction))\n",
" \n",
" # plot hands as a triangular mesh representation\n",
" if show_hand_mesh:\n",
" left_hand_mesh_vertices = hand_data_provider.get_hand_mesh_vertices(left_hand_pose)\n",
" left_hand_triangles, left_hand_vertex_normals = hand_data_provider.get_hand_mesh_faces_and_normals(left_hand_pose) \n",
" rr.log(\n",
" f\"world/left_hand/mesh_faces\",\n",
" rr.Mesh3D(\n",
" vertex_positions=left_hand_mesh_vertices,\n",
" vertex_normals=left_hand_vertex_normals,\n",
" triangle_indices=left_hand_triangles))\n",
" right_hand_mesh_vertices = hand_data_provider.get_hand_mesh_vertices(right_hand_pose)\n",
" right_hand_triangles, right_hand_vertex_normals = hand_data_provider.get_hand_mesh_faces_and_normals(right_hand_pose)\n",
" rr.log(\n",
" f\"world/right_hand/mesh_faces\",\n",
" rr.Mesh3D(\n",
" vertex_positions=right_hand_mesh_vertices,\n",
" vertex_normals=right_hand_vertex_normals,\n",
" triangle_indices=right_hand_triangles))\n",
" else:\n",
" #left_hand_translation = np.array([0, 0, 0])\n",
" #left_hand_rotation = np.array([0, 0, 0, 1])\n",
" #left_hand_joint_angles = np.zeros(15)\n",
" #left_hand_wrist_pose = SE3.from_quat_and_translation(left_hand_rotation[-1], left_hand_rotation[:-1], left_hand_translation)\n",
" #log_pose(pose=left_hand_wrist_pose, label=\"world/left_hand_pose\")\n",
" #left_hand_pose = HandPose(Handedness.Left, left_hand_wrist_pose, left_hand_joint_angles)\n",
" #left_hand_joints = hand_data_provider.get_hand_landmarks(left_hand_pose)\n",
" #left_hand_wrist = left_hand_joints[5, :].clone()\n",
" #joint_number = left_hand_joints.shape[0]\n",
" #for index in range(joint_number):\n",
" # left_hand_joints[index, :] -= left_hand_wrist\n",
" #for index in range(joint_number): \n",
" # tmp = left_hand_joints[index, :].clone()\n",
" # left_hand_joints[index, 1] = -tmp[2]\n",
" # left_hand_joints[index, 2] = tmp[1]\n",
" #for index in range(joint_number): \n",
" # print(left_hand_joints[index])\n",
" \n",
" #right_hand_translation = np.array([0, 0, 0])\n",
" #right_hand_rotation = np.array([0, 0, 0, 1])\n",
" #right_hand_joint_angles = np.zeros(15)\n",
" #right_hand_wrist_pose = SE3.from_quat_and_translation(right_hand_rotation[-1], right_hand_rotation[:-1], right_hand_translation)\n",
" #log_pose(pose=right_hand_wrist_pose, label=\"world/right_hand_pose\")\n",
" #right_hand_pose = HandPose(Handedness.Right, right_hand_wrist_pose, right_hand_joint_angles)\n",
" #right_hand_joints = hand_data_provider.get_hand_landmarks(right_hand_pose)\n",
" #right_hand_wrist = right_hand_joints[5, :].clone()\n",
" #joint_number = right_hand_joints.shape[0]\n",
" #for index in range(joint_number):\n",
" # right_hand_joints[index, :] -= right_hand_wrist\n",
" #for index in range(joint_number): \n",
" # tmp = right_hand_joints[index, :].clone()\n",
" # right_hand_joints[index, 1] = -tmp[2]\n",
" # right_hand_joints[index, 2] = tmp[1]\n",
" #for index in range(joint_number): \n",
" # print(right_hand_joints[index])\n",
" \n",
" left_hand_skeleton = [connections\n",
" for connectivity in LANDMARK_CONNECTIVITY\n",
" for connections in [[left_hand_joints[it].tolist() for it in connectivity]]] \n",
" rr.log(\n",
" f\"world/left_hand_skeleton\",\n",
" rr.LineStrips3D(left_hand_skeleton, radii=0.002),\n",
" )\n",
" right_hand_skeleton = [connections\n",
" for connectivity in LANDMARK_CONNECTIVITY\n",
" for connections in [[right_hand_joints[it].tolist() for it in connectivity]]] \n",
" rr.log(\n",
" f\"world/right_hand_skeleton\",\n",
" rr.LineStrips3D(right_hand_skeleton, radii=0.002),\n",
" )\n",
" \n",
" # load objects\n",
" object_num_max = 6\n",
" logging_status = {} \n",
" for item in range(object_num_max):\n",
" object_uid = str(int(object_data[i, item*8]))\n",
" if object_uid == '0':\n",
" break\n",
" logging_status[object_uid] = False\n",
" object_num = len(logging_status)\n",
" for item in range(object_num):\n",
" object_uid = str(int(object_data[i, item*8]))\n",
" object_name = object_library.object_id_to_name_dict[object_uid]\n",
" object_cad_asset_filepath = ObjectLibrary.get_cad_asset_path(\n",
" object_library_folderpath=object_library.asset_folder_name,\n",
" object_id=object_uid)\n",
" object_translation = object_data[i, item*8+1:item*8+4]\n",
" object_rotation = object_data[i, item*8+4:item*8+8]\n",
" object_pose = SE3.from_quat_and_translation(object_rotation[-1], object_rotation[:-1], object_translation) \n",
" log_pose(pose=object_pose, label=f\"world/objects/{object_name}\")\n",
" logging_status[object_uid] = True # mark object has been seen (enable to know which object has been logged or not)\n",
" \n",
" if show_bbx:\n",
" bbx_vertex_0 = object_bbx_data[i, item*24:item*24+3]\n",
" bbx_vertex_1 = object_bbx_data[i, item*24+3:item*24+6]\n",
" bbx_vertex_2 = object_bbx_data[i, item*24+6:item*24+9]\n",
" bbx_vertex_3 = object_bbx_data[i, item*24+9:item*24+12]\n",
" bbx_vertex_4 = object_bbx_data[i, item*24+12:item*24+15]\n",
" bbx_vertex_5 = object_bbx_data[i, item*24+15:item*24+18]\n",
" bbx_vertex_6 = object_bbx_data[i, item*24+18:item*24+21]\n",
" bbx_vertex_7 = object_bbx_data[i, item*24+21:item*24+24] \n",
" points = [\n",
" bbx_vertex_0,\n",
" bbx_vertex_1,\n",
" bbx_vertex_2,\n",
" bbx_vertex_3,\n",
" bbx_vertex_0,\n",
" bbx_vertex_7,\n",
" bbx_vertex_6,\n",
" bbx_vertex_5,\n",
" bbx_vertex_4,\n",
" bbx_vertex_7,\n",
" bbx_vertex_6,\n",
" bbx_vertex_1,\n",
" bbx_vertex_2,\n",
" bbx_vertex_5,\n",
" bbx_vertex_4,\n",
" bbx_vertex_3]\n",
" rr.log(f\"world/objects_bbx/{object_name}\", rr.LineStrips3D([points]))\n",
" \n",
" # link the corresponding 3D object to the pose\n",
" if object_uid not in object_cache_status.keys():\n",
" object_cache_status[object_uid] = True \n",
" rr.log(\n",
" f\"world/objects/{object_name}\",\n",
" rr.Asset3D(path=object_cad_asset_filepath)) \n",
" # if some objects are not visible, we clear the entity\n",
" for object_uid, displayed in logging_status.items():\n",
" if not displayed:\n",
" object_name = object_library.object_id_to_name_dict[object_uid]\n",
" rr.log(\n",
" f\"world/objects/{object_name}\",\n",
" rr.Clear.recursive())\n",
" if show_bbx:\n",
" rr.log(\n",
" f\"world/objects_bbx/{object_name}\",\n",
" rr.Clear.recursive()) \n",
" if object_uid in object_cache_status.keys():\n",
" del object_cache_status[object_uid] # we will log the mesh again\n",
" \n",
"# show the rerun window\n",
"rr.notebook_show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7811d038-6150-46b3-ac62-d4875191e0f4",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View file

@ -0,0 +1,34 @@
object_uid,object_name,bbx_x_min,bbx_x_max,bbx_y_min,bbx_y_max,bbx_z_min,bbx_z_max
106434519822892,bottle_bbq,-0.023,0.021,0,0.145,-0.02,0.04
106957734975303,puzzle_toy,-0.039,0.019,0,0.058,-0.031,0.027
111305855142671,aria_small,-0.073,0.073,-0.03,0.015,-0.141,0.023
117658302265452,mug_patterned,-0.052,0.045,0,0.084,-0.07,0.06
125863066770940,carton_milk,-0.039,0.033,0,0.192,-0.04,0.04
143541090750632,holder_gray,-0.035,0.051,0,0.124,-0.04,0.03
163340972252026,vase,-0.084,0.052,0,0.168,-0.052,0.048
171735388712249,can_parmesan,-0.031,0.035,0,0.102,-0.04,0.03
183136364331389,can_tomato_sauce,-0.034,0.036,0,0.082,-0.036,0.03
194930206998778,bowl,-0.139,0.141,0,0.13,-0.14,0.14
195041665639898,birdhouse_toy,-0.102,0.078,0,0.233,-0.09,0.091
204462113746498,carton_oj,-0.032,0.043,0,0.192,-0.033,0.041
208243983021975,dino_toy,-0.147,0.092,0,0.135,-0.08,0.06
223371871635142,mug_white,-0.068,0.049,0,0.091,-0.04,0.05
225397651484143,spoon_wooden,-0.034,0.034,0,0.018,-0.155,0.155
228358276546933,coffee_pot,-0.066,0.08,0,0.151,-0.043,0.042
232501673989606,holder_black,-0.022,0.04,0,0.111,-0.046,0.045
238686662724712,whiteboard_marker,-0.01,0.009,0,0.121,-0.009,0.011
248247003992116,plate_bamboo,-0.163,0.138,0,0.047,-0.17,0.132
249541253457812,dvd_remote,-0.018,0.017,-0.082,0.082,0.012,0.038
253405647833885,food_waffles,-0.048,0.022,0,0.021,-0.062,0.068
258906041248094,whiteboard_eraser,-0.043,0.024,0,0.037,-0.074,0.074
261746112525368,bottle_mustard,-0.03,0.018,0,0.149,-0.032,0.033
265826671143948,mouse,-0.036,0.034,-0.021,0.021,-0.056,0.054
270231216246839,spatula_red,-0.154,0.149,0,0.042,-0.114,0.097
27078911029651,dumbbell_5lb,-0.042,0.042,-0.09,0.09,-0.037,0.037
37787722328019,keyboard,-0.215,0.215,-0.018,0.002,-0.063,0.066
4111539686391,flask,-0.051,0.069,0,0.301,-0.104,0.056
5462893327580,cellphone,-0.037,0.036,-0.006,0.005,-0.077,0.077
70709727230291,bottle_ranch,-0.023,0.021,0,0.147,-0.034,0.03
79582884925181,potato_masher,-0.06,0.03,0,0.283,-0.047,0.043
96945373046044,food_vegetables,-0.045,0.023,0,0.02,-0.049,0.048
98604936546412,can_soup,-0.033,0.038,0,0.082,-0.035,0.031
1 object_uid object_name bbx_x_min bbx_x_max bbx_y_min bbx_y_max bbx_z_min bbx_z_max
2 106434519822892 bottle_bbq -0.023 0.021 0 0.145 -0.02 0.04
3 106957734975303 puzzle_toy -0.039 0.019 0 0.058 -0.031 0.027
4 111305855142671 aria_small -0.073 0.073 -0.03 0.015 -0.141 0.023
5 117658302265452 mug_patterned -0.052 0.045 0 0.084 -0.07 0.06
6 125863066770940 carton_milk -0.039 0.033 0 0.192 -0.04 0.04
7 143541090750632 holder_gray -0.035 0.051 0 0.124 -0.04 0.03
8 163340972252026 vase -0.084 0.052 0 0.168 -0.052 0.048
9 171735388712249 can_parmesan -0.031 0.035 0 0.102 -0.04 0.03
10 183136364331389 can_tomato_sauce -0.034 0.036 0 0.082 -0.036 0.03
11 194930206998778 bowl -0.139 0.141 0 0.13 -0.14 0.14
12 195041665639898 birdhouse_toy -0.102 0.078 0 0.233 -0.09 0.091
13 204462113746498 carton_oj -0.032 0.043 0 0.192 -0.033 0.041
14 208243983021975 dino_toy -0.147 0.092 0 0.135 -0.08 0.06
15 223371871635142 mug_white -0.068 0.049 0 0.091 -0.04 0.05
16 225397651484143 spoon_wooden -0.034 0.034 0 0.018 -0.155 0.155
17 228358276546933 coffee_pot -0.066 0.08 0 0.151 -0.043 0.042
18 232501673989606 holder_black -0.022 0.04 0 0.111 -0.046 0.045
19 238686662724712 whiteboard_marker -0.01 0.009 0 0.121 -0.009 0.011
20 248247003992116 plate_bamboo -0.163 0.138 0 0.047 -0.17 0.132
21 249541253457812 dvd_remote -0.018 0.017 -0.082 0.082 0.012 0.038
22 253405647833885 food_waffles -0.048 0.022 0 0.021 -0.062 0.068
23 258906041248094 whiteboard_eraser -0.043 0.024 0 0.037 -0.074 0.074
24 261746112525368 bottle_mustard -0.03 0.018 0 0.149 -0.032 0.033
25 265826671143948 mouse -0.036 0.034 -0.021 0.021 -0.056 0.054
26 270231216246839 spatula_red -0.154 0.149 0 0.042 -0.114 0.097
27 27078911029651 dumbbell_5lb -0.042 0.042 -0.09 0.09 -0.037 0.037
28 37787722328019 keyboard -0.215 0.215 -0.018 0.002 -0.063 0.066
29 4111539686391 flask -0.051 0.069 0 0.301 -0.104 0.056
30 5462893327580 cellphone -0.037 0.036 -0.006 0.005 -0.077 0.077
31 70709727230291 bottle_ranch -0.023 0.021 0 0.147 -0.034 0.03
32 79582884925181 potato_masher -0.06 0.03 0 0.283 -0.047 0.043
33 96945373046044 food_vegetables -0.045 0.023 0 0.02 -0.049 0.048
34 98604936546412 can_soup -0.033 0.038 0 0.082 -0.035 0.031

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,4 @@
__all__ = ['file_systems']
from .file_systems import remake_dir, make_dir

View file

@ -0,0 +1,50 @@
import os
import shutil
import time
# remove a directory
def remove_dir(dirName):
if os.path.exists(dirName):
shutil.rmtree(dirName)
else:
print("Invalid directory path!")
# remake a directory
def remake_dir(dirName):
if os.path.exists(dirName):
shutil.rmtree(dirName)
os.makedirs(dirName)
else:
os.makedirs(dirName)
# calculate the number of lines in a file
def file_lines(fileName):
if os.path.exists(fileName):
with open(fileName, 'r') as fr:
return len(fr.readlines())
else:
print("Invalid file path!")
return 0
# make a directory if it does not exist.
def make_dir(dirName):
if os.path.exists(dirName):
print("Directory "+ dirName + " already exists.")
else:
os.makedirs(dirName)
if __name__ == "__main__":
dirName = "test"
RemakeDir(dirName)
time.sleep(3)
MakeDir(dirName)
RemoveDir(dirName)
time.sleep(3)
MakeDir(dirName)
#print(FileLines('233.txt'))