Skip to content

Commit

Permalink
Merge pull request #38 from eth-ait/dev
Browse files Browse the repository at this point in the history
Pull request in preparation for 1.12 Release
  • Loading branch information
kaufManu authored Sep 13, 2023
2 parents edd41e6 + 841ecb2 commit 744a9d6
Show file tree
Hide file tree
Showing 112 changed files with 870 additions and 1,699 deletions.
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For more advanced installation and for installing SMPL body models, please refer

## Features
* Native Python interface, easy to use and hack.
* Load [SMPL[-H/-X]](https://smpl.is.tue.mpg.de/) / [MANO](https://mano.is.tue.mpg.de/) / [FLAME](https://flame.is.tue.mpg.de/) / [STAR](https://github.com/ahmedosman/STAR) sequences and display them in an interactive viewer.
* Load [SMPL[-H/-X]](https://smpl.is.tue.mpg.de/) / [MANO](https://mano.is.tue.mpg.de/) / [FLAME](https://flame.is.tue.mpg.de/) / [STAR](https://github.com/ahmedosman/STAR) / [SUPR](https://github.com/ahmedosman/SUPR) sequences and display them in an interactive viewer.
* Headless mode for server rendering of videos/images.
* Remote mode for non-blocking integration of visualization code.
* Render 3D data on top of images via weak-perspective or OpenCV camera models.
Expand Down
3 changes: 3 additions & 0 deletions aitviewer/aitvconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ backface_culling: True
background_color: [1.0, 1.0, 1.0, 1.0]
window_type: "pyqt5"

# Viewer defaults to Y up, set to true for Z up.
z_up: False

# Server for remote connections.
server_enabled: False
server_port: 8417
17 changes: 1 addition & 16 deletions aitviewer/configuration.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import os

import torch
Expand Down
17 changes: 1 addition & 16 deletions aitviewer/headless.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import os
from typing import Dict, Tuple

Expand Down
17 changes: 1 addition & 16 deletions aitviewer/models/smpl.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import collections
from abc import ABC

Expand Down
17 changes: 1 addition & 16 deletions aitviewer/models/star.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import collections
import os

Expand Down
17 changes: 1 addition & 16 deletions aitviewer/models/supr.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import collections
import os

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/message.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import enum


Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/node.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from .message import Message
from .viewer import RemoteViewer

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/renderables/arrows.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from ..message import Message
from ..node import RemoteNode

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/renderables/lines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from ..message import Message
from ..node import RemoteNode

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/renderables/meshes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from ..message import Message
from ..node import RemoteNode

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/renderables/rigid_bodies.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from ..message import Message
from ..node import RemoteNode

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/renderables/smpl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from ..message import Message
from ..node import RemoteNode

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/renderables/spheres.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
from ..message import Message
from ..node import RemoteNode

Expand Down
1 change: 1 addition & 0 deletions aitviewer/remote/viewer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import asyncio
import pickle
import queue
Expand Down
17 changes: 1 addition & 16 deletions aitviewer/renderables/arrows.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import numpy as np

from aitviewer.renderables.lines import Lines
Expand Down
17 changes: 1 addition & 16 deletions aitviewer/renderables/billboard.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import os
import pickle
from typing import List, Union
Expand Down
17 changes: 1 addition & 16 deletions aitviewer/renderables/bounding_boxes.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import numpy as np

from aitviewer.renderables.lines import Lines
Expand Down
17 changes: 1 addition & 16 deletions aitviewer/renderables/coordinate_system.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import numpy as np

from aitviewer.renderables.rigid_bodies import RigidBodies
Expand Down
59 changes: 43 additions & 16 deletions aitviewer/renderables/lines.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
"""
Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos
import moderngl
import numpy as np
import trimesh
Expand All @@ -33,6 +18,7 @@
compute_vertex_and_face_normals,
set_lights_in_program,
set_material_properties,
usd,
)
from aitviewer.utils.decorators import hooked
from aitviewer.utils.so3 import aa2rot_numpy as aa2rot
Expand Down Expand Up @@ -447,6 +433,47 @@ def remove_frames(self, frames):
self.lines = np.delete(self.lines, frames, axis=0)
self.redraw()

def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False):
name = f"{self.name}_{self.uid:03}".replace(" ", "_")
usd_path = f"{usd_path}/{name}"

if self.mode == "lines":
v0s = self.lines[:, ::2]
v1s = self.lines[:, 1::2]
else:
v0s = self.lines[:, :-1]
v1s = self.lines[:, 1:]

print(self.lines.shape)
print(v0s.shape)

# Data is in the form of (F, N_LINES, 3), convert it to (F*N_LINES, 3)
v0s = np.reshape(v0s, (-1, 3))
v1s = np.reshape(v1s, (-1, 3))

self.r_tip = self.r_base if self.r_tip is None else self.r_tip

# If r_tip is below a certain threshold, we create a proper cone, i.e. with just a single vertex at the top.
if self.r_tip < 10e-6:
data = _create_cone_from_to(v0s, v1s, radius=self.r_base)
else:
data = _create_cylinder_from_to(v0s, v1s, radius1=self.r_base, radius2=self.r_tip)

L = self.n_lines
V = data["vertices"].shape[1]

vertices = data["vertices"].reshape((self.n_frames, -1, 3))
faces = data["faces"]

fs = faces[np.newaxis].repeat(L, 0).reshape((L, -1))
offsets = (np.arange(L) * V).reshape((L, 1))
faces = (fs + offsets).reshape((-1, 3))

mesh = usd.add_mesh(stage, usd_path, self.name, vertices, faces, self.get_local_transform())
usd.add_color(stage, mesh, usd_path, self.color[:3])

self._export_usd_recursively(stage, usd_path, directory, verbose)


class Lines2D(Node):
"""Render 2D lines."""
Expand Down
Loading

0 comments on commit 744a9d6

Please sign in to comment.