Closed wwwpkol closed 8 months ago
Yes, this can be achieved with some color maps from matplotlib (not a dependency of aitviewer, so to be installed if it's not yet in your environment):
import os
import numpy as np
from aitviewer.configuration import CONFIG as C
from aitviewer.renderables.smpl import SMPLSequence
from aitviewer.renderables.meshes import Meshes
from aitviewer.viewer import Viewer
if __name__ == "__main__":
# Load a random AMASS sequence to get some SMPL data.
c = (149 / 255, 85 / 255, 149 / 255, 0.5)
seq_amass = SMPLSequence.from_amass(
npz_data_path=os.path.join(C.datasets.amass, "ACCAD/Female1Running_c3d/C2 - Run to stand_poses.npz"),
fps_out=60.0,
color=c,
name="AMASS Running",
show_joint_angles=True,
)
# Extract two meshes, let's pretend vertices1 is the ground-truth.
vertices1 = seq_amass.mesh_seq.vertices[0]
vertices2 = seq_amass.mesh_seq.vertices[30]
vertices1 = vertices1 - np.mean(vertices1, axis=0, keepdims=True)
vertices2 = vertices2 - np.mean(vertices2, axis=0, keepdims=True)
# Swap z and y because for AMASS z is up, but in the viewer y is up. This is usually not required if you don't use AMASS data.
vertices1[:, [1, 2]] = vertices1[:, [2, 1]]
vertices2[:, [1, 2]] = vertices2[:, [2, 1]]
faces = seq_amass.mesh_seq.faces
faces[:, [1, 2]] = faces[:, [2, 1]]
# Pick a color map of your liking https://matplotlib.org/stable/users/explain/colors/colormaps.html
from matplotlib.pyplot import cm
color_map = cm.get_cmap('viridis', 256)
color_map_output = color_map(np.linalg.norm(vertices2 - vertices1, axis=-1))
# Create mesh objects and display it in the viewer.
mesh1 = Meshes(vertices=vertices1, faces=faces, name="mesh1")
mesh2 = Meshes(vertices=vertices2, faces=faces, vertex_colors=color_map_output, name="mesh2", position=np.array([-1.0, 0.0, -1.0]))
v = Viewer()
v.scene.add(mesh1, mesh2)
v.run()
Which then looks like this (may be the cool
color map would produce more similar results to your screenshot):
Thank you very much for your enthusiastic and detailed answer!
Thank you for such an experienced work, the visualization has tortured me to the point of unconsciousness!
I am currently working on joint prediction. I have seen comparisons between other people’s work and GT. The greater the difference, the more obvious the color. Do you have any examples of this?
Thank you so much!