# GenRecon web app — phone video → walkable 3D (PWA) Front-to-back app for **genrecon.suby.pl**: upload a phone video → server reconstructs a 3D scene with [GenRecon](https://github.com/kasothaphie/GenRecon) → walk through it first-person in the browser. Built to drop onto the `genrecon` LXC from issue **i-opavuyaq**. ``` backend/ FastAPI service: upload → ffmpeg → COLMAP → reconstruct_scene → chunked_to_glb → scene.glb frontend/ PWA: upload UI, live progress, three.js first-person walkthrough (Octree collision) vendor/ = three.js r161 (vendored, offline-capable) · demo.glb = bundled sample scene sample/ a sample walkable scene.glb (also used as the MOCK output) ``` ## Run locally WITHOUT a GPU (mock mode) ```bash python3 -m venv .venv && . .venv/bin/activate pip install -r backend/requirements.txt GENRECON_MOCK=1 GENRECON_JOBS_DIR="$PWD/_jobs" \ GENRECON_FRONTEND_DIR="$PWD/frontend" GENRECON_SAMPLE_GLB="$PWD/sample/scene.glb" \ uvicorn app:app --app-dir backend --host 0.0.0.0 --port 8000 # open http://localhost:8000 → "Zobacz przykładową scenę 3D", or upload any file (mock ignores content) ``` ## Deploy on the `genrecon` machine (real pipeline) Prereqs from issue i-opavuyaq Step 2 (GenRecon at `/opt/genrecon/src`, checkpoints at `/opt/genrecon/ckpts`, conda env `genrecon`, COLMAP + ffmpeg installed). ```bash git clone /opt/genrecon/app pip install -r /opt/genrecon/app/backend/requirements.txt # into the system/base python cp /opt/genrecon/app/backend/genrecon-app.service /etc/systemd/system/ systemctl enable --now genrecon-app # then add the Caddy route on the suby edge: genrecon.suby.pl → :8000 ``` Service config lives in `backend/genrecon-app.service` (env vars: jobs dir, GenRecon paths, conda env, `GENRECON_CUDA_DEVICE` — pin to a free GPU, e.g. `5`). Set `GENRECON_MOCK=1` there to serve the demo scene before the model is ready. ## API | Method | Path | | |---|---|---| | POST | `/api/jobs` | multipart `video` → `{id}` | | GET | `/api/jobs/{id}` | `{status, stage, progress, message, error}` | | GET | `/api/jobs/{id}/scene.glb` | the reconstructed scene | | GET | `/api/jobs/{id}/log` | raw pipeline log | | GET | `/api/health` | | ## ⚠️ Verify against the real GenRecon `Iphone` layout `backend/pipeline.py` assembles `/images/` + `/colmap/{cameras,images,points3D}.txt` (what the README implies). During the i-opavuyaq Step-2 smoke test, confirm `reconstruct_scene.py --mode Iphone` actually finds that layout; adjust `run_colmap` / `_reconstruct_cmd` if not. ## Deploy: web-optimized walkthrough (optional but recommended) Reconstructed meshes are 100s of MB. `backend/optimize_glb.sh` (called automatically by the glb stage) shrinks them to a browser-loadable size (simplify + webp). It needs a one-time local gltf-transform install: ```sh bash backend/setup_gltftool.sh # installs to /opt/genrecon/gltftool ``` Without it the pipeline still works — it just serves the full-res `scene.glb`. Tune via `GENRECON_SIMPLIFY_RATIO` (default 0.12) and `GENRECON_TEX_SIZE` (2048).