Skip to content

Commit

Permalink
fix images output
Browse files Browse the repository at this point in the history
  • Loading branch information
machenmusik committed Dec 21, 2022
1 parent 186791b commit c6487f9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions scripts/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import struct
import sys
from contextlib import ExitStack
from dataclasses import dataclass, field
from pathlib import Path
from typing import List, Optional
Expand All @@ -17,13 +18,8 @@
import torch
import tyro
from rich.console import Console
from rich.progress import (
BarColumn,
Progress,
TaskProgressColumn,
TextColumn,
TimeRemainingColumn,
)
from rich.progress import (BarColumn, Progress, TaskProgressColumn, TextColumn,
TimeRemainingColumn)
from typing_extensions import Literal, assert_never

from nerfstudio.cameras.camera_paths import get_path_from_json, get_spiral_path
Expand Down Expand Up @@ -62,7 +58,7 @@ def _render_trajectory_video(
render_width: Video width to render.
render_height: Video height to render.
"""
CONSOLE.print("[bold green]Creating trajectory video")
CONSOLE.print("[bold green]Creating trajectory " + output_format)
cameras.rescale_output_resolution(rendered_resolution_scaling_factor)
cameras = cameras.to(pipeline.device)

Expand All @@ -87,9 +83,12 @@ def _render_trajectory_video(
# (unless we reserve enough space to overwrite with our uuid tag,
# but we don't know how big the video file will be, so it's not certain!)

with media.VideoWriter(
path=output_filename, shape=(render_height, render_width), fps=fps
) if output_format == "video" else None as writer:
with ExitStack() as stack:
writer = (
stack.enter_context(media.VideoWriter(path=output_filename, shape=(render_height, render_width), fps=fps))
if output_format == "video"
else None
)
with progress:
for camera_idx in progress.track(range(cameras.size), description=""):
camera_ray_bundle = cameras.generate_rays(camera_indices=camera_idx)
Expand All @@ -115,7 +114,6 @@ def _render_trajectory_video(
if output_format == "video":
if camera_type == CameraType.EQUIRECTANGULAR:
insert_spherical_metadata_into_file(output_filename)
CONSOLE.print(f"[green]Saved video to {output_filename}", justify="center")


def insert_spherical_metadata_into_file(
Expand Down

0 comments on commit c6487f9

Please sign in to comment.