Skip to content

uv_triangles Path in the DFSNet/src/dataset/uv_face.py #8

Description

@Dharmendra04

I want to visualize the created meshes through MeshLab from the out['face_uvm']. I need to change this UV map to a mesh using the provided code. But I couldn't find uv_triangles path in the code. What should be the path to it. Below is the code I am using:

Code

import numpy as np
import trimesh

def uvm2mesh(uv_position_map, only_foreface=True, is_extra_triangle=False):
    """
    If no texture map is provided, translate the position map to a point cloud
    :param uv_position_map:
    :param only_foreface:
    :param is_extra_triangle:
    :return:
    """
    uv_h, uv_w = UV_MAP_SIZE, UV_MAP_SIZE
    vertices = []
    colors = []
    triangles = []
    triangles = [[t[0] * uv_w + t[1], t[4] * uv_w + t[5], t[2] * uv_w + t[3], ] for t in uv_triangles]
    for i in range(uv_h):
        for j in range(uv_w):
            vertices.append(uv_position_map[i][j])
            colors.append([25, 25, 50, 128])

    vertices = np.array(vertices)
    triangles = np.array(triangles)
    colors = np.array(colors)
    face_mesh = trimesh.Trimesh(vertices=vertices, faces=triangles)

    return face_mesh

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions