Codex staging deploy commited on
Commit
6311a9e
·
1 Parent(s): 2e640f8

Preview feature/realistic-floor-rendering at 31ec5d8

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -3253,10 +3253,22 @@ def estimate_wall_plane(mask: np.ndarray, geometry: dict | None = None):
3253
  "floorTransform": None,
3254
  "surfaceTransform": None,
3255
  "surfaceType": "wall",
 
 
3256
  "metersPerUnit": None,
3257
  "cameraIntrinsics": None,
3258
  "camera": {"focalLength": float(max(h, w) * 0.95), "horizonY": y1, "confidence": 0.45},
3259
  }
 
 
 
 
 
 
 
 
 
 
3260
  if metric_geometry:
3261
  plane.update(metric_geometry)
3262
  plane["surfaceType"] = "wall"
@@ -3264,6 +3276,25 @@ def estimate_wall_plane(mask: np.ndarray, geometry: dict | None = None):
3264
  return homography, plane
3265
 
3266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3267
  def wall_surface_components(seg_map: np.ndarray, min_area: int):
3268
  """Create clean, independently renderable wall regions.
3269
 
 
3253
  "floorTransform": None,
3254
  "surfaceTransform": None,
3255
  "surfaceType": "wall",
3256
+ "surfaceWidthMeters": max(0.5, 2.4 * (x2 - x1) / max(y2 - y1, 1.0)),
3257
+ "surfaceHeightMeters": 2.4,
3258
  "metersPerUnit": None,
3259
  "cameraIntrinsics": None,
3260
  "camera": {"focalLength": float(max(h, w) * 0.95), "horizonY": y1, "confidence": 0.45},
3261
  }
3262
+ if metric_geometry and not validate_wall_metric_geometry(metric_geometry):
3263
+ print(
3264
+ "[WALL_GEOMETRY] rejected metric wall fit; using contour homography "
3265
+ f"confidence={metric_geometry.get('geometryConfidence')} "
3266
+ f"normal={metric_geometry.get('planeNormal')} "
3267
+ f"size={metric_geometry.get('surfaceWidthMeters')}x{metric_geometry.get('surfaceHeightMeters')}",
3268
+ flush=True,
3269
+ )
3270
+ metric_geometry = None
3271
+
3272
  if metric_geometry:
3273
  plane.update(metric_geometry)
3274
  plane["surfaceType"] = "wall"
 
3276
  return homography, plane
3277
 
3278
 
3279
+ def validate_wall_metric_geometry(geometry: dict) -> bool:
3280
+ confidence = float(geometry.get("geometryConfidence") or 0.0)
3281
+ normal = np.asarray(geometry.get("planeNormal") or [], dtype=np.float32)
3282
+ width = float(geometry.get("surfaceWidthMeters") or 0.0)
3283
+ height = float(geometry.get("surfaceHeightMeters") or 0.0)
3284
+ if confidence < 0.45 or normal.shape != (3,) or not np.isfinite(normal).all():
3285
+ return False
3286
+ # In the indoor coordinate system Y is vertical; a wall normal should be
3287
+ # mostly horizontal, unlike the floor normal.
3288
+ normal /= max(float(np.linalg.norm(normal)), 1e-6)
3289
+ if abs(float(normal[1])) > 0.45:
3290
+ return False
3291
+ if not (0.25 <= width <= 30.0 and 0.25 <= height <= 15.0):
3292
+ return False
3293
+ if width / max(height, 1e-6) > 20.0 or height / max(width, 1e-6) > 20.0:
3294
+ return False
3295
+ return True
3296
+
3297
+
3298
  def wall_surface_components(seg_map: np.ndarray, min_area: int):
3299
  """Create clean, independently renderable wall regions.
3300