mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 14:28:41 +08:00
add direct render via viewer and notifications
This commit is contained in:
1 parent
c273891cb3
commit
c43e9e0671
2 files changed
+30
-29
No files matched your search
@@ -439,6 +439,8 @@ class RenderCameraPath(BaseRender):
|
|||||||
"""Filename of the camera path to render."""
|
"""Filename of the camera path to render."""
|
||||||
output_format: Literal["images", "video"] = "video"
|
output_format: Literal["images", "video"] = "video"
|
||||||
"""How to save output data."""
|
"""How to save output data."""
|
||||||
|
complete: bool = True
|
||||||
|
"""Whether rendering is complete"""
|
||||||
|
|
||||||
def main(self) -> None:
|
def main(self) -> None:
|
||||||
"""Main function."""
|
"""Main function."""
|
||||||
@@ -575,7 +577,7 @@ class RenderCameraPath(BaseRender):
|
|||||||
if str(left_eye_path.parent)[-5:] == "_temp":
|
if str(left_eye_path.parent)[-5:] == "_temp":
|
||||||
shutil.rmtree(left_eye_path.parent, ignore_errors=True)
|
shutil.rmtree(left_eye_path.parent, ignore_errors=True)
|
||||||
CONSOLE.print("[bold green]Final VR180 Render Complete")
|
CONSOLE.print("[bold green]Final VR180 Render Complete")
|
||||||
|
self.complete = True
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class RenderInterpolated(BaseRender):
|
class RenderInterpolated(BaseRender):
|
||||||
|
|||||||
@@ -1050,8 +1050,17 @@ def populate_render_tab(
|
|||||||
@render_button.on_click
|
@render_button.on_click
|
||||||
def _(event: viser.GuiEvent) -> None:
|
def _(event: viser.GuiEvent) -> None:
|
||||||
assert event.client is not None
|
assert event.client is not None
|
||||||
|
render_path = f"""renders/{datapath.name}/{render_name_text.value}.mp4"""
|
||||||
|
server.add_notification(
|
||||||
|
title="Rendering trajectory",
|
||||||
|
body="Saving rendered video as " + render_path,
|
||||||
|
withCloseButton=True,
|
||||||
|
loading=True,
|
||||||
|
autoClose=False,
|
||||||
|
)
|
||||||
num_frames = int(framerate_number.value * duration_number.value)
|
num_frames = int(framerate_number.value * duration_number.value)
|
||||||
json_data = {}
|
json_data = {}
|
||||||
|
|
||||||
# json data has the properties:
|
# json data has the properties:
|
||||||
# keyframes: list of keyframes with
|
# keyframes: list of keyframes with
|
||||||
# matrix : flattened 4x4 matrix
|
# matrix : flattened 4x4 matrix
|
||||||
@@ -1070,7 +1079,7 @@ def populate_render_tab(
|
|||||||
# aspect: float
|
# aspect: float
|
||||||
# first populate the keyframes:
|
# first populate the keyframes:
|
||||||
keyframes = []
|
keyframes = []
|
||||||
for keyframe, dummy in camera_path._keyframes.values():
|
for keyframe, _ in camera_path._keyframes.values():
|
||||||
pose = tf.SE3.from_rotation_and_translation(
|
pose = tf.SE3.from_rotation_and_translation(
|
||||||
tf.SO3(keyframe.wxyz) @ tf.SO3.from_x_radians(np.pi),
|
tf.SO3(keyframe.wxyz) @ tf.SO3.from_x_radians(np.pi),
|
||||||
keyframe.position / VISER_NERFSTUDIO_SCALE_RATIO,
|
keyframe.position / VISER_NERFSTUDIO_SCALE_RATIO,
|
||||||
@@ -1143,34 +1152,24 @@ def populate_render_tab(
|
|||||||
json_outfile.parent.mkdir(parents=True, exist_ok=True)
|
json_outfile.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(json_outfile.absolute(), "w") as outfile:
|
with open(json_outfile.absolute(), "w") as outfile:
|
||||||
json.dump(json_data, outfile)
|
json.dump(json_data, outfile)
|
||||||
# now show the command
|
|
||||||
with event.client.add_gui_modal("Render") as modal:
|
|
||||||
dataname = datapath.name
|
|
||||||
command = " ".join(
|
|
||||||
[
|
|
||||||
"ns-render camera-path",
|
|
||||||
f"--load-config {config_path}",
|
|
||||||
f"--camera-path-filename {json_outfile.absolute()}",
|
|
||||||
f"--output-path renders/{dataname}/{render_name_text.value}.mp4",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
event.client.add_gui_markdown(
|
|
||||||
"\n".join(
|
|
||||||
[
|
|
||||||
"Rendering trajectory and saving file as",
|
|
||||||
"",
|
|
||||||
"```",
|
|
||||||
f"renders/{dataname}/{render_name_text.value}.mp4",
|
|
||||||
"```",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
run_command(command, verbose=False)
|
|
||||||
close_button = event.client.add_gui_button("Close")
|
|
||||||
|
|
||||||
@close_button.on_click
|
# rendering
|
||||||
def _(_) -> None:
|
from nerfstudio.scripts.render import RenderCameraPath
|
||||||
modal.close()
|
render = RenderCameraPath(
|
||||||
|
load_config=config_path,
|
||||||
|
camera_path_filename=json_outfile.absolute(),
|
||||||
|
output_path=Path(render_path)
|
||||||
|
)
|
||||||
|
render.main()
|
||||||
|
|
||||||
|
if render.complete:
|
||||||
|
server.add_notification(
|
||||||
|
title="Render complete!",
|
||||||
|
body="Video saved as " + render_path,
|
||||||
|
withCloseButton=True,
|
||||||
|
loading=False,
|
||||||
|
autoClose=5000,
|
||||||
|
)
|
||||||
|
|
||||||
if control_panel is not None:
|
if control_panel is not None:
|
||||||
camera_path = CameraPath(server, duration_number, control_panel._time_enabled)
|
camera_path = CameraPath(server, duration_number, control_panel._time_enabled)
|
||||||
|
|||||||
Reference in new issue
Block a user