Skip to content

Commit

Permalink
Add separate mean and max rot/trans metrics to camera-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
oseiskar committed Feb 9, 2024
1 parent 8594da9 commit 3b02a7f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nerfstudio/cameras/camera_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import annotations

import functools
import math
from dataclasses import dataclass, field
from typing import Literal, Optional, Type, Union

Expand Down Expand Up @@ -176,8 +177,11 @@ def get_correction_matrices(self):
def get_metrics_dict(self, metrics_dict: dict) -> None:
"""Get camera optimizer metrics"""
if self.config.mode != "off":
metrics_dict["camera_opt_translation"] = self.pose_adjustment[:, :3].norm()
metrics_dict["camera_opt_rotation"] = self.pose_adjustment[:, 3:].norm()
rad2deg = lambda x: x / math.pi * 180.0
metrics_dict["camera_opt_translation_max"] = self.pose_adjustment[:, :3].norm(dim=-1).max()
metrics_dict["camera_opt_translation_mean"] = self.pose_adjustment[:, :3].norm(dim=-1).mean()
metrics_dict["camera_opt_rotation_mean"] = rad2deg(self.pose_adjustment[:, 3:].norm(dim=-1).mean())
metrics_dict["camera_opt_rotation_max"] = rad2deg(self.pose_adjustment[:, 3:].norm(dim=-1).max())

def get_param_groups(self, param_groups: dict) -> None:
"""Get camera optimizer parameters"""
Expand Down

0 comments on commit 3b02a7f

Please sign in to comment.