forked from saikiran321/nonrigid_icp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (26 loc) · 1.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np
import open3d as o3d
import copy
from icp import icp,draw_registration_result
from nricp import nonrigidIcp
#read source file
targetmesh = o3d.io.read_triangle_mesh("data/exp_b.ply")
sourcemesh = o3d.io.read_triangle_mesh("data/male_0001.ply")
# sourcemesh = o3d.io.read_triangle_mesh("data/source_test.obj")
# targetmesh = o3d.io.read_triangle_mesh("data/target_half.obj")
sourcemesh.compute_vertex_normals()
targetmesh.compute_vertex_normals()
#first find rigid registration
# guess for inital transform for icp
initial_guess = np.eye(4)
affine_transform = icp(sourcemesh,targetmesh,initial_guess)
#creating a new mesh for non rigid transform estimation
refined_sourcemesh = copy.deepcopy(sourcemesh)
refined_sourcemesh.transform(affine_transform)
refined_sourcemesh.compute_vertex_normals()
#non rigid registration
deformed_mesh = nonrigidIcp(refined_sourcemesh,targetmesh)
sourcemesh.paint_uniform_color([0.1, 0.9, 0.1])
targetmesh.paint_uniform_color([0.9,0.1,0.1])
deformed_mesh.paint_uniform_color([0.1,0.1,0.9])
o3d.visualization.draw_geometries([targetmesh,deformed_mesh])