Skip to content

Commit

Permalink
Define undistort as pinhole projection
Browse files Browse the repository at this point in the history
Summary:
Currently on master we have a bug in that we undistort images into a pinhole frame but then optimize in Rosetta using fisheye. Undistorting to pinhole is totally fine but then we should be optimizing in pinhole in Rosetta.

So this is the "other" version of the fix I did in D58979100. In D58979100 I "fixed" the cameras by defining the undistort method to be fisheye rather than pinhole. In this diff I did the other way round - I've left the CameraOperator alone and I've fixed the distortion model we propagate after undistortion to be pinhole.

Reviewed By: AlexRadionovMeta

Differential Revision: D60927099

fbshipit-source-id: 316aa0d99396c49d61c31d743112f1aa0eef85cb
  • Loading branch information
Patrick Snape authored and facebook-github-bot committed Aug 17, 2024
1 parent b91ae53 commit 24822ed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drtk/utils/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

DISTORTION_MODES: Set[Optional[str]] = {
None,
"pinhole",
"radial-tangential",
"fisheye",
}
Expand Down Expand Up @@ -359,7 +360,7 @@ def project_points(
elif len(modes) == 1:
distortion_mode = modes[0]

if distortion_mode is None:
if distortion_mode is None or distortion_mode == "pinhole":
v_pix = project_pinhole(v_cam, focal, princpt)
elif isinstance(distortion_mode, str):
assert distortion_coeff is not None
Expand Down Expand Up @@ -391,9 +392,10 @@ def project_points(
f"Invalid distortion mode: {distortion_mode}. Valid options: {DISTORTION_MODES}."
)
v_pix = th.empty_like(v_cam[..., :2])
if None in modes:
if None in modes or "pinhole" in modes:
idx = th.tensor(
[mode is None for mode in distortion_mode], device=v_pix.device
[mode is None or mode == "pinhole" for mode in distortion_mode],
device=v_pix.device,
)
v_pix[idx] = project_pinhole(v_cam[idx], focal[idx], princpt[idx])
if "radial-tangential" in modes:
Expand Down

0 comments on commit 24822ed

Please sign in to comment.