-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.py
32 lines (26 loc) · 1.04 KB
/
demo.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
import time
from matplotlib import pyplot as plt
import torch
from pyrender import render, testutils
p_xmax, p_ymax = 200, 120
f_x, f_y = 600, 600
c_x, c_y = int(p_xmax / 2), int(p_ymax / 2)
sphere = testutils.Sphere(z_offset=10, radius=0.5)
# Render silhouette
start = time.time()
image = render.render_silhouette(f_x, f_y, c_x, c_y, p_xmax=p_xmax, p_ymax=p_ymax, obj=sphere, max_dist=12)
end = time.time()
print('Rendering silhouette took {:.03f} seconds for image of size {}x{}'.format((end - start) * 1, p_xmax, p_ymax))
plt.imshow(image.permute(1, 0))
plt.show()
plt.imshow(image.permute(1, 0))
plt.savefig('results/sphere_silhouette.png')
# Render normals
start = time.time()
image = render.render_normals(f_x, f_y, c_x, c_y, p_xmax=p_xmax, p_ymax=p_ymax, obj=sphere, max_dist=12)
end = time.time()
print('Rendering normals took {:.03f} seconds for image of size {}x{}'.format((end - start) * 1, p_xmax, p_ymax))
plt.imshow((image.permute(2, 1, 0) + 1) / 2)
plt.show()
plt.imshow((image.permute(2, 1, 0) + 1) / 2)
plt.savefig('results/sphere_normal.png')