def render_from_depth()

in tacto/renderer.py [0:0]


    def render_from_depth(self, depth, noise=True, calibration=True, scale=1.0):
        """
        :param depth:
        :param scale:
        :return:
        """
        # Load config
        X0 = self.conf.sensor.gel.origin[0]
        width = self.conf.sensor.gel.width
        height = self.conf.sensor.gel.height

        # scale depth map
        depth = depth * scale

        # Auto-fit the canvas size
        h_resize = depth.shape[0]
        w_resize = int(h_resize * width / height)
        depth_resize = np.zeros([w_resize, h_resize])

        if w_resize <= depth.shape[1]:
            w_left = int((depth.shape[1] - w_resize) / 2)
            depth_resize = depth[:, w_left : w_left + w_resize]
        else:
            w_left = int((w_resize - depth.shape[1]) / 2)
            print("w_left", w_left, "depth shape", depth.shape)
            depth_resize[:, w_left : w_left + depth.shape[1]] = depth

        surf_trimesh = self._generate_trimesh_from_depth(X0 - depth_resize)
        mesh = pyrender.Mesh.from_trimesh(surf_trimesh, smooth=True)

        # Update depth node
        self.gel_node_depth.mesh = mesh

        color, depth = self.r.render(self.scene_depth)
        color, depth = self._post_process(color, depth, 0, noise, calibration)

        return color, depth