Ejemplo n.º 1
0
def main():

    # The model
    model_path = os.path.join(util.get_chira_root(), "data/models/hand-model-v3/exported_template_from_blender")
    model = load_model(model_path)
    viewer = ModelViewer(model, optimizer.Optimizer(model_path, model))
    viewer.sequence = local_annotation_sequence()
    viewer.start()
Ejemplo n.º 2
0
def main():

    # The model
    model_path = os.path.join(
        util.get_chira_root(),
        'data/models/hand-model-v3/exported_template_from_blender')
    model = load_model(model_path)
    viewer = ModelViewer(model, optimizer.Optimizer(model_path, model))
    viewer.sequence = local_annotation_sequence()
    viewer.start()
Ejemplo n.º 3
0
import os

from pychira.model import load_model
from pychira import util

util.add_ezvtk_to_path()
import ezvtk.vis
import ezvtk.troupe

import vtk

model_path = os.path.join(
    util.get_chira_root(),
    'data/models/hand-model-v3/exported_template_from_blender')

model = load_model(model_path)


class ModelViewer():
    def __init__(self):

        self.viewer = ezvtk.vis.Viewer()

        # Add triangular mesh.
        self.mesh_troupe = ezvtk.troupe.MeshTroupe()
        self.mesh_troupe.set_polygons(model.triangles)
        self.mesh_troupe.set_points(model.base_positions)

        # Also add points for easy picking with the mouse.
        self.vertices_troupe = ezvtk.troupe.SpheresTroupe(color=(.2, .5, .7),
                                                          radius=0.002)
Ejemplo n.º 4
0
#for i_data_point in range(n_data_points):
#    energy.data_points[i_data_point] = vertex_positions[correspondences[i_data_point]]
#print('Energy with perfect data point correspondences:', energy.evaluate(theta))

## Now add some noise to the data points.
#energy.data_points += .1 * np.random.randn(*energy.data_points.shape)

##save_instance("C:/Users/t-filsra/Workspace/autodiff/hand/instance.txt", correspondences, data_points, theta);

#print('Energy with noisy data points:', energy.evaluate(theta))


#### generate instances ####
n_data_points = [100, 192, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 100000]
data_dir = "C:/Users/t-filsra/Workspace/autodiff/hand_instances/complicated_big/"
model = load_model(data_dir + "model/")

for i in range(len(n_data_points)):
        
    ### complicated version ###
    correspondences = np.random.random_integers(0, model.triangles.shape[0] - 1, n_data_points[i])
    data_points = np.zeros((n_data_points[i], 3))

    energy = Energy(model, data_points, correspondences)

    theta = np.random.randn(energy.n_theta)
    us = np.random.rand(n_data_points[i], 2)*0.5;

    pose_params = energy.to_pose_params(theta)
    vertex_positions = model.get_skinned_vertex_positions(pose_params)
    for i_data_point,u in zip(range(n_data_points[i]),us):
Ejemplo n.º 5
0
"""A script to display the hand model."""
import os

from pychira.model import load_model
from pychira import util

util.add_ezvtk_to_path()
import ezvtk.vis
import ezvtk.troupe

import vtk

model_path = os.path.join(util.get_chira_root(), 'data/models/hand-model-v3/exported_template_from_blender')

model = load_model(model_path)

class ModelViewer():

    def __init__(self):

        self.viewer = ezvtk.vis.Viewer()

        # Add triangular mesh.
        self.mesh_troupe = ezvtk.troupe.MeshTroupe()
        self.mesh_troupe.set_polygons(model.triangles)
        self.mesh_troupe.set_points(model.base_positions)

        # Also add points for easy picking with the mouse.
        self.vertices_troupe = ezvtk.troupe.SpheresTroupe(color=(.2, .5, .7), radius=0.002)
        self.vertices_troupe.set_positions(model.base_positions)
Ejemplo n.º 6
0
#    energy.data_points[i_data_point] = vertex_positions[correspondences[i_data_point]]
#print('Energy with perfect data point correspondences:', energy.evaluate(theta))

## Now add some noise to the data points.
#energy.data_points += .1 * np.random.randn(*energy.data_points.shape)

##save_instance("C:/Users/t-filsra/Workspace/autodiff/hand/instance.txt", correspondences, data_points, theta);

#print('Energy with noisy data points:', energy.evaluate(theta))

#### generate instances ####
n_data_points = [
    100, 192, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 100000
]
data_dir = "C:/Users/t-filsra/Workspace/autodiff/hand_instances/complicated_big/"
model = load_model(data_dir + "model/")

for i in range(len(n_data_points)):

    ### complicated version ###
    correspondences = np.random.random_integers(0,
                                                model.triangles.shape[0] - 1,
                                                n_data_points[i])
    data_points = np.zeros((n_data_points[i], 3))

    energy = Energy(model, data_points, correspondences)

    theta = np.random.randn(energy.n_theta)
    us = np.random.rand(n_data_points[i], 2) * 0.5

    pose_params = energy.to_pose_params(theta)