How to Export Reconstructed Point Cloud or 3D Mesh from LingBot-Map

LingBot-Map provides both interactive and programmatic GLB export methods via predictions_to_glb and the PointCloudViewer UI to convert reconstructions into portable 3D files.

LingBot-Map generates world-space point clouds and camera poses from image sequences, offering two distinct pathways to export reconstructed point cloud or 3D mesh data. The library outputs standard GLB (GL Binary) files that integrate geometry, colors, and camera trajectories into a single portable format compatible with Blender, three.js, and Microsoft 3D Viewer.

Interactive GLB Export Using the Point Cloud Viewer

The PointCloudViewer class in lingbot_map/vis/point_cloud_viewer.py provides a browser-based interface for visualizing reconstructions and exporting them without writing additional code.

Accessing the Export Panel

After loading a prediction dictionary into the viewer, the Export GLB panel becomes available in the web interface. The UI is constructed in the _setup_gui method (lines 44-100), which renders controls for file naming, geometry mode selection, and visual enhancement parameters.

from lingbot_map.vis.point_cloud_viewer import PointCloudViewer

# pred_dict contains world_points, extrinsic matrices, and image data

viewer = PointCloudViewer(pred_dict=pred_dict)

# Access http://<host>:8080 to open the visualization interface

Clicking the Export GLB button triggers the _export_glb method, which collects the currently visible points, applies configured color boosts, and invokes the export pipeline.

Configuring Export Settings

The interactive panel exposes several parameters to control the output:

  • Export Mode: Choose between raw Points or Spheres for mesh-like visualization
  • Color Adjustments: Saturation, brightness, and opacity sliders for enhancing point visibility
  • Camera Visualization: Toggle frustum thickness and camera scale for debugging poses
  • Trajectory Display: Option to include a tube geometry showing the camera path

The viewer automatically aligns the scene to the first camera frame using apply_scene_alignment before writing the binary GLB file.

Programmatic GLB Export with Python

For batch processing or pipeline integration, lingbot_map/vis/glb_export.py exposes the predictions_to_glb function to generate scenes directly from model outputs.

Basic Export from Predictions

Pass the model's prediction dictionary containing world_points or world_points_from_depth, images, and extrinsic matrices to create a trimesh.Scene object:

import torch
from lingbot_map.vis.glb_export import predictions_to_glb

with torch.no_grad():
    preds = model(imgs)  # Inference output dict

scene = predictions_to_glb(
    predictions=preds,
    conf_thres=40.0,               # Filter to top 60% confident points

    mask_sky=True,                # Remove sky pixels via segmentation

    mask_black_bg=False,
    show_cam=True,                # Include camera frustum meshes

    target_dir="/tmp/export_tmp", # Cache directory for sky mask downloads

    prediction_mode="Predicted Pointmap"
)

scene.export("reconstruction.glb")

The function applies confidence thresholding, optional sky segmentation (requiring an internet download of the ONNX model), and background masking before constructing the geometry.

Custom Post-Processing Before Export

Since predictions_to_glb returns a mutable trimesh.Scene, you can manipulate vertices, colors, or add custom geometries before final export:

from lingbot_map.vis.glb_export import predictions_to_glb
import numpy as np

scene = predictions_to_glb(predictions=my_preds)

# Color correction: shift toward cooler tones

pc = scene.geometry[0]  # Primary point cloud geometry

colors = pc.colors.astype(np.float32) / 255
cool_tint = np.clip(colors * np.array([0.8, 0.9, 1.2]), 0, 1)
pc.colors = (cool_tint * 255).astype(np.uint8)

scene.export("processed_scene.glb")

Implementation Details and Source Code

The export architecture separates visualization logic from core geometry processing. In lingbot_map/vis/glb_export.py, the predictions_to_glb function orchestrates the conversion pipeline, while helper functions handle specific components:

  • integrate_camera_into_scene: Generates frustum meshes from extrinsic matrices
  • _build_trajectory_tube: Creates a continuous path geometry connecting camera positions
  • apply_scene_alignment: Transforms the scene so the first camera aligns with the origin

The PointCloudViewer in lingbot_map/vis/point_cloud_viewer.py wraps these utilities for interactive use, managing the state between UI controls and the underlying trimesh.Scene construction.

Summary

  • LingBot-Map exports reconstructions as standard GLB files containing point clouds, camera frustums, and trajectory data.
  • Interactive export uses the PointCloudViewer browser interface with real-time parameter adjustment via the Export GLB panel.
  • Programmatic export calls predictions_to_glb directly from lingbot_map/vis/glb_export.py for batch processing and custom pipelines.
  • The export supports confidence filtering, sky masking, and color enhancement before geometry generation.
  • Output files are compatible with standard 3D software including Blender and web-based three.js viewers.

Frequently Asked Questions

What file format does LingBot-Map use for 3D export?

LingBot-Map exports to GLB (GL Binary), a standardized format based on glTF 2.0 that packages 3D geometry, materials, and scene hierarchy into a single binary file. This format opens natively in Blender, Microsoft 3D Viewer, and web browsers without requiring additional plugins.

Can I export without using the interactive viewer?

Yes. Import predictions_to_glb from lingbot_map/vis/glb_export.py and call it with your model's prediction dictionary. This programmatic approach bypasses the UI entirely, returning a trimesh.Scene that you can export via scene.export() or further manipulate in Python scripts.

How do I filter points by confidence before exporting?

Pass the conf_thres parameter to predictions_to_glb. Values range from 0 to 100, representing percentile thresholds. For example, conf_thres=40.0 retains only points with confidence scores above the 40th percentile, effectively filtering the lowest 40% of confidence values from the output.

Does the export include camera trajectory information?

Yes. When show_cam=True (programmatic) or the equivalent UI toggle is enabled, the export includes both individual camera frustum meshes and an optional trajectory tube connecting camera positions over time. The _build_trajectory_tube helper generates this path geometry from the extrinsic matrices stored in the prediction dictionary.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →