mirror of
https://github.com/gosticks/body-pose-animation.git
synced 2025-10-16 11:45:42 +00:00
visualize toggle
This commit is contained in:
parent
5f070e202f
commit
b52d907336
@ -114,7 +114,7 @@ class CameraEstimate:
|
||||
|
||||
|
||||
class TorchCameraEstimate(CameraEstimate):
|
||||
def estimate_camera_pos(self):
|
||||
def estimate_camera_pos(self, visualize=True):
|
||||
self.memory = None
|
||||
translation = torch.zeros(
|
||||
1, 3, requires_grad=True, dtype=self.dtype, device=self.device)
|
||||
@ -125,7 +125,8 @@ class TorchCameraEstimate(CameraEstimate):
|
||||
|
||||
init_points_2d, init_points_3d = self.get_torso_keypoints()
|
||||
|
||||
#self.visualize_mesh(init_points_2d, init_points_3d)
|
||||
if visualize:
|
||||
self.visualize_mesh(init_points_2d, init_points_3d)
|
||||
|
||||
init_points_2d = torch.from_numpy(init_points_2d).to(
|
||||
device=self.device, dtype=self.dtype)
|
||||
@ -223,8 +224,9 @@ class TorchCameraEstimate(CameraEstimate):
|
||||
else:
|
||||
loss.backward()
|
||||
opt2.step()
|
||||
#self.renderer.scene.set_pose(
|
||||
#self.camera_renderer, self.torch_params_to_pose(params).detach().numpy())
|
||||
if visualize:
|
||||
self.renderer.scene.set_pose(
|
||||
self.camera_renderer, self.torch_params_to_pose(params).detach().numpy())
|
||||
per = int((cam_tol/loss*100).item())
|
||||
|
||||
if per > 100:
|
||||
|
||||
@ -12,7 +12,7 @@ from utils.general import rename_files, get_new_filename
|
||||
|
||||
START_IDX = 150 # starting index of the frame to optimize for
|
||||
FINISH_IDX = 200 # choose a big number to optimize for all frames in samples directory
|
||||
RUN_OPTIMIZATION = True
|
||||
RUN_OPTIMIZATION = False # if False, only run already saved animation without optimization
|
||||
|
||||
final_poses = [] # optimized poses array that is saved for playing the animation
|
||||
idx = START_IDX
|
||||
@ -73,7 +73,7 @@ if RUN_OPTIMIZATION:
|
||||
est_scale=est_scale
|
||||
)
|
||||
|
||||
pose, transform, cam_trans = camera.estimate_camera_pos()
|
||||
pose, transform, cam_trans = camera.estimate_camera_pos(visualize=False)
|
||||
print("\nCamera optimization of frame", idx, "is finished.")
|
||||
|
||||
camera_transformation = transform.clone().detach().to(device=device, dtype=dtype)
|
||||
@ -114,7 +114,7 @@ if RUN_OPTIMIZATION:
|
||||
pickle.dump(final_poses, fp)
|
||||
print("Results have been saved to", filename)
|
||||
|
||||
# TODO: put into utils, rename file, use current body pose and camera transform for next optimization
|
||||
# TODO: use current body pose and camera transform for next optimization?
|
||||
def replay_animation(file, start_frame=0, end_frame=None, with_background=False, fps=30):
|
||||
r = Renderer()
|
||||
r.start()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user