Skip to content

Commit

Permalink
Additional changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShihMengLi committed May 4, 2020
1 parent 55af63a commit fe52122
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion argument.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ y_shift_range: [0.00, 0.00, -0.02, -0.00]
z_shift_range: [-0.05, -0.05, -0.07, -0.07]
traj_types: ['double-straight-line', 'double-straight-line', 'circle', 'circle']
video_postfix: ['dolly-zoom-in', 'zoom-in', 'circle', 'swing']
specific: ''
specific: 'moon'
longer_side_len: 960
src_folder: image
depth_folder: depth
Expand Down
17 changes: 7 additions & 10 deletions mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2188,10 +2188,8 @@ def output_3d_photo(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses,
fov = (fov_in_rad * 180 / np.pi)
print("fov: " + str(fov))
init_factor = 1
factor = 1
if config.get('canvas_resize_factor') is not None:
init_factor = config['canvas_resize_factor']
factor = config['canvas_resize_factor']
if (cam_mesh.graph['original_H'] is not None) and (cam_mesh.graph['original_W'] is not None):
canvas_w = cam_mesh.graph['original_W']
canvas_h = cam_mesh.graph['original_H']
Expand All @@ -2205,7 +2203,7 @@ def output_3d_photo(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses,
faces,
colors,
canvas_size=canvas_size,
factor=factor,
factor=init_factor,
bgcolor='gray',
proj='perspective')
else:
Expand All @@ -2214,7 +2212,6 @@ def output_3d_photo(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses,
img = normal_canvas.render()
backup_img, backup_all_img, all_img_wo_bound = img.copy(), img.copy() * 0, img.copy() * 0
img = cv2.resize(img, (int(img.shape[1] / init_factor), int(img.shape[0] / init_factor)), interpolation=cv2.INTER_AREA)
factor = 1
if border is None:
border = [0, img.shape[0], 0, img.shape[1]]
H, W = cam_mesh.graph['H'], cam_mesh.graph['W']
Expand All @@ -2227,16 +2224,16 @@ def output_3d_photo(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses,
img_w_len = img_h_len / aspect_ratio
anchor = [0,
img.shape[0],
int(max(0, int((img.shape[1]/factor)//2 - img_w_len//2))),
int(min(int((img.shape[1]/factor)//2 + img_w_len//2), (img.shape[1]/factor)-1))]
int(max(0, int((img.shape[1])//2 - img_w_len//2))),
int(min(int((img.shape[1])//2 + img_w_len//2), (img.shape[1])-1))]
elif aspect_ratio <= 1:
img_w_len = cam_mesh.graph['W'] if cam_mesh.graph.get('original_W') is None else cam_mesh.graph['original_W']
img_h_len = img_w_len * aspect_ratio
anchor = [int(max(0, int((img.shape[0]/factor)//2 - img_h_len//2))),
int(min(int((img.shape[0]/factor)//2 + img_h_len//2), (img.shape[0]/factor)-1)),
anchor = [int(max(0, int((img.shape[0])//2 - img_h_len//2))),
int(min(int((img.shape[0])//2 + img_h_len//2), (img.shape[0])-1)),
0,
img.shape[1]]
anchor = np.array(anchor) * factor
anchor = np.array(anchor)
plane_width = np.tan(fov_in_rad/2.) * np.abs(mean_loc_depth)
for video_pose, video_traj_type in zip(videos_poses, video_traj_types):
stereos = []
Expand All @@ -2254,7 +2251,7 @@ def output_3d_photo(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses,
normal_canvas.reinit_camera(fov)
normal_canvas.view_changed()
img = normal_canvas.render()
img = cv2.resize(img, (int(img.shape[1] / init_factor), int(img.shape[0] / init_factor)), interpolation=cv2.INTER_CUBIC)
img = cv2.resize(img, (int(img.shape[1] / init_factor), int(img.shape[0] / init_factor)), interpolation=cv2.INTER_LINEAR)
img = img[anchor[0]:anchor[1], anchor[2]:anchor[3]]
img = img[int(border[0]):int(border[1]), int(border[2]):int(border[3])]

Expand Down
Binary file removed misc/moon_40.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ vispy==0.6.4
moviepy==1.0.2
transforms3d==0.3.1
networkx==2.3
# cynetworkx
cynetworkx
scikit-image
Binary file modified video/moon_circle.mp4
Binary file not shown.
Binary file modified video/moon_dolly-zoom-in.mp4
Binary file not shown.
Binary file modified video/moon_swing.mp4
Binary file not shown.
Binary file modified video/moon_zoom-in.mp4
Binary file not shown.

0 comments on commit fe52122

Please sign in to comment.