|
| 1 | +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. |
| 2 | + |
| 3 | +import hydra |
| 4 | + |
| 5 | +from pytouch.common.visualizer import Visualizer3D, Visualizer3DViewParams |
| 6 | +from pytouch.datasets.sequence import ImageSequenceDataset |
| 7 | +from pytouch.sensors import DigitSensor |
| 8 | +from pytouch.tasks import Surface3D |
| 9 | + |
| 10 | + |
| 11 | +@hydra.main(config_path="configs", config_name="digit_surface3d.yaml") |
| 12 | +def visualize_surface_3d(cfg): |
| 13 | + # load touch sequence dataset |
| 14 | + img_seq_ds = ImageSequenceDataset(cfg.dataset.path) |
| 15 | + |
| 16 | + # define a custom camera view |
| 17 | + view_params = Visualizer3DViewParams( |
| 18 | + fov=60, # field of view |
| 19 | + front=[0.4257, -0.2125, -0.8795], # front vector |
| 20 | + lookat=[0.02, 0.0, 0.0], # look at vector |
| 21 | + up=[0.9768, -0.0694, 0.2024], # up vector |
| 22 | + zoom=0.25, # zoom |
| 23 | + ) |
| 24 | + |
| 25 | + # initialize point cloud visualizer |
| 26 | + visualizer = Visualizer3D(view_params=view_params) |
| 27 | + |
| 28 | + # initialize surface 3d model |
| 29 | + surface3d = Surface3D( |
| 30 | + DigitSensor, |
| 31 | + sensor_params=cfg.sensor, |
| 32 | + ) |
| 33 | + |
| 34 | + # get first sequence |
| 35 | + sequence = img_seq_ds[0] |
| 36 | + for img in sequence: |
| 37 | + output = surface3d.point_cloud_3d(img_color=img) |
| 38 | + visualizer.render(output.points_3d) |
| 39 | + # you may also plot the color, predicted normal, and predicted depth images |
| 40 | + # color = output.color |
| 41 | + # depth = output.depth |
| 42 | + # normal = output.normal |
| 43 | + |
| 44 | + |
| 45 | +if __name__ == "__main__": |
| 46 | + visualize_surface_3d() |
0 commit comments