SkyLok/math_example/README.md
2026-05-21 14:11:06 +02:00

39 lines
1.0 KiB
Markdown

# math_example
Basic pixel → 3D vertex projection. Each pixel's brightness is used as depth in a
pinhole back-projection:
```
x = (u - cx) / fx * depth
y = (v - cy) / fy * depth
z = depth
```
Output is a triangulated OBJ mesh. Bright pixels project far from the camera,
dark pixels stay close. Gives a height-map-like 3D surface from any image.
## Build
```sh
make
```
Needs only the C++ stdlib and `stb_image` from `../shader_example/`.
## Run
```sh
./math # 128x128 sine-wave test pattern
./math ../shader_example/frame1.jpg # load an image
./math ../shader_example/frame1.jpg 2 # step=2 (denser mesh)
./math ../shader_example/frame1.jpg 4 90 # step=4, FOV 90°
```
Output: `out.obj` — open in Blender (`File → Import → Wavefront`) or MeshLab.
## What it's for
This is the math layer that sits between the camera and the LoRa transmitter.
Instead of sending raw pixels, you project them to vertices, run motion detection
in that 3D space, and transmit only the diff vertices over LoRa.