Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# These preregistered protocols are bound by exact raw-byte SHA-256 receipts.
# Windows checkout must preserve their committed LF bytes rather than use CRLF.
benchmarks/*.json text eol=lf
# README visual provenance hashes bind the generator's exact source bytes.
scripts/render_readme_heroes.py text eol=lf
scripts/readme_tracking_data.mjs text eol=lf
docs/assets/readme_heroes.json text eol=lf
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ removed no sooner than the next major (see `docs/API_STABILITY.md`).

## [Unreleased]

- Refresh the README's opening animations with a shared visual style, actual
public-cloud results and synthetic Rust/WASM feature tracking. Link the
tracking animation to the mobile playground and record bounded generation
instructions, provenance and animation sizes.

- Reuse exact previous-image samples and gradients across CPU LK iterations
for small patches. Retain each iteration's bounds, numerical order and public
behavior with a bounded call-local array and no new heap allocation. Add a
Expand Down
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# SpatialRust

<p align="center">
<img src="docs/assets/readme_hero.gif" alt="SpatialRust hero: public PCL table_scene_lms400 scan, voxel downsample, plane RANSAC, and Euclidean cluster labels from a real MVP pipeline run" width="960">
<img src="docs/assets/readme_hero.gif" alt="SpatialRust: a public PCL scan becomes voxel centroids, a segmented plane, and labeled objects through the Rust pipeline" width="960">
</p>

<p align="center">
<strong>Rust-native spatial computing</strong><br>
Point clouds · wgpu · COPC · RANSAC · ICP — native Rust, no C++ binding layer.
Point clouds · image processing · wgpu · robotics · Rust/WASM camera tracking.
</p>

<p align="center">
Expand All @@ -18,25 +18,29 @@
<img src="https://img.shields.io/badge/GPU-wgpu-38bdf8.svg" alt="wgpu">
</p>

The hero GIF above is **real MVP pipeline output** (not a mockup): it uses the public PCL [`table_scene_lms400.pcd`](https://github.com/PointCloudLibrary/data/blob/master/tutorials/table_scene_lms400.pcd) sample, voxel-downsamples it, RANSAC peels off the dominant plane, and Euclidean clustering lights up objects in color — every frame rendered straight from a live pipeline run.

<p align="center">
<img src="docs/assets/readme_mvp_preview.svg" alt="SpatialRust MVP pipeline preview: RANSAC plane inliers, Euclidean cluster labels, and the pipeline stages" width="960">
</p>
The hero shows **actual Rust pipeline results** from the public PCL
[`table_scene_lms400.pcd`](https://github.com/PointCloudLibrary/data/blob/master/tutorials/table_scene_lms400.pcd)
scan: voxel centroids → plane RANSAC → Euclidean clusters. Animated viewpoints
present the saved outputs; playback speed is independent of processing latency.

| ⚡ GPU-accelerated | 🗂️ COPC-native | 🦀 Pure Rust | 🧩 Composable |
| --- | --- | --- | --- |
| explicit wgpu voxel and normal kernels, automatic CPU fallback | **bounds + LOD** partial reads straight off disk — no full-tile load | no C++ / FFI binding layer to fight | one MVP crate: **IO → filter → segment → register** |

<p align="center">
<img src="docs/assets/clusters_rotating.gif" alt="A multi-object point cloud rotating, each object colored by its DBSCAN cluster label" width="380">
<img src="docs/assets/voxelize_rotating.gif" alt="The same scene voxelized into a rotating 3D occupancy grid of cyan blocks" width="380">
<img src="docs/assets/clusters_rotating.gif" alt="Actual Euclidean cluster labels from the public PCL scan, rendered from changing viewpoints" width="464">
<img src="docs/assets/voxelize_rotating.gif" alt="Occupied 8 cm cells computed by SpatialRust from the same public scan" width="464">
</p>
<p align="center"><sub>DBSCAN clustering and voxel occupancy grids, generated by <code>examples/make_gifs.py</code> through the Python bindings.</sub></p>
<p align="center"><sub>Public point-cloud data · Rust outputs · Euclidean clustering and occupancy cells.</sub></p>

Try the [mobile camera playground](https://rsasaki0109.github.io/SpatialRust/camera/):
opt-in camera or sample playback, Rust/WASM background feature flow and local AI
person masking. Experimental 2D image motion; [usage and device limits](docs/MOBILE_CAMERA_DEMO.md).
<p align="center">
<a href="https://rsasaki0109.github.io/SpatialRust/camera/"><img src="docs/assets/camera_tracking.gif" alt="Synthetic textured image playback with actual forward/backward-consistent feature tracks from the Rust/WASM camera tracker; AI is off in this recording" width="464"></a>
</p>

**[Try camera tracking on your phone →](https://rsasaki0109.github.io/SpatialRust/camera/)**
Use sample playback or opt in to your camera, with optional local AI person
masking. The GIF uses synthetic frames and the actual CPU Rust/WASM tracker,
with AI off. Experimental 2D image motion; [usage and device limits](docs/MOBILE_CAMERA_DEMO.md).

## Why SpatialRust?

Expand Down Expand Up @@ -817,17 +821,22 @@ See also `crates/spatialrust-py/examples/make_gifs.py` and `examples/ml_preproce

## README visuals

The main README pipeline visuals use the public PCL [`table_scene_lms400.pcd`](https://github.com/PointCloudLibrary/data/blob/master/tutorials/table_scene_lms400.pcd) sample, cached under `target/readme-data/` at generation time rather than committed to the repository. Regenerate them with:
The four opening GIFs share a bounded renderer, actual Rust outputs and a
3 MB combined budget. [Generation instructions and provenance](docs/README_VISUALS.md)
cover the public scan, execution settings, synthetic tracking and current asset hashes.

The other README pipeline visuals use the public PCL [`table_scene_lms400.pcd`](https://github.com/PointCloudLibrary/data/blob/master/tutorials/table_scene_lms400.pcd) sample, cached under `target/readme-data/` at generation time rather than committed to the repository. Regenerate them with:

```bash
cargo run -p spatialrust --features mvp --example readme_mvp_preview
```

Outputs: `readme_hero.gif` (header), `readme_mvp_preview.svg` (pipeline panel), `copc_query.gif` (COPC partial read), `benchmark_voxel.svg` (Performance chart), `architecture.svg` (crates diagram), `readme_mvp_pipeline.gif` (pipeline receipt: measured log + top-down result), and `social_preview.svg`.
Outputs: `readme_mvp_preview.svg` (pipeline panel), `copc_query.gif` (COPC partial read), `benchmark_voxel.svg` (Performance chart), `architecture.svg` (crates diagram), `readme_mvp_pipeline.gif` (pipeline receipt: measured log + top-down result), and `social_preview.svg`. This older generator also writes the former `readme_hero.gif`; regenerate the opening group last using the instructions above.

Use `SPATIALRUST_README_CLOUD=/path/to/cloud.pcd` to render the same assets from another local public dataset.

The rotating `clusters_rotating.gif` and `voxelize_rotating.gif` are generated through the Python bindings from the same public sample: `python crates/spatialrust-py/examples/make_gifs.py --input target/readme-data/table_scene_lms400.pcd` (needs `maturin develop` + Matplotlib/Pillow).
`crates/spatialrust-py/examples/make_gifs.py` remains a standalone Matplotlib
example; the opening gallery now uses `scripts/render_readme_heroes.py`.

## Social preview

Expand Down
75 changes: 75 additions & 0 deletions docs/README_VISUALS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# README opening animations

The opening group is rendered from actual SpatialRust results in a shared dark
palette, with readable labels and a link to the mobile camera playground.
`readme_hero.gif` presents the pipeline; the smaller animations show Euclidean
cluster labels, occupied voxel cells and Rust/WASM image-space feature tracking.
The renderer limits each GIF to 1.5 MB and the group to 3 MB. It holds bounded
frame sequences in memory instead of writing intermediate frames to disk.

## Inputs and meaning

- Point clouds: the public PCL
[`table_scene_lms400.pcd`](https://github.com/PointCloudLibrary/data/blob/master/tutorials/table_scene_lms400.pcd)
scan (460,400 points, 5,649,007 bytes). SHA256:
`e285d415641e0d9de695b611db874cc8fe995e8089b77a50d6056d24d8cbcc58`.
The renderer selects every sixth finite point (76,734 points), runs the Rust
pipeline through the Python extension and uses its returned downsampled and
labeled clouds. Exact output membership identifies removed plane points;
the renderer does not fit its own plane or invent cluster labels. Occupied
8 cm cells are returned by `spatialrust.voxelize`.
- Execution: voxel policy is explicitly `cpu`. The installed extension used
for these assets does not expose resolved stage policies; its receipt records
`null` and its binary hash. The visuals make no GPU execution or speed claim.
Build the current extension to reproduce with current stage-policy receipts.
- Tracking: 48 generated 256×192 gray frames are passed to the actual
`BrowserCameraTracker` WASM API at logical 125 ms intervals. All 47 frames
after initialization track successfully. The renderer reconstructs the
same input and checks every frame's byte hash before drawing returned tracks.
No camera, person model, upload or physical-phone capture is involved; the
animation is visibly marked **SYNTHETIC / AI OFF**. The playground separately
offers opt-in camera use and optional local AI person masking.

Viewpoint movement and GIF playback are presentation choices. They do not show
live processing latency, GPU acceleration, metric pose or SLAM qualification.

## Regeneration

Use a built SpatialRust Python extension (`maturin develop --release` from
`crates/spatialrust-py`), NumPy, Pillow and Node.js. Reuse a built camera package
from `scripts/build_camera_demo.py`, or generate only its Rust/WASM package:

```sh
cargo build --release -p spatialrust-web --target wasm32-unknown-unknown
wasm-bindgen --target web --out-dir target/readme-camera-pkg target/wasm32-unknown-unknown/release/spatialrust_web.wasm
```

Use the wasm-bindgen CLI version matching Cargo's wasm-bindgen version. Keep
the input scan and the generated tracking report outside tracked directories.
The exporter and renderer perform no downloads. Then run from the repo root:

```sh
node scripts/readme_tracking_data.mjs --pkg target/readme-camera-pkg --output target/readme-tracking.json
python scripts/render_readme_heroes.py --input /absolute/path/table_scene_lms400.pcd --tracking target/readme-tracking.json --font /absolute/path/sans.ttf --output docs/assets
```

The exporter requires a fresh output file. The renderer updates only the four
opening GIFs and `docs/assets/readme_heroes.json`; it does not modify other README
visuals. Use a local sans font such as DejaVu Sans or Segoe UI. The font hash,
Python extension hash, WASM hash, generator hashes, dependency versions, pipeline
parameters and asset hashes are recorded in that provenance receipt. Different
fonts or builds can change pixels and hashes; rerun the visual checks after
regeneration. No font binary, scan, WASM package or sensor data is committed.

The older `readme_mvp_preview` and `make_gifs.py` examples also write some of
these filenames. Run the opening-group renderer last when regenerating all
README media.

## Verification

The updated group is about 1.54 MB, versus 2.83 MB for the previous three opening
GIFs, including the new tracking animation. Decode every frame, verify image
dimensions, looping, meaningful frame changes, the provenance hashes and the
combined size. Inspect all four pipeline phases and the smaller animations at
desktop and phone widths. Check that the tracking link points to the playground
and that the synthetic/AI-off label and experimental 2D description remain visible.
Binary file added docs/assets/camera_tracking.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/clusters_rotating.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/readme_hero.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions docs/assets/readme_heroes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"schema": "spatialrust.readme-heroes.v1",
"assets": [
{
"path": "readme_hero.gif",
"bytes": 296115,
"sha256": "6567c15b48f102ecdc5595c6c1eae614de5af0545f65c1510d8658f74bca2548"
},
{
"path": "clusters_rotating.gif",
"bytes": 92877,
"sha256": "f944d14e7349510b20a487d60ebb9bdf48ffc8135b6c0d37b74889c822d5f715"
},
{
"path": "voxelize_rotating.gif",
"bytes": 185226,
"sha256": "a7b0d05d2903cb9c809535ef67ddc2bb65c9ba5a45aabfd2c334681dbf96ce48"
},
{
"path": "camera_tracking.gif",
"bytes": 968718,
"sha256": "3ea5d14be5c99d2168c6f75afefd0efc05f5a43b0eb76826f3930f468dbd67c7"
}
],
"public_input": {
"file": "table_scene_lms400.pcd",
"sha256": "e285d415641e0d9de695b611db874cc8fe995e8089b77a50d6056d24d8cbcc58",
"points": 460400,
"sampled_points": 76734
},
"execution": "SpatialRust Python bindings (voxel policy cpu); CPU Rust/WASM camera tracker",
"spatialrust_version": "1.0.0",
"resolved_policies": null,
"python_extension_sha256": "cba594925d83a3b495db4f1ecb97434df72767b7075fccf0380c559477e62c5c",
"generator_sha256": "d3b13cc87501d4e9f1c6ad6c8dc24ad0cedafa26e09e4c1cc0a6468932c120ec",
"tracking_generator_sha256": "0ab17ebc391cd054e1c607ed6fbf42bccab39a026c8516e09b86faee4d78c9cb",
"numpy_version": "2.3.4",
"pillow_version": "12.3.0",
"font_sha256": "8134dbcd09e7b123c9a7f229d49cffbcb01352cc72ea5e1076b65d0dca9f73cd",
"pipeline": {
"voxel_leaf_m": 0.03,
"plane_distance_m": 0.025,
"cluster_tolerance_m": 0.06,
"min_cluster_size": 8,
"downsampled_points": 4561,
"plane_inliers": 2179,
"cluster_count": 6,
"occupancy_cell_m": 0.08,
"occupied_cells": 776
},
"tracking_wasm_sha256": "f99c2ba94abe68021b880ba2141c087b5758d638011b04b1ea5d0b47b00493ad",
"tracking_frames": 48,
"claims": "Illustrations of actual outputs; animation playback is not a throughput benchmark. Synthetic tracking has AI disabled."
}
Binary file modified docs/assets/voxelize_rotating.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions scripts/readme_tracking_data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Export actual Rust/WASM reports for the README's synthetic playback visual.
// No camera, AI model, browser, network request or timing benchmark is used.
import fs from "node:fs";
import path from "node:path";
import { createHash } from "node:crypto";

function arg(name) {
const i = process.argv.indexOf(name);
if (i < 0 || !process.argv[i + 1]) throw new Error(`missing ${name}`);
return path.resolve(process.argv[i + 1]);
}
const pkg = arg("--pkg"), output = arg("--output");
if (fs.existsSync(output)) throw new Error("output already exists");
const js = fs.readFileSync(path.join(pkg, "spatialrust_web.js"));
const wasm = fs.readFileSync(path.join(pkg, "spatialrust_web_bg.wasm"));
const { initSync, BrowserCameraTracker } = await import(`data:text/javascript;base64,${js.toString("base64")}`);
initSync({ module: wasm });
const width = 256, height = 192, frameCount = 48;
const tracker = new BrowserCameraTracker(width, height);
const frames = [];
try {
for (let frame = 0; frame < frameCount; frame++) {
const angle = 2 * Math.PI * frame / frameCount;
const dx = Math.round(8 * Math.sin(angle)), dy = Math.round(5 * Math.cos(angle));
const gray = new Uint8Array(width * height);
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
const sx = x - dx + 32, sy = y - dy + 32;
const h = (Math.imul(sx, 73856093) ^ Math.imul(sy, 19349663)) >>> 0;
gray[y * width + x] = ((((sx >> 4) + (sy >> 4)) % 2) ? 125 : 35) + ((h ^ (h >>> 13)) & 31);
}
const report = JSON.parse(tracker.track_gray_copy(gray, new Uint8Array(0), frame * 125));
if (report.schema !== 1 || report.tracks.length > 80) throw new Error("unexpected tracking report");
if (frame && (report.status !== "tracking" || !report.background_flow_px)) throw new Error(`tracking lost at frame ${frame}`);
frames.push({ shift: [dx, dy], gray_sha256: createHash("sha256").update(gray).digest("hex"), report });
}
} finally { tracker.free(); }
fs.mkdirSync(path.dirname(output), { recursive: true });
fs.writeFileSync(output, JSON.stringify({
schema: "spatialrust.readme-tracking.v1", synthetic_only: true, ai_enabled: false,
execution: "CPU Rust/WASM", width, height, frame_duration_ms: 125,
wasm_sha256: createHash("sha256").update(wasm).digest("hex"),
bindings_sha256: createHash("sha256").update(js).digest("hex"), frames,
}, null, 2) + "\n", { flag: "wx" });
console.log(JSON.stringify({ frames: frames.length, tracked: frames.filter(f => f.report.status === "tracking").length, output }));
Loading
Loading