MCPcopy
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / output_3d_photo

Function output_3d_photo

inpaint/mesh.py:2413–2548  ·  view source on GitHub ↗
(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses, video_traj_types, ref_pose,
                    output_dir, ref_image, int_mtx, config, image, videos_poses, video_basename, original_H=None, original_W=None,
                    border=None, depth=None, normal_canvas=None, all_canvas=None, mean_loc_depth=None, dolly=False, fnExt="mp4")

Source from the content-addressed store, hash-verified

2411
2412
2413def output_3d_photo(verts, colors, faces, Height, Width, hFov, vFov, tgt_poses, video_traj_types, ref_pose,
2414 output_dir, ref_image, int_mtx, config, image, videos_poses, video_basename, original_H=None, original_W=None,
2415 border=None, depth=None, normal_canvas=None, all_canvas=None, mean_loc_depth=None, dolly=False, fnExt="mp4"):
2416
2417 cam_mesh = netx.Graph()
2418 cam_mesh.graph['H'] = Height
2419 cam_mesh.graph['W'] = Width
2420 cam_mesh.graph['original_H'] = original_H
2421 cam_mesh.graph['original_W'] = original_W
2422 int_mtx_real_x = int_mtx[0] * Width
2423 int_mtx_real_y = int_mtx[1] * Height
2424 cam_mesh.graph['hFov'] = 2 * np.arctan((1. / 2.) * ((cam_mesh.graph['original_W']) / int_mtx_real_x[0]))
2425 cam_mesh.graph['vFov'] = 2 * np.arctan((1. / 2.) * ((cam_mesh.graph['original_H']) / int_mtx_real_y[1]))
2426 colors = colors[..., :3]
2427
2428 fov_in_rad = max(cam_mesh.graph['vFov'], cam_mesh.graph['hFov'])
2429 fov = (fov_in_rad * 180 / np.pi)
2430 print("fov: " + str(fov))
2431 init_factor = 1
2432 #if config.get('anti_flickering') is True:
2433 # init_factor = 3
2434 #bty: basically Supersample Anti-Aliasing (SSAA)
2435 init_factor = config['ssaa']
2436 if (cam_mesh.graph['original_H'] is not None) and (cam_mesh.graph['original_W'] is not None):
2437 canvas_w = cam_mesh.graph['original_W']
2438 canvas_h = cam_mesh.graph['original_H']
2439 else:
2440 canvas_w = cam_mesh.graph['W']
2441 canvas_h = cam_mesh.graph['H']
2442 canvas_size = max(canvas_h, canvas_w)
2443 if normal_canvas is None:
2444 normal_canvas = Canvas_view(fov,
2445 verts,
2446 faces,
2447 colors,
2448 canvas_size=canvas_size,
2449 factor=init_factor,
2450 bgcolor='gray',
2451 proj='perspective')
2452 else:
2453 normal_canvas.reinit_mesh(verts, faces, colors)
2454 normal_canvas.reinit_camera(fov)
2455 img = normal_canvas.render()
2456 #backup_img, backup_all_img, all_img_wo_bound = img.copy(), img.copy() * 0, img.copy() * 0
2457 img = cv2.resize(img, (int(img.shape[1] / init_factor), int(img.shape[0] / init_factor)), interpolation=cv2.INTER_AREA)
2458 if border is None:
2459 border = [0, img.shape[0], 0, img.shape[1]]
2460 H, W = cam_mesh.graph['H'], cam_mesh.graph['W']
2461 if (cam_mesh.graph['original_H'] is not None) and (cam_mesh.graph['original_W'] is not None):
2462 aspect_ratio = cam_mesh.graph['original_H'] / cam_mesh.graph['original_W']
2463 else:
2464 aspect_ratio = cam_mesh.graph['H'] / cam_mesh.graph['W']
2465 if aspect_ratio > 1:
2466 img_h_len = cam_mesh.graph['H'] if cam_mesh.graph.get('original_H') is None else cam_mesh.graph['original_H']
2467 img_w_len = img_h_len / aspect_ratio
2468 anchor = [0,
2469 img.shape[0],
2470 int(max(0, int((img.shape[1])//2 - img_w_len//2))),

Callers 2

run_3dphoto_videosFunction · 0.90
main.pyFile · 0.90

Calls 9

reinit_meshMethod · 0.95
reinit_cameraMethod · 0.95
renderMethod · 0.95
rotateMethod · 0.95
translateMethod · 0.95
view_changedMethod · 0.95
Canvas_viewClass · 0.85
getMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected