Removed Depth and Segmentation Code
Browse files- tray_sim.py +0 -25
tray_sim.py
CHANGED
|
@@ -286,31 +286,6 @@ def run_tray_simulation(
|
|
| 286 |
scene_option=scene_option
|
| 287 |
)
|
| 288 |
img = renderer.render()
|
| 289 |
-
|
| 290 |
-
# Depth map processing
|
| 291 |
-
depth = renderer.depth
|
| 292 |
-
# Normalize depth for visualization (e.g., map to 0–255)
|
| 293 |
-
depth_normalized = np.clip((depth - depth.min()) / (depth.max() - depth.min() + 1e-6) * 255, 0, 255).astype(np.uint8)
|
| 294 |
-
imageio.imwrite(f"/tmp/frame_{t}_depth.png", depth_normalized)
|
| 295 |
-
|
| 296 |
-
# Segmentation map processing (e.g., use geom IDs for visualization)
|
| 297 |
-
# Note: he segmentation map’s geom IDs are used here, but you could also use body IDs (segmentation[:, :, 1])
|
| 298 |
-
# or create a color-coded image by mapping IDs to specific colors for better interpretability.
|
| 299 |
-
segmentation = renderer.segmentation
|
| 300 |
-
# Use geom IDs (first channel) and normalize for visualization
|
| 301 |
-
seg_geom = segmentation[:, :, 0] # Geom IDs
|
| 302 |
-
seg_normalized = np.clip((seg_geom - seg_geom.min()) / (seg_geom.max() - seg_geom.min() + 1e-6) * 255, 0, 255).astype(np.uint8)
|
| 303 |
-
imageio.imwrite(f"/tmp/frame_{t}_segmentation.png", seg_normalized)
|
| 304 |
-
|
| 305 |
-
# Create a color-coded segmentation image
|
| 306 |
-
# This creates a visually distinct image where each object (geom) has a unique color.
|
| 307 |
-
unique_geom_ids = np.unique(segmentation[:, :, 0])
|
| 308 |
-
color_map = {gid: np.random.randint(0, 256, size=3) for gid in unique_geom_ids} # Random colors
|
| 309 |
-
seg_colored = np.zeros((segmentation.shape[0], segmentation.shape[1], 3), dtype=np.uint8)
|
| 310 |
-
for gid in unique_geom_ids:
|
| 311 |
-
mask = segmentation[:, :, 0] == gid
|
| 312 |
-
seg_colored[mask] = color_map[gid]
|
| 313 |
-
imageio.imwrite(f"/tmp/frame_{t}_segmentation_colored.png", seg_colored)
|
| 314 |
|
| 315 |
if t in keyframes:
|
| 316 |
#imageio.imwrite(f"/tmp/frame_{t}.png", img)
|
|
|
|
| 286 |
scene_option=scene_option
|
| 287 |
)
|
| 288 |
img = renderer.render()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
if t in keyframes:
|
| 291 |
#imageio.imwrite(f"/tmp/frame_{t}.png", img)
|