Skip to content

Commit

Permalink
updating 360 video script
Browse files Browse the repository at this point in the history
  • Loading branch information
Etai Sella committed May 28, 2024
1 parent e3cff82 commit 589950a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions visualizations/blender_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def good_looking_render(meshPath,
print("NOT SETTING PLASTIC")
if plastic:
RGBA = (130.0/255, 130.0/255, 130.0/255, 1)
#RGBA = (130.0/255, 100.0/255, 100.0/255, 1)
if tint:
RGBA = (100.0/255, 130.0/255, 130.0/255, 1)
meshColor = bt.colorObj(RGBA, 0.5, 1.0, 1.0, 0.0, 2.0)
Expand Down
14 changes: 12 additions & 2 deletions visualizations/make_360_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
parser.add_argument('--guidance', action='store_true', help='render as guidance', required=False)
parser.add_argument('--tint', action='store_true', help='render with tint (for shape editing outputs)', required=False)
parser.add_argument('--load_mesh', action='store_true', help='loads mesh directly instead of latent', required=False)
parser.add_argument('--crop_r', type=int, default=0, help='crop pixels on right', required=False)
parser.add_argument('--crop_l', type=int, default=0, help='crop pixels on left', required=False)
parser.add_argument('--crop_t', type=int, default=0, help='crop pixels on top', required=False)
parser.add_argument('--crop_b', type=int, default=0, help='crop pixels on bottom', required=False)
parser.add_argument('--background_intensity', type=int, default=255, help='background intensity (grayscale color)', required=False)


def alpha_blend_with_mask(foreground, background, mask): # modified func from link
# Convert uint8 to float
Expand Down Expand Up @@ -71,13 +77,17 @@ def infer(args, device):

# Create video from all the frames in the output directory
video_path = os.path.join(args.output_dir, "video.mp4")
out = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc(*'mp4v'), 30, (args.resolution_x, args.resolution_y))
out = cv2.VideoWriter(video_path,
cv2.VideoWriter_fourcc(*'mp4v'),
30,
(args.resolution_x - args.crop_r - args.crop_l, args.resolution_y - args.crop_t - args.crop_b))
for i in range(args.num_frames):
img = cv2.imread(os.path.join(args.output_dir, f"frame_{i:05}.png"), cv2.IMREAD_UNCHANGED)
mask = img[:,:,3]
foreground = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
background = np.ones_like(foreground) * 255
background = np.ones_like(foreground) * args.background_intensity
img = alpha_blend_with_mask(foreground, background, mask)
img = img[args.crop_t:args.resolution_y-args.crop_b, args.crop_l:args.resolution_x-args.crop_r]
out.write(img)
out.release()

Expand Down

0 comments on commit 589950a

Please sign in to comment.