From b31f9aa59f587551aac0f70ffc925a75d474a418 Mon Sep 17 00:00:00 2001
From: Manuel <mra59@bath.ac.uk>
Date: Tue, 30 Aug 2022 09:38:21 +0100
Subject: [PATCH] Start support for boosting monodepth

---
 .gitmodules                               | 3 +++
 BoostingMonocularDepth                    | 1 +
 code/python/src/main.py                   | 4 ++--
 code/python/src/utility/depthmap_utils.py | 7 +++++++
 4 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 .gitmodules
 create mode 160000 BoostingMonocularDepth

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..127d780
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "BoostingMonocularDepth"]
+	path = BoostingMonocularDepth
+	url = https://github.com/compphoto/BoostingMonocularDepth
diff --git a/BoostingMonocularDepth b/BoostingMonocularDepth
new file mode 160000
index 0000000..ecedd0c
--- /dev/null
+++ b/BoostingMonocularDepth
@@ -0,0 +1 @@
+Subproject commit ecedd0c0cf5e1807cdab1c5154351a97168e710d
diff --git a/code/python/src/main.py b/code/python/src/main.py
index 928bc5d..a59c1f4 100644
--- a/code/python/src/main.py
+++ b/code/python/src/main.py
@@ -97,7 +97,7 @@ class Options():
         parser.add_argument("--padding", type=float, default="0.3")
         parser.add_argument("--multires_levels", type=int, default=1, help="Levels of multi-resolution pyramid. If > 1"
                                                                            "then --grid_size is the lowest resolution")
-        parser.add_argument("--persp_monodepth", type=str, default="midas2", choices=["midas2", "midas3"])
+        parser.add_argument("--persp_monodepth", type=str, default="boost", choices=["midas2", "midas3", "boost"])
         parser.add_argument('--depthalignstep', type=int, nargs='+', default=[1, 2, 3, 4])
         parser.add_argument("--rm_debug_folder", default=True, action='store_false')
         parser.add_argument("--intermediate_data", default=False, action='store_true', help="save intermediate data"
@@ -207,7 +207,7 @@ def depthmap_estimation(erp_rgb_image_data, fnc, opt, blendIt, idx=1):
         tic = time.perf_counter()
         subimage_depthmap_persp_list = []
         # estimate disparity map
-        subimage_dispmap_persp_list = depthmap_utils.MiDaS_torch_hub_data(subimage_rgb_list, opt.persp_monodepth)
+        subimage_dispmap_persp_list = depthmap_utils.run_persp_monodepth(subimage_rgb_list, opt.persp_monodepth)
         # convert disparity map to depth map
         for dispmap_persp in subimage_dispmap_persp_list:
             subimage_depthmap_persp_list.append(depthmap_utils.disparity2depth(dispmap_persp))
diff --git a/code/python/src/utility/depthmap_utils.py b/code/python/src/utility/depthmap_utils.py
index e5402fb..90fa719 100644
--- a/code/python/src/utility/depthmap_utils.py
+++ b/code/python/src/utility/depthmap_utils.py
@@ -166,6 +166,13 @@ def rgb2dispmap(image_filepath, pytorch_hub=True):
     return depthmap_data
 
 
+def run_persp_monodepth(rgb_image_data_list, persp_monodepth, use_large_model=True):
+    if (persp_monodepth == "midas2") or (persp_monodepth == "midas3"):
+        MiDaS_torch_hub_data(rgb_image_data_list, persp_monodepth, use_large_model=use_large_model)
+    if persp_monodepth == "boost":
+        boosting_monodepth(rgb_image_data_list)
+
+
 def MiDaS_torch_hub_data(rgb_image_data_list, persp_monodepth, use_large_model=True):
     """Estimation the single RGB image's depth with MiDaS downloading from Torch Hub.
     reference: https://pytorch.org/hub/intelisl_midas_v2/
-- 
GitLab