Spaces:
Paused
Paused
Codex staging deploy commited on
Commit ·
0b146dd
1
Parent(s): 2688d45
Preview feature/realistic-floor-rendering at 6b2e9fd
Browse files
app.py
CHANGED
|
@@ -2854,10 +2854,6 @@ def analyze_surface_uv_quality(
|
|
| 2854 |
if coverage < SURFACE_UV_MIN_COVERAGE:
|
| 2855 |
quality["textureMappingReason"] = "incomplete-surface-uv"
|
| 2856 |
return quality
|
| 2857 |
-
if len(active_plane_ids) != 1:
|
| 2858 |
-
quality["textureMappingReason"] = "multiple-surface-planes"
|
| 2859 |
-
return quality
|
| 2860 |
-
|
| 2861 |
h, w = surface_mask.shape[:2]
|
| 2862 |
uv_grid = np.full((h * w, 2), np.nan, dtype=np.float32)
|
| 2863 |
plane_grid = np.full(h * w, 255, dtype=np.uint8)
|
|
@@ -2908,13 +2904,13 @@ def analyze_surface_uv_quality(
|
|
| 2908 |
if bad_ratio > SURFACE_UV_MAX_BAD_NEIGHBOR_RATIO:
|
| 2909 |
quality["textureMappingReason"] = "noisy-surface-uv"
|
| 2910 |
return quality
|
| 2911 |
-
|
| 2912 |
-
|
| 2913 |
-
|
| 2914 |
-
|
| 2915 |
-
|
| 2916 |
-
|
| 2917 |
-
|
| 2918 |
return quality
|
| 2919 |
|
| 2920 |
|
|
@@ -3021,9 +3017,17 @@ def build_surface_uv_mapping(
|
|
| 3021 |
plane_ids[assigned_positions] = plane_idx
|
| 3022 |
plane["assignedCount"] = int(assigned_keep.sum())
|
| 3023 |
|
| 3024 |
-
serializable_planes = []
|
| 3025 |
-
for plane in planes:
|
| 3026 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3027 |
"id": int(plane["id"]),
|
| 3028 |
"normal": plane["normal"].astype(float).tolist(),
|
| 3029 |
"origin": plane["origin"].astype(float).tolist(),
|
|
@@ -3033,8 +3037,12 @@ def build_surface_uv_mapping(
|
|
| 3033 |
"inlierCount": int(plane["inlierCount"]),
|
| 3034 |
"assignedCount": int(plane.get("assignedCount", 0)),
|
| 3035 |
"isFloor": bool(plane["isFloor"]),
|
| 3036 |
-
"fitMode": str(plane.get("fitMode", "normal-aware")),
|
| 3037 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3038 |
|
| 3039 |
finite_uv = np.isfinite(uv_by_mask).all(axis=1)
|
| 3040 |
uv_quality = analyze_surface_uv_quality(surface_mask, surface_indices, uv_by_mask, plane_ids)
|
|
|
|
| 2854 |
if coverage < SURFACE_UV_MIN_COVERAGE:
|
| 2855 |
quality["textureMappingReason"] = "incomplete-surface-uv"
|
| 2856 |
return quality
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2857 |
h, w = surface_mask.shape[:2]
|
| 2858 |
uv_grid = np.full((h * w, 2), np.nan, dtype=np.float32)
|
| 2859 |
plane_grid = np.full(h * w, 255, dtype=np.uint8)
|
|
|
|
| 2904 |
if bad_ratio > SURFACE_UV_MAX_BAD_NEIGHBOR_RATIO:
|
| 2905 |
quality["textureMappingReason"] = "noisy-surface-uv"
|
| 2906 |
return quality
|
| 2907 |
+
quality["surfaceUvEnabled"] = True
|
| 2908 |
+
quality["textureMappingMode"] = "surface-uv"
|
| 2909 |
+
quality["textureMappingReason"] = (
|
| 2910 |
+
"surface-uv-quality-ok"
|
| 2911 |
+
if len(active_plane_ids) <= 1
|
| 2912 |
+
else "multi-plane-surface-uv-quality-ok"
|
| 2913 |
+
)
|
| 2914 |
return quality
|
| 2915 |
|
| 2916 |
|
|
|
|
| 3017 |
plane_ids[assigned_positions] = plane_idx
|
| 3018 |
plane["assignedCount"] = int(assigned_keep.sum())
|
| 3019 |
|
| 3020 |
+
serializable_planes = []
|
| 3021 |
+
for plane in planes:
|
| 3022 |
+
assigned_plane_uv = uv_by_mask[plane_ids == int(plane["id"])]
|
| 3023 |
+
assigned_plane_uv = assigned_plane_uv[np.isfinite(assigned_plane_uv).all(axis=1)]
|
| 3024 |
+
if len(assigned_plane_uv):
|
| 3025 |
+
uv_min = np.min(assigned_plane_uv, axis=0)
|
| 3026 |
+
uv_max = np.max(assigned_plane_uv, axis=0)
|
| 3027 |
+
else:
|
| 3028 |
+
uv_min = np.zeros(2, dtype=np.float32)
|
| 3029 |
+
uv_max = np.ones(2, dtype=np.float32)
|
| 3030 |
+
serializable_planes.append({
|
| 3031 |
"id": int(plane["id"]),
|
| 3032 |
"normal": plane["normal"].astype(float).tolist(),
|
| 3033 |
"origin": plane["origin"].astype(float).tolist(),
|
|
|
|
| 3037 |
"inlierCount": int(plane["inlierCount"]),
|
| 3038 |
"assignedCount": int(plane.get("assignedCount", 0)),
|
| 3039 |
"isFloor": bool(plane["isFloor"]),
|
| 3040 |
+
"fitMode": str(plane.get("fitMode", "normal-aware")),
|
| 3041 |
+
"uvMin": uv_min.astype(float).tolist(),
|
| 3042 |
+
"uvMax": uv_max.astype(float).tolist(),
|
| 3043 |
+
"uvWidth": float(max(uv_max[0] - uv_min[0], 0.05)),
|
| 3044 |
+
"uvHeight": float(max(uv_max[1] - uv_min[1], 0.05)),
|
| 3045 |
+
})
|
| 3046 |
|
| 3047 |
finite_uv = np.isfinite(uv_by_mask).all(axis=1)
|
| 3048 |
uv_quality = analyze_surface_uv_quality(surface_mask, surface_indices, uv_by_mask, plane_ids)
|