Skip to content

Commit

Permalink
propagate the lut in drtk rendering functions
Browse files Browse the repository at this point in the history
Summary:
The purpos of this stack is to enable LUT in rosetta2. To do this:
1. extend project_fisheye_distort_62 to support LUT
2. propagate lut in DRTK rendering functions
3. load the LUT in HMCCalibrationSCIOVRS
4. register LUT as an asset for loading
5. extend the rendering pipeline in rosetta2 with  LUT
6. hook the care cmd string generated in fblearner pipeline with assets defined in 4.

This diff implements 2. I start from the rendering layer defined in drtk and add lut as optional defaults to None.

Reviewed By: patricksnape

Differential Revision: D68207715

fbshipit-source-id: bb9250ec13eaa78bc2615d1845a0b612fbfc12e4
  • Loading branch information
Wenjing Zhang authored and facebook-github-bot committed Jan 22, 2025
1 parent 9163544 commit 9683df2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
13 changes: 12 additions & 1 deletion drtk/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def transform_with_v_cam(
distortion_mode: Optional[Union[List[str], str]] = None,
distortion_coeff: Optional[th.Tensor] = None,
fov: Optional[th.Tensor] = None,
lut_vector_field: Optional[th.Tensor] = None,
lut_spacing: Optional[th.Tensor] = None,
) -> Tuple[th.Tensor, th.Tensor]:
"""
Same as transform, but also returns the camera-space coordinates.
Expand All @@ -100,7 +102,16 @@ def transform_with_v_cam(
assert princpt is not None
# Compute camera-space 3D coordinates and 2D pixel-space projections.
v_pix, v_cam = project_points(
v, campos, camrot, focal, princpt, distortion_mode, distortion_coeff, fov
v=v,
campos=campos,
camrot=camrot,
focal=focal,
princpt=princpt,
distortion_mode=distortion_mode,
distortion_coeff=distortion_coeff,
fov=fov,
lut_vector_field=lut_vector_field,
lut_spacing=lut_spacing,
)

return v_pix, v_cam
12 changes: 10 additions & 2 deletions drtk/utils/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ def project_points(
distortion_mode: Optional[Union[List[str], str]] = None,
distortion_coeff: Optional[th.Tensor] = None,
fov: Optional[th.Tensor] = None,
lut_vector_field: Optional[th.Tensor] = None,
lut_spacing: Optional[th.Tensor] = None,
) -> Tuple[th.Tensor, th.Tensor]:
"""Project 3D world-space vertices to pixel-space, optionally applying a
distortion model with provided coefficients.
Expand Down Expand Up @@ -410,9 +412,15 @@ def project_points(
v_pix = project_fisheye_distort(
v_cam, focal, princpt, distortion_coeff, fov
)
elif distortion_mode == "fisheye62":
elif distortion_mode == "fisheye62" or distortion_mode == "fisheye62_lut":
v_pix = project_fisheye_distort_62(
v_cam, focal, princpt, distortion_coeff, fov
v_cam=v_cam,
focal=focal,
princpt=princpt,
D=distortion_coeff,
fov=fov,
lut_vector_field=lut_vector_field,
lut_spacing=lut_spacing,
)
else:
raise ValueError(
Expand Down

0 comments on commit 9683df2

Please sign in to comment.