├── README.md
├── chair_pcl.npy
├── mitsuba_scene.png
└── pointflow_fig_colorful.py
/README.md:
--------------------------------------------------------------------------------
1 | # Point Cloud Renderer
2 |
3 | Instructions and scripts for rendering point cloud figures shown in **PointFlow: 3D Point Cloud Generation with Continuous Normalizing Flows**.
4 |
5 | [[Paper]](https://arxiv.org/abs/1906.12320) [[Project GitHub]](https://github.com/stevenygd/PointFlow).
6 |
7 | The script generates a XML file, which describes a 3D scene in the format used by Mitsuba. You will then be able to render it with Mitsuba.
8 |
9 | ## Dependencies
10 | * Python 3.6
11 | * [Mitsuba Renderer](http://www.mitsuba-renderer.org/)
12 |
13 | ## Instructions
14 | ```bash
15 | # Generate scene XML file
16 | python3.6 pointflow_fig_colorful.py
17 |
18 | # Render using Mitsuba
19 | mitsuba mitsuba_scene.xml
20 | ```
21 |
22 | ## Examples
23 |
24 |
25 |
26 |
27 | ## Cite
28 | Please consider citing our work if you find it useful:
29 | ```latex
30 | @article{pointflow,
31 | title={PointFlow: 3D Point Cloud Generation with Continuous Normalizing Flows},
32 | author={Yang, Guandao and Huang, Xun, and Hao, Zekun and Liu, Ming-Yu and Belongie, Serge and Hariharan, Bharath},
33 | journal={arXiv},
34 | year={2019}
35 | }
36 | ```
37 |
--------------------------------------------------------------------------------
/chair_pcl.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zekunhao1995/PointFlowRenderer/ed18fc97bebece1beecd1846d1bb8d76911573c0/chair_pcl.npy
--------------------------------------------------------------------------------
/mitsuba_scene.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zekunhao1995/PointFlowRenderer/ed18fc97bebece1beecd1846d1bb8d76911573c0/mitsuba_scene.png
--------------------------------------------------------------------------------
/pointflow_fig_colorful.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 |
3 | def standardize_bbox(pcl, points_per_object):
4 | pt_indices = np.random.choice(pcl.shape[0], points_per_object, replace=False)
5 | np.random.shuffle(pt_indices)
6 | pcl = pcl[pt_indices] # n by 3
7 | mins = np.amin(pcl, axis=0)
8 | maxs = np.amax(pcl, axis=0)
9 | center = ( mins + maxs ) / 2.
10 | scale = np.amax(maxs-mins)
11 | print("Center: {}, Scale: {}".format(center, scale))
12 | result = ((pcl - center)/scale).astype(np.float32) # [-0.5, 0.5]
13 | return result
14 |
15 | xml_head = \
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 |
45 |
46 |
47 | """
48 |
49 | xml_ball_segment = \
50 | """
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | """
61 |
62 | xml_tail = \
63 | """
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | """
83 |
84 | def colormap(x,y,z):
85 | vec = np.array([x,y,z])
86 | vec = np.clip(vec, 0.001,1.0)
87 | norm = np.sqrt(np.sum(vec**2))
88 | vec /= norm
89 | return [vec[0], vec[1], vec[2]]
90 | xml_segments = [xml_head]
91 |
92 | pcl = np.load('chair_pcl.npy')
93 | pcl = standardize_bbox(pcl, 2048)
94 | pcl = pcl[:,[2,0,1]]
95 | pcl[:,0] *= -1
96 | pcl[:,2] += 0.0125
97 |
98 | for i in range(pcl.shape[0]):
99 | color = colormap(pcl[i,0]+0.5,pcl[i,1]+0.5,pcl[i,2]+0.5-0.0125)
100 | xml_segments.append(xml_ball_segment.format(pcl[i,0],pcl[i,1],pcl[i,2], *color))
101 | xml_segments.append(xml_tail)
102 |
103 | xml_content = str.join('', xml_segments)
104 |
105 | with open('mitsuba_scene.xml', 'w') as f:
106 | f.write(xml_content)
107 |
108 |
109 |
--------------------------------------------------------------------------------