Ejemplo n.º 1
0
 def save(self, fp):
     igl.writeOBJ(fp, self._V, self._F)
            objdir + '/ori_color_crop' + '.obj',
        )
        target_V = scaleToOriCoodi_bottomleft(V, BB, 192)
        write_full_obj(
            target_V,
            F,
            np.array([]),
            np.array([]),
            np.array([]),
            np.array([]),
            vtx_color,
            objdir + '/ori_color' + '.obj',
        )
        igl.writeOBJ(objdir + '/Target_corr' + '.obj',
                     igl.eigen.MatrixXd(target_V), igl.eigen.MatrixXi(F_igl),
                     igl.eigen.MatrixXd(VertexNormal),
                     igl.eigen.MatrixXi(F_igl), igl.eigen.MatrixXd(),
                     igl.eigen.MatrixXi())
#       break
    else:
        n_f = igl.eigen.MatrixXi()
        t_v = igl.eigen.MatrixXd()
        t_f = igl.eigen.MatrixXi()
        igl.readOBJ(objdir + '/Target_corr' + '.obj', V_igl, t_v, VertexNormal,
                    F_igl, t_f, n_f)
        target_V = np.array(V_igl)
        if target_V.shape[1] > 3:
            target_V = target_V[:, 0:3]

# 2. 提取对称面
    mesh_center, main_dir, eigenvalues = k_main_dir_sklearn(target_V, 3)
Ejemplo n.º 3
0
from __future__ import print_function
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import pyigl as igl

# Load a mesh in OFF format
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF("../../tutorial/shared/cube.off", V, F)

# Print the vertices and faces matrices
print("Vertices: \n", V, sep='')
print("Faces: \n", F, sep='')

# Save the mesh in OBJ format
igl.writeOBJ("cube.obj",V,F)
Ejemplo n.º 4
0
#!/usr/bin/env python
#
# This file is part of libigl, a simple c++ geometry processing library.
#
# Copyright (C) 2017 Sebastian Koch <*****@*****.**> and Daniele Panozzo <*****@*****.**>
#
# This Source Code Form is subject to the terms of the Mozilla Public License
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
import sys, os

# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH

# Load a mesh in OFF format
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF(TUTORIAL_SHARED_PATH + "cube.off", V, F)

# Print the vertices and faces matrices (commented out to make this file compatible with python 2.x and 3.x)
# print("Vertices: \n", V, sep='')
# print("Faces: \n", F, sep='')

# Save the mesh in OBJ format
igl.writeOBJ("cube.obj", V, F)
Ejemplo n.º 5
0
model_path = './models/female_model.pkl'  # change to 'female_model.pkl' or 'generic_model.pkl', if needed
model = load_model(model_path)

sphere_v = igl.eigen.MatrixXd()
sphere_f = igl.eigen.MatrixXi()
igl.readOBJ('sphere.obj', sphere_v, sphere_f)
sphere_v = np.array(sphere_v)
sphere_f = np.array(sphere_f)

model.pose[6:9] = np.array([0.2, 0, 0])
# select corresponding vertices
mesh_verts = model.r
mesh_faces = model.f
embedding_vertex = np.vstack([
    (mesh_verts[mesh_faces[lmk_face_idx], 0] * lmk_b_coords).sum(axis=1),
    (mesh_verts[mesh_faces[lmk_face_idx], 1] * lmk_b_coords).sum(axis=1),
    (mesh_verts[mesh_faces[lmk_face_idx], 2] * lmk_b_coords).sum(axis=1)
]).T

lmk_num = embedding_vertex.shape[0]
igl.writeOBJ('./landmark_embedding_squence_openmouse/' + 'mesh' + '.obj',
             igl.eigen.MatrixXd(mesh_verts.astype('float64')),
             igl.eigen.MatrixXi(mesh_faces.astype('intc')))
for i in range(0, lmk_num):
    sphere_v_move = sphere_v + embedding_vertex[i, :]
    igl.writeOBJ('./landmark_embedding_squence_openmouse/' + str(i) + '.obj',
                 igl.eigen.MatrixXd(sphere_v_move.astype('float64')),
                 igl.eigen.MatrixXi(sphere_f.astype('intc')))

frame_landmark_idx = range(17, 60) + range(61, 64) + range(65, 68)
Ejemplo n.º 6
0
import trimesh
from fitting.util import save_landmark
# print logged messages
trimesh.util.attach_to_log()
sys.path.insert(0, "D:/mprojects/libiglfull/libigl/python/build/x64/Release")
import pyigl as igl
# load a mesh
mesh = trimesh.load('L:/yuanqing/imgs/imgs/vrn_result/niutou/01/01.obj')
ray_origins = np.zeros((1024 * 683, 3), dtype=np.int)
ray_directions = np.zeros((1024 * 683, 3), dtype=np.int)
for x in range(0, 1024):
    for y in range(0, 683):
        ray_origins[x * 683 + y, :] = np.array([x, y, 192])
        ray_directions[x * 683 + y, :] = np.array([0, 0, -1])

index_triangles, index_ray, result_locations = mesh.ray.intersects_id(
    ray_origins=ray_origins,
    ray_directions=ray_directions,
    multiple_hits=False,
    return_locations=True)
print index_triangles, index_ray, result_locations
index_triangles = index_triangles.reshape(index_triangles.size, 1)
index_ray = index_triangles.reshape(index_ray.size, 1)
save_landmark('index_triangles.txt', index_triangles)
save_landmark('index_ray.txt', index_ray)
save_landmark('result_locations.txt', result_locations)

igl.writeOBJ('embree_hit' + '.obj',
             igl.eigen.MatrixXd(result_locations.astype('float64')),
             igl.eigen.MatrixXi(), igl.eigen.MatrixXd(), igl.eigen.MatrixXi(),
             igl.eigen.MatrixXd(), igl.eigen.MatrixXi())