#!/usr/bin/env python3 """The words and the markup of the scans pages on the site (6ense.com/scans/), for scan_publish.py. list_page(metas, stamp) scans/index.html the scans, as cards how_page(groups, stamp) scans/how.html how a scan is made, with the tools with_site_style(html, stamp) a page kept as a file here (view.html, live.html) as it goes onto the site The pages wear the home page's look: each loads the home page's stylesheet (../style.css) and then scans.css, which adds what only these pages have. They are plain pages with no script (the two with a 3-D stage aside), laid out as the home page is: a masthead with the words on the left and a dark panel on the right, tiles, cards, and a footer that says how the page is honest. """ import html import re SITE = "http://6ense.com/" SECURE_COPY = "https://cyborg-collective-relay.onrender.com/scans/" MARK = "" # in view.html and live.html: where the home page's stylesheet is linked on the site e = html.escape def styles(stamp): return f'\n' def with_site_style(page, stamp): """A page that also runs on the laptop, as it is published: the home page's stylesheet first, scans.css stamped.""" if MARK not in page or '' not in page: raise SystemExit("the page has no place for the site's stylesheet (the site-style comment and the scans.css link)") return page.replace(MARK, '').replace( '', f'') def head(title, description, stamp): return f""" {e(title)} {styles(stamp)} """ def menu(here): items = [("../", "Home"), ("./", "Scans"), ("live.html", "Live"), ("how.html", "How a scan is made"), ("../space/", "Rooms in 3-D"), ("../record.html", "The record")] return '\n" def chain_figure(): """The chain from headset to print and to this site, drawn the way the home page draws its chains: balls on lines.""" nodes = [ # x, y, name, what, class (70, 78, "headset", "a Quest 3S, worn", ""), (232, 78, "pictures", "with position + depth rays", ""), (410, 78, "splat", "trained by Brush, ~2 min", ""), (566, 78, "solid", "closed, flat base", ""), (700, 78, "print file", "sliced, Bambu H2C", ""), (232, 256, "live Gaussians", "one per depth reading", "live"), (410, 168, "compressed", "Open3D, .spz, a tenth", ""), (640, 226, "this site", "live · scans", "gold"), ] edges = [ # from, to, class (0, 1, ""), (1, 2, ""), (2, 3, ""), (3, 4, ""), (0, 5, "live"), (5, 7, "live"), (2, 6, ""), (6, 7, "gold")] r = 13 out = ['', 'The chain from a headset to a print file and to this site', 'A headset, worn, keeps pictures with its position and depth rays. A laptop trains a Gaussian splat from them, makes a closed solid from the splat and slices it into a print file. ' 'While scanning, live Gaussians, one per depth reading, go to this site. Afterwards the trained splat, compressed, goes to this site too.'] for a, b, cls in edges: x1, y1, x2, y2 = nodes[a][0], nodes[a][1], nodes[b][0], nodes[b][1] if y1 == y2: # along the row d = f"M{x1 + r} {y1} L{x2 - r} {y2}" elif x1 == x2: # straight down d = f"M{x1} {y1 + r} L{x2} {y2 - r}" elif y2 > y1 and x2 > x1 and a == 0: # down from the headset, then across into the ball's left d = f"M{x1} {y1 + r} C{x1} {y2}, {x1 + 40} {y2}, {x2 - r} {y2}" elif abs(y2 - y1) < 40: # from the right of one into the left of the other, a little lower or higher mx = (x1 + x2) / 2 d = f"M{x1 + r} {y1} C{mx} {y1}, {mx} {y2}, {x2 - r} {y2}" else: # across, then down into the top of the ball d = f"M{x1 + r} {y1} C{x2 - 60} {y1}, {x2} {y1 + 10}, {x2} {y2 - r}" out.append(f'') for x, y, name, what, cls in nodes: out.append(f'') up = y == nodes[0][1] # the top row's words stand over their balls: lines leave downwards out.append(f'{e(name)}') out.append(f'{e(what)}') out.append("") return ('
\n' '
6ense™ the chain · from what a headset sees to something that can be held
\n' '

Blue is what a laptop makes after the scan; green goes out while the headset is still scanning; ' 'gold is this site.

\n' '
' + "\n".join(out) + "
\n
\n") def honest(): return f""" """ def mb(n): return f"{n / 1e6:.0f} MB" if n >= 1e7 else f"{n / 1e6:.1f} MB" if n >= 1e6 else f"{max(1, round(n / 1e3))} kB" def sliced(text): """'sliced x.stl for the H2C: 1h 33m 49s print time, 30.44 g PLA, 373 layers' -> '1h 33m 49s, 30.44 g PLA'.""" t = re.sub(r"^sliced \S+ for the H2C: ", "", text or "") return re.sub(r", \d+ layers$", "", t.replace(" print time", "")) def facts(m): rows = [] s, tr, pr, rm = m.get("size_cm"), m.get("train") or {}, m.get("print") or {}, m.get("room") or {} if m["mode"] == "object" and s and not m.get("size_note"): rows.append(("Real size", f"{s[0]} × {s[2]} × {s[1]} cm high")) pl = m.get("placing") or {} if pl.get("pictures"): # a phone's pictures: how many there were, and how many could be placed from what they show rows.append(("Pictures", f"{pl['pictures']}, of which {pl.get('placed')} placed (to {pl.get('reprojection_px')} px)")) else: rows.append(("Pictures", str(m.get("pictures", "—")))) if m.get("size_note"): rows.append(("Size", "a guess: pictures alone carry no scale")) eeg = (m.get("bag") or {}).get("eeg") if eeg: rows.append(("With it", f"{eeg:,} samples of brain waves and {(m.get('bag') or {}).get('imu', 0):,} of the phone's motion, in the same recording")) if tr.get("gaussians"): part = m.get("splat_count") if m.get("splat_count") != tr["gaussians"] else None rows.append(("Splat", f"{tr['gaussians']:,} Gaussians, {tr.get('steps'):,} steps" + ("" if not part else f"; {part:,} are the object" if m["mode"] == "object" else f"; {part:,} shown here"))) if tr.get("held_out_psnr_db"): rows.append(("Pictures kept back", f"reproduced at {tr['held_out_psnr_db']} dB")) c = m.get("check") or {} if c.get("median_mm") is not None: rows.append(("From the true shape", f"{c['median_mm']} mm for half the surface, {c.get('p95_mm')} mm for 95 %")) if pr.get("print_size_mm"): rows.append(("Print", " × ".join(f"{v:.0f}" for v in pr["print_size_mm"]) + " mm" + (f"; {sliced(pr.get('slice'))}" if pr.get("slice") else ""))) if rm.get("size_m"): rows.append(("Room model", f"{rm['size_m'][0]} × {rm['size_m'][2]} m, {rm['size_m'][1]} m high (an estimate)")) rp = rm.get("print") or {} if rp.get("size_mm"): rows.append(("Diorama print", f"{rp.get('scale')}, " + " × ".join(f"{v:.0f}" for v in rp["size_mm"]) + " mm" + (f"; {sliced(rp.get('slice'))}" if rp.get("slice") else ""))) return rows def tiles(metas): seen = sum(1 for m in metas if m["kind"] == "headset") phones = sum(1 for m in metas if m["kind"] == "phone") gauss = sum((m.get("train") or {}).get("gaussians") or 0 for m in metas) pics = sum(m.get("pictures") or 0 for m in metas) best = min((m["check"]["median_mm"] for m in metas if (m.get("check") or {}).get("median_mm") is not None), default=None) secs = [(m.get("train") or {}).get("seconds") for m in metas if (m.get("train") or {}).get("seconds")] out = [(str(len(metas)), "scans here"), (str(seen), "seen by a headset")] + ([(str(phones), "photographed with a phone")] if phones else []) \ + [(f"{gauss:,}", "Gaussians trained"), (str(pics), "pictures they were trained from")] if best is not None: out.append((f"{best} mm", "closest to a known shape (half the surface)")) if secs: out.append((f"{min(secs) / 60:.1f}–{max(secs) / 60:.1f} min" if len(secs) > 1 else f"{secs[0] / 60:.1f} min", "to train one on a laptop")) return '
\n' + "\n".join(f'
{e(v)}{e(l)}
' for v, l in out) + "\n
\n" def list_page(metas, stamp): title = "Scans in 3-D" desc = ("What a person wearing a headset looks at, rebuilt in 3-D: drawn as Gaussians while they look, trained into a Gaussian splat " "minutes later, and for an object made into a solid that can be printed and held.") parts = [head(title, desc, stamp), f"""

Cyborg Collective · 6ense™

{title}

{e(desc)}

A headset on the head is a camera that knows where it is. These pages use that and little else: its pictures, its own positions, and the depth it works out from its two tracking cameras (it has no lidar). A laptop does the rest, with tools that are published beside the results, and every result says what it is: seen by a headset, or a test of the method against a shape that is known.

{menu("./")}
{tiles(metas)}
{chain_figure()}

The scans

Each opens in 3-D: an object to turn round, beside the solid made from it; a place to look round from where it was photographed. “Pictures kept back”: a tenth of the pictures are not used for training, and the number says how closely the splat reproduces them (higher is closer).

"""] if not metas: parts.append('
No scan is published at the moment.
\n') else: parts.append('
\n') for m in metas: sid = m["id"] pics = "".join(f'{e(p[' for p in m["pictures_shown"]) rows = "".join(f"
{e(a)}
{e(b)}
" for a, b in facts(m)) files = " · ".join(f'{e(d["label"])} {mb(d["bytes"])}' for d in m["downloads"]) badge = ('a test of the method' if m["kind"] == "test" else 'photographed with a phone' if m["kind"] == "phone" else 'seen by a headset') opener = "Look round it in 3-D" if m["mode"] == "view" else "Turn it round in 3-D" parts.append(f"""
{pics}

{e(m["title"])}

{badge}

{e(m["note"])}

{rows}

{opener}{files}

""") parts.append("
\n") parts.append("
\n
\n") parts.append(honest()) return "".join(parts) def how_page(groups, stamp): """groups: [(title, [(file name, what it is for), ...]), ...] for the tools published in scans/tools/.""" title = "How a scan is made" desc = "From a headset's pictures to a Gaussian splat, a solid and a print file: the chain, what has been checked and what has not, and every tool as a plain file." tools = [] for group, files in groups: rows = "\n".join(f' {e(n)}{e(job)}' for n, job in files) tools.append(f'
\n

{e(group)}

\n
\n{rows}\n
\n
\n') return head(title, desc, stamp) + f"""

Cyborg Collective · Scans in 3-D

{title}

{e(desc)}

A thing or a place is photographed with a Meta Quest 3S headset. A laptop turns the photographs into a Gaussian splat and, for an object, into a closed solid sliced for a 3-D printer, and the result goes onto this site. Everything it is made with is on this page.

{menu("how.html")}
.\\start_quest_scan.ps1scan, splat, solid, print file .\\start_quest_scan.ps1 -Live -Publishthe same, live on this site while scanning and published here afterwards

One command on the laptop the headset is plugged into. Without -Live or -Publish everything stays on that laptop; nothing is ever sent to a printer.

{chain_figure()}

The chain

Six steps. The two with a dashed edge happen only when asked for, because they are public.

  1. The headset keeps picturesIts app keeps a picture from the passthrough camera every 5 cm or 6 degrees of head movement, with the headset's own position and direction for it and an 80 × 60 grid of depth rays behind it. Pulling the trigger on a thing names it as the object. The headset has no lidar: its depth comes from its two tracking cameras.
  2. Live, if asked forWhile it scans, the app also sends one depth reading per ray to the laptop over the USB cable. The laptop keeps one per 2 cm of surface and passes them through the relay; the live page draws each as a Gaussian the moment it arrives. These are placed, not trained.
  3. The laptop trains the splatThe headset's positions are used as they are, with no structure from motion. The pictures are cropped round the object and Brush trains the Gaussians for 8,000 steps, about two minutes on a laptop's graphics card. A tenth of the pictures are kept back and compared with what the splat draws from their positions.
  4. From splat to solidThe splat's depth is drawn from every camera position and voted into a grid: outside where enough cameras see past a cell, surface where they see it, solid where none could see, so the body is closed. It is cut flat on the surface it stood on.
  5. SlicedThe solid is scaled and sliced for a Bambu H2C with the slicer's command line, which reports the time and the grams. Nothing is sent to a printer.
  6. Published, if asked forOpen3D reads the trained splat and writes it compressed, about a tenth of the size; that file, the solid, a render and the print files go into this site's repository. Open3D does not make the splat: it has no training. The camera pictures are not published.

What has been checked, and what has not

0.47 mmT. rex: half the surface within this of the true shape
0.37 mmTriceratops, the same measure
0.3 %T. rex: its sizes, against the true ones
0.5 %T. rex: its volume
0.02 pxreal depth rays against the camera model, sideways
26pictures in the one sitting on the headset so far
Against known shapesTwo made-up scans of known models, drawn at the headset camera's geometry with noise in the depth, went through the same steps as a real scan. The solids are measured against the models they were drawn from. Both are on the list, labelled as tests.
On the headsetOne sitting so far, from one seat in a room: a view to look round rather than an object. Its depth rays land within 0.02 px sideways and 4 px vertically of where they were cast, so the camera model holds on the device.
These pagesEach has a browser test that travels with it (test_scans_page.py, test_live_page.py). The live page's test sends a made-up room through a relay and requires the page to draw it and let it go.
Not yetA walk all the way round one object with the headset; the live view from the headset itself (only made-up rooms have been sent so far); AR and VR inside the headset from this site; a print.

The tools

Plain files, as they are used; nothing here is built. Python (numpy, scipy, numba, Open3D, scikit-image, Pillow, playwright), PowerShell, and one C# script for Unity 6 with Meta's XR packages. Their defaults name folders in the user's home folder. The viewer is view.html and the live page live.html: their source is the page itself, with scans.css.

{"".join(tools)}

What they stand on

Brushtrains the splat (Apache 2.0)
Open3Dcompresses it to .spz (MIT)
Sparkdraws Gaussian splats in the browser (MIT; kept in vendor/)
three.jsthe 3-D underneath (MIT; kept in vendor/)
Meta's XR interfacesthe headset's passthrough camera and depth
Bambu Studioits command line slices the solid
""" + honest()