Download HOT3DHUGGFACE/data_loaders/PathProvider.py from LIDAR-GT/handpose_annotations: direct link, hf CLI and curl.
- Browser
- Download file 4.76 kB
-
https://huggingface.co/datasets/LIDAR-GT/handpose_annotations/resolve/main/HOT3DHUGGFACE/data_loaders/PathProvider.py
- Command line
-
hf download hf://datasets/LIDAR-GT/handpose_annotations/HOT3DHUGGFACE/data_loaders/PathProvider.py
-
curl -L -o PathProvider.py https://huggingface.co/datasets/LIDAR-GT/handpose_annotations/resolve/main/HOT3DHUGGFACE/data_loaders/PathProvider.py
4.76 kB
| # Copyright (c) Meta Platforms, Inc. and affiliates. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import os | |
| from abc import abstractmethod | |
| from .headsets import Headset | |
| from .io_utils import load_json | |
| #提供所有文件的地址 | |
| class SequenceDatasetPathsBase: | |
| """ | |
| Class defining the expected filepaths for a given HOT3D sequence | |
| This base class can be extended to support headset specific filepaths (Aria, Quest, etc.) | |
| """ | |
| def __init__(self, recording_instance_folderpath): | |
| self._recording_instance_folderpath = recording_instance_folderpath | |
| def recording_instance_folderpath(self): | |
| return self._recording_instance_folderpath | |
| def dynamic_objects_filepath(self): | |
| return f"{self._recording_instance_folderpath}/dynamic_objects.csv" | |
| def headset_trajectory_filepath(self): | |
| return f"{self._recording_instance_folderpath}/headset_trajectory.csv" | |
| def mano_hand_pose_trajectory_filepath(self): | |
| return f"{self._recording_instance_folderpath}/mano_hand_pose_trajectory.jsonl" | |
| def umetrack_hand_user_profile_filepath(self): | |
| return f"{self._recording_instance_folderpath}/umetrack_hand_user_profile.json" | |
| def umetrack_hand_pose_trajectory_filepath(self): | |
| return ( | |
| f"{self._recording_instance_folderpath}/umetrack_hand_pose_trajectory.jsonl" | |
| ) | |
| def vrs_filepath(self): | |
| return f"{self._recording_instance_folderpath}/recording.vrs" | |
| def box2d_objects_filepath(self): | |
| return f"{self._recording_instance_folderpath}/box2d_objects.csv" | |
| def box2d_hands_filepath(self): | |
| return f"{self._recording_instance_folderpath}/box2d_hands.csv" | |
| def scene_metadata_filepath(self): | |
| return f"{self._recording_instance_folderpath}/metadata.json" | |
| def is_valid(self) -> bool: | |
| """ | |
| Returns if the list of required file for the Headset sequence are available | |
| """ | |
| class Hot3dDataPathProvider(object): | |
| def fromRecordingFolder(recording_instance_folderpath) -> SequenceDatasetPathsBase: | |
| metadata_filepath = os.path.join(recording_instance_folderpath, "metadata.json") | |
| metadata_json = load_json(metadata_filepath) | |
| headset = Headset[metadata_json["headset"]] | |
| if headset is Headset.Aria: | |
| return AriaDatasetPaths( | |
| recording_instance_folderpath=recording_instance_folderpath | |
| ) | |
| elif headset is Headset.Quest3: | |
| return Quest3DatasetPaths( | |
| recording_instance_folderpath=recording_instance_folderpath | |
| ) | |
| else: | |
| raise NotImplementedError(f"{headset} not supported at the moment.") | |
| #继承,子类自动拥有父类的所有属性和方法 | |
| class Quest3DatasetPaths(SequenceDatasetPathsBase): | |
| def __init__(self, recording_instance_folderpath): | |
| super().__init__(recording_instance_folderpath) | |
| def camera_models_filepath(self): | |
| return f"{self._recording_instance_folderpath}/camera_models.json" | |
| def required_filepaths(self): | |
| return [ | |
| self.vrs_filepath, | |
| self.dynamic_objects_filepath, | |
| self.headset_trajectory_filepath, | |
| self.camera_models_filepath, | |
| self.mano_hand_pose_trajectory_filepath, | |
| ] | |
| def is_valid(self) -> bool: | |
| return all(os.path.exists(filepath) for filepath in self.required_filepaths) | |
| class AriaDatasetPaths(SequenceDatasetPathsBase): | |
| def __init__(self, recording_instance_folderpath): | |
| super().__init__(recording_instance_folderpath) | |
| def mps_folderpath(self): | |
| return f"{self._recording_instance_folderpath}/mps" | |
| def required_filepaths(self): | |
| return [ | |
| self.vrs_filepath, | |
| self.dynamic_objects_filepath, | |
| self.headset_trajectory_filepath, | |
| self.mano_hand_pose_trajectory_filepath, | |
| ] | |
| def is_valid(self) -> bool: | |
| return all(os.path.exists(filepath) for filepath in self.required_filepaths) | |