Debian Codegraph @

benchmark/reconstruction/evaluation/eth3d.py

raw
1 # Copyright (c), ETH Zurich and UNC Chapel Hill.
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 #
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 #
14 # * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of
15 # its contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
29
30
31 from .utils import Dataset, SceneInfo
32
33
34 class DatasetETH3D(Dataset):
35 @property
36 def position_accuracy_gt(self):
37 return 0.001
38
39 @property
40 def supports_covisibility_filtering(self) -> bool:
41 return True
42
43 def list_scenes(self):
44 scene_infos = []
45 for category_path in (self.data_path / "eth3d").iterdir():
46 if not category_path.is_dir() or (
47 self.categories and category_path.name not in self.categories
48 ):
49 continue
50
51 category = category_path.name
52
53 for scene_path in sorted(category_path.iterdir()):
54 if not scene_path.is_dir():
55 continue
56
57 scene = scene_path.name
58 if self.scenes and scene not in self.scenes:
59 continue
60
61 workspace_path = (
62 self.run_path / self.run_name / "eth3d" / category / scene
63 )
64 image_path = scene_path / "images"
65 sparse_gt_path = list(
66 scene_path.glob("*_calibration_undistorted")
67 )[0]
68
69 colmap_extra_args = []
70 if category == "dslr":
71 colmap_extra_args.extend(["--data_type", "individual"])
72 elif category == "rig":
73 colmap_extra_args.extend(["--data_type", "video"])
74
75 num_images = sum(
76 1
77 for p in image_path.rglob("*")
78 if p.is_file()
79 and p.suffix.lower() in {".jpg", ".jpeg", ".png"}
80 )
81
82 scene_info = SceneInfo(
83 dataset="eth3d",
84 category=category,
85 scene=scene,
86 num_images=num_images,
87 workspace_path=workspace_path,
88 image_path=image_path,
89 sparse_gt_path=sparse_gt_path,
90 has_camera_priors=True,
91 colmap_extra_args=colmap_extra_args,
92 )
93
94 scene_infos.append(scene_info)
95
96 return scene_infos
97
98 def prepare_scene(self, scene_info):
99 # Nothing to prepare for ETH3D.
100 pass