Projects motion of pixels to a voxel
Find a file
Sam b02a5b4f46 Formalise project
This "projectifies" the code as it stood. We add
a more detailed README, a Makefile and include the
dependencies in source control in a sub directory.
Building is updated slightly to output to a
`build` directory so we can gitignore artifacts.
AI Disclosure: Some copilot use for drafts of the
makefile and readme
2025-08-27 21:08:51 +01:00
docs Formalise project 2025-08-27 21:08:51 +01:00
nlohmann Formalise project 2025-08-27 21:08:51 +01:00
stb Formalise project 2025-08-27 21:08:51 +01:00
.gitignore Formalise project 2025-08-27 21:08:51 +01:00
examplebuildvoxelgridfrommotion.bat Create examplebuildvoxelgridfrommotion.bat 2025-04-01 05:38:15 +13:00
Makefile Formalise project 2025-08-27 21:08:51 +01:00
process_image.cpp Create process_image.cpp 2025-04-01 05:33:04 +13:00
ray_voxel.cpp Formalise project 2025-08-27 21:08:51 +01:00
README.md Formalise project 2025-08-27 21:08:51 +01:00
requirements.txt Formalise project 2025-08-27 21:08:51 +01:00
setup.py Create setup.py 2025-04-01 05:35:03 +13:00
spacevoxelviewer.py Create spacevoxelviewer.py 2025-04-01 05:33:43 +13:00
voxelmotionviewer.py Create voxelmotionviewer.py 2025-04-01 05:35:49 +13:00

Pixeltovoxelprojector

Projects motion of pixels to a voxel

Overview

PixelToVoxelProjector reconstructs 3D motion or object trajectories from multi-camera image sequences using voxel-based ray accumulation. It provides both C++ and Python tools for processing images, detecting motion, casting rays into a 3D voxel grid, and visualizing results.

Features

  1. Multi-camera motion detection: Detects moving pixels between consecutive frames for each camera.
  2. Ray casting: Projects rays from camera pixels into a shared 3D voxel grid using voxel DDA.
  3. Voxel accumulation: Aggregates brightness/motion evidence in a 3D grid.
  4. Flexible metadata: Camera parameters and image info are loaded from a JSON file.
  5. Python visualization: Visualizes the reconstructed 3D scene, camera positions, and motion using matplotlib and pyvista.
  6. Astro support: Includes tools for processing astronomical FITS images and mapping sky coordinates.

Requirements

  1. C++17 compiler
  2. Python 3.8+

Example Workflow

  1. Prepare metadata.json and images in a folder.
  2. Run the C++ pipeline to generate voxel_grid.bin.
  3. Use Python scripts to visualize and analyze the voxel grid.

File Structure and metadata format

See docs.

Build Instructions

C++ Executable

make

This builds ray_voxel.

Python Extension (process_image_cpp)

# Optionally create a virtual env (recommended)
python3 -m venv .venv
# or with uv:
# uv venv
# Then activate with (linux)
source .venv/bin/activate
# Windows
# .venv/bin/activate.bat or .venv/bin/Activate.ps1

# Install the dependencies
pip install pybind11 setuptools
python setup.py build_ext --inplace

This builds the process_image_cpp Python module.

Usage

C++ Pipeline

./build/ray_voxel metadata.json images_folder output_voxel_grid.bin
  • Processes images and metadata, outputs a binary voxel grid.

Python Visualization

python spacevoxelviewer.py
  • Processes FITS images, accumulates into a voxel grid, and visualizes results.
python voxelmotionviewer.py
  • Loads and interactively visualizes a voxel grid.