File size: 6,707 Bytes
1fe7075
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from config.loader import config_bool, config_value

SURFACE_RANSAC_DISTANCE = float(config_value(
    "SURFACE_RANSAC_DISTANCE", "surface_mapping", "ransac_distance_threshold", "0.04",
))

SURFACE_MAX_PLANES = int(config_value(
    "SURFACE_MAX_PLANES", "surface_mapping", "max_planes", "5",
))

SURFACE_NORMAL_ANGLE_DEGREES = float(config_value(
    "SURFACE_NORMAL_ANGLE_DEGREES", "surface_mapping", "normal_angle_threshold_degrees", "35",
))

SURFACE_NORMAL_SMOOTHING_KERNEL = int(config_value(
    "SURFACE_NORMAL_SMOOTHING_KERNEL", "surface_mapping", "normal_smoothing_kernel", "5",
))

SURFACE_MIN_PLANE_PIXELS = int(config_value(
    "SURFACE_MIN_PLANE_PIXELS", "surface_mapping", "min_plane_pixels", "1500",
))

SURFACE_EDGE_CLOSE_RATIO = float(config_value(
    "SURFACE_EDGE_CLOSE_RATIO", "surface_mapping", "edge_close_ratio", "0.009",
))

SURFACE_EDGE_KERNEL_RATIO = float(config_value(
    "SURFACE_EDGE_KERNEL_RATIO", "surface_mapping", "edge_kernel_ratio", "0.006",
))

# Growing the floor past the segmentation and cutting it back with other class
# masks leaves spikes; edge refinement (below) reaches the real edge instead.
SURFACE_EDGE_DILATION_ITERATIONS = int(config_value(
    "SURFACE_EDGE_DILATION_ITERATIONS", "surface_mapping", "edge_dilation_iterations", "0",
))

# Floor edge refinement (services/floor/edge_refinement.py): a guided filter
# snaps the low-resolution segmentation edge to the photo's own edges, and the
# floor's edge along walls and doors is redrawn as straight lines.
ENABLE_SURFACE_EDGE_REFINEMENT = config_bool(
    "ENABLE_SURFACE_EDGE_REFINEMENT", "surface_mapping", "edge_refinement_enabled", "1",
)

# Guided filter window radius as a fraction of the short image side (~36px at 1200):
# the segmentation edge can be 10-20px off, and the filter corrects about half its radius.
SURFACE_EDGE_REFINE_RADIUS_RATIO = float(config_value(
    "SURFACE_EDGE_REFINE_RADIUS_RATIO", "surface_mapping", "edge_refine_radius_ratio", "0.03",
))

# Guided filter regularisation: higher ignores weaker photo edges (floor grain).
SURFACE_EDGE_REFINE_EPS = float(config_value(
    "SURFACE_EDGE_REFINE_EPS", "surface_mapping", "edge_refine_eps", "0.002",
))

# Wobble within this tolerance (fraction of the short side) along a wall or
# door becomes one straight line. 0 disables straightening.
SURFACE_EDGE_STRAIGHTEN_RATIO = max(0.0, float(config_value(
    "SURFACE_EDGE_STRAIGHTEN_RATIO", "surface_mapping", "edge_straighten_ratio", "0.006",
)))

# Only edge runs along a wall at least this long (fraction of the short side) are straightened.
SURFACE_EDGE_STRAIGHTEN_MIN_RUN_RATIO = float(config_value(
    "SURFACE_EDGE_STRAIGHTEN_MIN_RUN_RATIO", "surface_mapping", "edge_straighten_min_run_ratio", "0.04",
))

ENABLE_SOFT_FLOOR_COVERING_EXPANSION = config_bool(
    "ENABLE_SOFT_FLOOR_COVERING_EXPANSION", "surface_mapping",
    "soft_floor_covering_expansion_enabled", "1",
)

SOFT_FLOOR_COVERING_KERNEL_RATIO = float(config_value(
    "SOFT_FLOOR_COVERING_KERNEL_RATIO", "surface_mapping",
    "soft_floor_covering_kernel_ratio", "0.008",
))

SOFT_FLOOR_COVERING_DILATION_ITERATIONS = int(config_value(
    "SOFT_FLOOR_COVERING_DILATION_ITERATIONS", "surface_mapping",
    "soft_floor_covering_dilation_iterations", "2",
))

SURFACE_UV_MIN_COVERAGE = float(config_value(
    "SURFACE_UV_MIN_COVERAGE", "surface_mapping", "uv_min_coverage", "0.995",
))

# Within this distance of the floor's edge (fraction of the short image side,
# ~36px at 1200, the edge refinement's reach) UVs blend from the measured depth
# to the fitted floor plane: edge pixels often carry a wall's or a furniture
# foot's 3D point, which smears the tile. 0 disables.
SURFACE_UV_EDGE_BAND_RATIO = max(0.0, float(config_value(
    "SURFACE_UV_EDGE_BAND_RATIO", "surface_mapping", "uv_edge_band_ratio", "0.03",
)))

SURFACE_UV_MAX_BAD_NEIGHBOR_RATIO = float(config_value(
    "SURFACE_UV_MAX_BAD_NEIGHBOR_RATIO", "surface_mapping", "uv_max_bad_neighbor_ratio", "0.035",
))

SURFACE_UV_MAX_JUMP_RATIO = float(config_value(
    "SURFACE_UV_MAX_JUMP_RATIO", "surface_mapping", "uv_max_jump_ratio", "8.0",
))

SURFACE_UV_ABSOLUTE_JUMP_METERS = float(config_value(
    "SURFACE_UV_ABSOLUTE_JUMP_METERS", "surface_mapping", "uv_absolute_jump_meters", "0.35",
))

ENABLE_GEOMETRY_SURFACE_FILTER = config_bool(
    "ENABLE_GEOMETRY_SURFACE_FILTER", "surface_mapping", "enable_geometry_surface_filter", "1",
)

SURFACE_PLANE_DISTANCE_METERS = float(config_value(
    "SURFACE_PLANE_DISTANCE_METERS", "surface_mapping", "plane_distance_threshold_meters", "0.12",
))

SURFACE_PLANE_NORMAL_MIN_COS = float(config_value(
    "SURFACE_PLANE_NORMAL_MIN_COS", "surface_mapping", "plane_normal_min_cos", "0.45",
))

SURFACE_PLANE_FILTER_MIN_KEEP_RATIO = float(config_value(
    "SURFACE_PLANE_FILTER_MIN_KEEP_RATIO", "surface_mapping", "plane_filter_min_keep_ratio", "0.45",
))

# --- Walls -----------------------------------------------------------------
# Walls use their own plane budget so the floor keeps `max_planes` (1 on GPU)
# no matter how many walls a room has.
WALL_MAX_PLANES = max(1, int(config_value(
    "WALL_MAX_PLANES", "surface_mapping", "wall_max_planes", "4",
)))

WALL_MAX_SEGMENTS = max(1, int(config_value(
    "WALL_MAX_SEGMENTS", "surface_mapping", "max_walls", "6",
)))

# Long-side resolution wall discovery and plane fitting run at. Only the final
# per-wall masks and UVs are produced at full resolution.
WALL_WORK_MAX_DIMENSION = max(256, int(config_value(
    "WALL_WORK_MAX_DIMENSION", "surface_mapping", "wall_work_max_dimension", "768",
)))

# A plane counts as a wall when |normal.y| (camera up component) is at most this.
WALL_MAX_NORMAL_Y = float(config_value(
    "WALL_MAX_NORMAL_Y", "surface_mapping", "wall_max_normal_y", "0.45",
))

# Planes closer than both limits are merged so one flat wall is never split.
WALL_COPLANAR_ANGLE_DEGREES = float(config_value(
    "WALL_COPLANAR_ANGLE_DEGREES", "surface_mapping", "wall_coplanar_angle_degrees", "10",
))

WALL_COPLANAR_OFFSET_METERS = float(config_value(
    "WALL_COPLANAR_OFFSET_METERS", "surface_mapping", "wall_coplanar_offset_meters", "0.15",
))

# Wall outlines are redrawn with straight edges; zig-zag within this tolerance
# (fraction of the short image side, ~6px at 1440) becomes one line. 0 disables.
WALL_EDGE_STRAIGHTEN_RATIO = max(0.0, float(config_value(
    "WALL_EDGE_STRAIGHTEN_RATIO", "surface_mapping", "wall_edge_straighten_ratio", "0.004",
)))

# Minimum share of a wall's pixels that must get a ray/plane UV; below this the
# wall falls back to its contour homography.
WALL_UV_MIN_COVERAGE = float(config_value(
    "WALL_UV_MIN_COVERAGE", "surface_mapping", "wall_uv_min_coverage", "0.9",
))