-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_3dgs.py
More file actions
43 lines (32 loc) · 1.3 KB
/
example_3dgs.py
File metadata and controls
43 lines (32 loc) · 1.3 KB
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
import os
import numpy as np
import multiprocessing as mp
from api import RenderEngine
test_scene_file_path = "assets/lego_gaussians.json"
render_engine = RenderEngine("GaussianSplatter", "JsonLoader")
render_engine.engine_launch()
render_engine.Load_scene(test_scene_file_path)
k_matrix = np.array((
(1000, 0.0, 640),
(0.0, 1000, 480),
(0.0, 0.0, 1.0)
))
frame_action = {"camera_action": {
"Camera": {"k_matrix": k_matrix},
}}
render_engine.render_frame(frame_action)
camera_pose = np.array(((-0.8191520571708679, -0.2867882251739502, 0.49673178791999817, 5),
(0.5735764503479004, -0.4095759987831116, 0.7094064950942993, 7),
(0.0, 0.866025447845459, 0.4999999701976776, 4.5),
(0.0, 0.0, 0.0, 1.0)))
rgb_image_list = []
for _ in range(1859): # 1859 frames in total
frame_action = {"camera_action": {"Camera": {"c2w_matrix": camera_pose}}}
render_result = render_engine.render_frame(frame_action)
rgb_image_list.append(render_result["rgb_image"]["Camera"][0])
render_engine.engine_finish()
import cv2
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('output.mp4', fourcc, 60, (rgb_image_list[0].shape[1], rgb_image_list[0].shape[0]))
[out.write(cv2.cvtColor(img, cv2.COLOR_RGB2BGR)) for img in rgb_image_list]
out.release()