Software setup: sandcam (Python)¶
Overview¶
DuneBox-sandcam is the hackable Python companion to DuneBox. It's ideal for rapid prototyping, custom creatures, ArUco marker experiments, and testing without dedicated hardware.
Repo: Manaiakalani/DuneBox-sandcam
Prerequisites¶
| Dependency | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Runtime |
| uv | latest | Package manager |
| Kinect (optional) | any type sandcam supports | Depth camera; falls back to the mouse simulator |
| websockets | latest | Depth streaming server (installed by uv sync) |
Optional Extras¶
# GeoTIFF / DEM loading support
uv sync --extra geo
# Extra sensor backends (Kinect v2, Azure Kinect, RealSense)
uv sync --extra all-sensors
Step 1: Clone the Repo¶
Step 2: Install Dependencies¶
# Install uv if you don't have it
pip install uv
# Sync dependencies (creates .venv automatically)
uv sync
This installs:
- pygame: 60 FPS display + multi-display
- numpy / scipy: array computation
- opencv-contrib-python: ArUco marker detection
- libfreenect bindings (ctypes wrapper)
- websockets: depth streaming server + inter-app bridge
Windows Note¶
sandcam ships with pre-compiled freenect.dll and libusb-1.0.dll: no C compilation needed on Windows.
Step 3: Run¶
On Windows, double-click run.bat or the DuneBox shortcut. It fast-forwards this checkout (git pull --ff-only) and runs uv sync, then launches. The pull gives up after 45 seconds, and a failed update still starts the copy already on disk. After a successful check, the shortcut skips the network for 6 hours. The kiosk still checks at each sign-in.
No Kinect Connected?¶
sandcam automatically enters mouse simulator mode: - Move your mouse to simulate terrain changes - Full UI and creature system works - Great for development and testing
With Kinect Connected¶
The Windows default is Kinect v2 (kinect_v2_sdk). Install the Kinect for Windows Runtime 2.0 and use a USB 3.0 port.
Kinect v1 (sensor_type set to kinect_v1) needs its AC power adapter. USB power alone is not enough.
Step 4: Multi-Display Setup¶
For projector output, sandcam supports a separate display window:
- Connect projector as a second display
- In the sandcam UI, select the projector display from the display picker
- The projector shows the clean sand visualization; your monitor shows the control UI
Features to Explore¶
Biome-Aware Creatures¶
Modern set: sharks (water) and dinosaurs (land). Cycle with V for prehistoric species (T-Rex, raptor, pteranodon, stegosaurus, triceratops, brachiosaurus).
Creature definitions are in creatures.py: easy to add your own!
ArUco Marker Triggers¶
- Print ArUco markers (OpenCV ArUco dictionary)
- Attach markers to physical toys (dinosaurs, boats, houses, etc.)
- Place a marked toy on the sand → the webcam detects it → triggers a themed event
Printed 4×4 tags live in calibration/ (dictionary DICT_4X4_250):
| IDs | Role |
|---|---|
| 1–5 | Toys: boat, dino, house, tree, volcano (guide + ripples) |
| 10–13 | Dinosaur spawn / extinction |
| 20 / 21 | Place volcano / trigger nearest volcano |
| 100 / 101 / 102 / 103 | Corners: TL / TR / BR / BL |
AI Guide (Optional)¶
Enable the AI guide in settings for interactive narration. The guide describes terrain features and teaches geography concepts. See ai_guide.py.
Also included¶
- Sound effects: ambient audio reacts to terrain and weather
- Dinosaurs: prehistoric creature set alongside modern animals
- Volcanoes: place and trigger volcanic eruptions
- Earthquakes: keyboard or a slap on the sand
- Ecosystem: plants grow near water; predator and prey
- Game modes: Build a Dam, Volcano Defense, Watershed Puzzle, Biome Sculpt
- Day/night cycle: animated lighting with adjustable speed
- Sensors: Kinect v1/v2, Azure Kinect, Orbbec, RealSense
- Web dashboard: live sand map and controls, including from a tablet
- Inter-app bridge: TCP link to DuneBox (C++) on
localhost:9876 - Contour lines, terrain snapshots (
F5), creature sets, and a settings sidebar (Tab)
Keyboard Controls¶
| Key | Action |
|---|---|
A |
Auto-calibrate Kinect v2 depth range from the flat sand |
C |
Toggle contour lines |
G |
Toggle creatures |
V |
Cycle creature sets (Modern → Prehistoric → All → None) |
F5 |
Save terrain snapshot |
E |
Toggle ecosystem simulation |
N |
Toggle day/night cycle |
+ / - |
Speed up / slow down day/night |
P |
Pause day/night cycle |
S |
Toggle sound mute |
O |
Toggle volcano click-to-place |
K |
Manual earthquake trigger |
U |
Toggle the web dashboard (http://127.0.0.1:8765/) |
B |
Toggle inter-app bridge |
F1 |
Game: Build a Dam |
F2 |
Game: Volcano Defense |
F3 |
Game: Watershed Puzzle |
F4 |
Game: Biome Sculpt |
Esc |
End current game |
Tab |
Settings sidebar |
R |
Reset terrain (simulator mode) |
Q |
Quit |
Web Dashboard¶
Press U and sandcam serves its dashboard at http://127.0.0.1:8765/. The status line flashes the address. It shows the live sand map in the current color theme and controls both apps: theme, contours, creatures, day and night, volcanoes, games, depth calibration, and DuneBox (C++) water and lava when it's running.
By default it only listens on this PC. To use it from a tablet, see Run it from a tablet.
Sensor Configuration¶
sandcam supports multiple depth sensors via the sensor_type field in sandcam-settings.json:
Supported values:
| Value | Sensor |
|---|---|
| kinect_v1 | Microsoft Kinect v1 (Xbox 360) |
| kinect_v2 | Microsoft Kinect v2 (Xbox One) via libfreenect |
| kinect_v2_sdk | Microsoft Kinect v2 via Kinect SDK 2.0 |
| orbbec | Orbbec depth camera |
| realsense | Intel RealSense (requires --extra all-sensors) |
| mouse_simulator | Mouse-driven simulator (default when no sensor found) |
| dummy | No-op dummy sensor for testing |
Configuration¶
Edit sandcam-settings.json:
{
"sensor_type": "kinect_v1",
"sensor_fallback": "mouse_simulator",
"fullscreen": false,
"display_index": 0,
"show_creatures": true,
"vision_enabled": false,
"ai_enabled": false,
"guide_enabled": true
}
Unknown keys are ignored. Copy sandcam-settings.example.json for the full portable default set. After mounting a Kinect v2, press A to auto-calibrate min_depth_mm / max_depth_mm.
Next Steps¶
- Calibration guide: aligning projector and Kinect
- Customization guide: adding themes and creatures
- Set up the webcam for ArUco detection →
webcam_observer.py