MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / process_pose_params

Function process_pose_params

wan/data/utils.py:318–347  ·  view source on GitHub ↗

Modified from https://github.com/hehao13/CameraCtrl/blob/main/inference.py

(cam_params, width=672, height=384, original_pose_width=1280, original_pose_height=720, device='cpu')

Source from the content-addressed store, hash-verified

316 return plucker_embedding
317
318def process_pose_params(cam_params, width=672, height=384, original_pose_width=1280, original_pose_height=720, device='cpu'):
319 """Modified from https://github.com/hehao13/CameraCtrl/blob/main/inference.py
320 """
321 cam_params = [Camera(cam_param) for cam_param in cam_params]
322
323 sample_wh_ratio = width / height
324 pose_wh_ratio = original_pose_width / original_pose_height # Assuming placeholder ratios, change as needed
325
326 if pose_wh_ratio > sample_wh_ratio:
327 resized_ori_w = height * pose_wh_ratio
328 for cam_param in cam_params:
329 cam_param.fx = resized_ori_w * cam_param.fx / width
330 else:
331 resized_ori_h = width / pose_wh_ratio
332 for cam_param in cam_params:
333 cam_param.fy = resized_ori_h * cam_param.fy / height
334
335 intrinsic = np.asarray([[cam_param.fx * width,
336 cam_param.fy * height,
337 cam_param.cx * width,
338 cam_param.cy * height]
339 for cam_param in cam_params], dtype=np.float32)
340
341 K = torch.as_tensor(intrinsic)[None] # [1, 1, 4]
342 c2ws = get_relative_pose(cam_params) # Assuming this function is defined elsewhere
343 c2ws = torch.as_tensor(c2ws)[None] # [1, n_frame, 4, 4]
344 plucker_embedding = ray_condition(K, c2ws, height, width, device=device)[0].permute(0, 3, 1, 2).contiguous() # V, 6, H, W
345 plucker_embedding = plucker_embedding[None]
346 plucker_embedding = rearrange(plucker_embedding, "b f c h w -> b f h w c")[0]
347 return plucker_embedding

Callers

nothing calls this directly

Calls 3

CameraClass · 0.85
get_relative_poseFunction · 0.85
ray_conditionFunction · 0.85

Tested by

no test coverage detected