Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

add depth warper example

edgarriba0d8391b5af4a
diff --git a/test/test_depth_warper.py b/test/test_depth_warper.py
index d7a0fa160..8dd436382 100644
--- a/test/test_depth_warper.py
+++ b/test/test_depth_warper.py
@@ -47,8 +47,6 @@ class Tester(unittest.TestCase):
patch_src[..., :-int(offset), :-int(offset)], \
patch_dst[..., int(offset):, int(offset):])
self.assertTrue(res)
-
- pass
if __name__ == '__main__':
diff --git a/torchgeometry/depth_warper.py b/torchgeometry/depth_warper.py
index 5d87bc354..635a41937 100644
--- a/torchgeometry/depth_warper.py
+++ b/torchgeometry/depth_warper.py
@@ -17,13 +17,16 @@ class DepthWarper(nn.Module):
self._i_Hs_ref = None # to be filled later
self._pinhole_ref = None # to be filled later
- def compute_homographies(self, pinhole, scale):
+ def compute_homographies(self, pinhole, scale=None):
+ if scale is None:
+ batch_size = pinhole.shape[0]
+ scale = torch.ones(batch_size, 1).to(pinhole.device).type_as(pinhole)
# TODO: add type and value checkings
pinhole_ref = scale_pinhole(pinhole, scale)
if self.width is None:
- self.width = pinhole_ref[..., 4]
+ self.width = pinhole_ref[..., 5]
if self.height is None:
- self.height = pinhole_ref[..., 5]
+ self.height = pinhole_ref[..., 4]
self._pinhole_ref = pinhole_ref
# scale pinholes_i and compute homographies
pinhole_i = scale_pinhole(self._pinholes, scale)
@@ -59,7 +62,7 @@ accurate sampling of the depth cost volume, per camera.
# TODO: add type and value checkings
assert self._i_Hs_ref is not None, 'call compute_homographies'
if roi == None:
- roi = (0, self.height, 0, self.width)
+ roi = (0, int(self.height), 0, int(self.width))
start_row, end_row, start_col, end_col = roi
assert start_row < end_row
assert start_col < end_col
@@ -67,6 +70,7 @@ accurate sampling of the depth cost volume, per camera.
area = width * height
# take sub region
+ #import ipdb;ipdb.set_trace()
inv_depth_ref = inv_depth_ref[..., start_row:end_row, \
start_col:end_col].contiguous()