mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-12 10:55:57 +08:00
Fix: Masks having wrong dimension after undistortion (causes crash in splatfacto) (#2987)
* Add third dim to masks after undistortion to fix error in multiplying color images with masks. * Revert auto format of imports to fix ruff error --------- Co-authored-by: Nicolas Zunhammer <n.zunhammer@dromni.eu>
This commit is contained in:
1 parent
6e6cedd438
commit
ae6c46cfea
1 file changed
+6
@@ -387,6 +387,8 @@ def _undistort_image(
|
||||
mask = cv2.undistort(mask, K, distortion_params, None, newK) # type: ignore
|
||||
mask = mask[y : y + h, x : x + w]
|
||||
mask = torch.from_numpy(mask).bool()
|
||||
if len(mask.shape) == 2:
|
||||
mask = mask[:, :, None]
|
||||
K = newK
|
||||
|
||||
elif camera.camera_type.item() == CameraType.FISHEYE.value:
|
||||
@@ -406,6 +408,8 @@ def _undistort_image(
|
||||
mask = mask.astype(np.uint8) * 255
|
||||
mask = cv2.fisheye.undistortImage(mask, K, distortion_params, None, newK)
|
||||
mask = torch.from_numpy(mask).bool()
|
||||
if len(mask.shape) == 2:
|
||||
mask = mask[:, :, None]
|
||||
K = newK
|
||||
elif camera.camera_type.item() == CameraType.FISHEYE624.value:
|
||||
fisheye624_params = torch.cat(
|
||||
@@ -498,6 +502,8 @@ def _undistort_image(
|
||||
)
|
||||
/ 255.0
|
||||
).bool()[..., None]
|
||||
if len(mask.shape) == 2:
|
||||
mask = mask[:, :, None]
|
||||
assert mask.shape == (undist_h, undist_w, 1)
|
||||
K = undist_K.numpy()
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user