|
ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
|
Classes | |
| struct | EvalMetrics |
| One held-out evaluation pass. More... | |
| struct | GaussianCloud |
| A set of 3D Gaussians in plain host memory. More... | |
| struct | GaussianInitOptions |
| Parameters for seeding Gaussians from a ReUseX point cloud. More... | |
| struct | GsplatStageOptions |
| End-to-end options for the rux create gsplat stage. More... | |
| struct | MCMCOptions |
| 3DGS-MCMC density control (Kheradmand et al. More... | |
| struct | TrainingView |
| One posed training image for the Gaussian-splatting optimizer. More... | |
| struct | TrainingViewOptions |
| Selection and preprocessing knobs for building the training set. More... | |
| struct | TrainMetrics |
| One row of the loss history. More... | |
| struct | TrainOptions |
| Optimizer / schedule parameters for the 3DGS training loop. More... | |
| struct | TrainResult |
Functions | |
| float | rgb_to_sh_dc (float c) |
| RGB in [0,1] -> degree-0 SH coefficient. | |
| float | sh_dc_to_rgb (float f) |
| Degree-0 SH coefficient -> RGB in [0,1] (not clamped). | |
| float | inverse_sigmoid (float x) |
| Numerically safe logit, the inverse of the sigmoid used for opacity. | |
| GaussianCloud | init_from_point_cloud (const CloudPtr &cloud, const GaussianInitOptions &opt={}) |
| Seed Gaussians from an XYZRGB cloud: means = point positions, DC colour = point colour, scale = log of the k-NN mean spacing, rotation = identity, opacity = logit(initial_opacity). | |
| std::vector< std::uint8_t > | gaussian_ply_bytes (const GaussianCloud &gaussians) |
| Serialize to a 3DGS-format binary-little-endian .ply in memory (the property names the reference implementation and every common viewer expect: x/y/z, nx/ny/nz, f_dc_*, f_rest_*, opacity, scale_*, rot_*). | |
| void | save_gaussian_ply (const GaussianCloud &gaussians, const std::filesystem::path &path) |
Write the bytes of gaussian_ply_bytes() to path. | |
| GaussianCloud | load_gaussian_ply (const std::filesystem::path &path) |
| Read back a .ply written by save_gaussian_ply. | |
| bool | is_available () |
| True when this build actually contains the CUDA trainer. | |
| bool | has_cuda_device () |
| True when this process can actually reach a CUDA device right now. | |
| TrainResult | train_gaussians (const GaussianCloud &init, const std::vector< TrainingView > &views, const TrainOptions &opt={}) |
| Train Gaussians against posed views. | |
| cv::Mat | render_view (const GaussianCloud &gaussians, const TrainingView &view) |
Rasterize gaussians from view. | |
| TrainResult | run_gsplat_stage (ProjectDB &db, const GsplatStageOptions &opt) |
Load the seed cloud and views from db, train, and store the splat. | |
| std::vector< TrainingView > | load_training_views (const ProjectDB &db, const TrainingViewOptions &opt={}) |
| Load posed training views from a project. | |
Variables | |
| constexpr float | kShC0 = 0.28209479177387814f |
| The 3D Gaussian Splatting DC spherical-harmonic basis function value, 0.5 * sqrt(1/pi). | |
| std::vector< std::uint8_t > reusex::gsplat::gaussian_ply_bytes | ( | const GaussianCloud & | gaussians | ) |
Serialize to a 3DGS-format binary-little-endian .ply in memory (the property names the reference implementation and every common viewer expect: x/y/z, nx/ny/nz, f_dc_*, f_rest_*, opacity, scale_*, rot_*).
Exists as its own function because the trained splat has two destinations and they must be byte-identical: ProjectDB (where the stage stores it, #322) and an optional --out file. Serializing twice would be two chances to diverge; writing the file and re-reading it would be an extra pass over hundreds of megabytes.
| std::runtime_error | if gaussians is empty or fails validation. |
| bool reusex::gsplat::has_cuda_device | ( | ) |
True when this process can actually reach a CUDA device right now.
is_available() answers "was the trainer compiled in"; this answers "is there a GPU to run it on", which is what a [gpu]-tagged test needs in order to SKIP honestly instead of failing.
| GaussianCloud reusex::gsplat::init_from_point_cloud | ( | const CloudPtr & | cloud, |
| const GaussianInitOptions & | opt = {} ) |
Seed Gaussians from an XYZRGB cloud: means = point positions, DC colour = point colour, scale = log of the k-NN mean spacing, rotation = identity, opacity = logit(initial_opacity).
| std::runtime_error | if cloud is null or empty. |
| float reusex::gsplat::inverse_sigmoid | ( | float | x | ) |
Numerically safe logit, the inverse of the sigmoid used for opacity.
| bool reusex::gsplat::is_available | ( | ) |
True when this build actually contains the CUDA trainer.
Always true in a translation unit that can link reusex_gsplat; provided so callers can report the capability without an #ifdef of their own.
| GaussianCloud reusex::gsplat::load_gaussian_ply | ( | const std::filesystem::path & | path | ) |
Read back a .ply written by save_gaussian_ply.
| std::vector< TrainingView > reusex::gsplat::load_training_views | ( | const ProjectDB & | db, |
| const TrainingViewOptions & | opt = {} ) |
Load posed training views from a project.
Sensor-frame poses go through the same composition the COLMAP exporter uses: ProjectDB stores pose = T_wb (sensor base in world) and intrinsics carry local_transform = T_bc, so T_wc = T_wb * T_bc and T_cw = (T_wc)^{-1}. Panorama slices use T_w_slice = T_w_pano * [R_pano_from_view | 0].
Frames without a colour image or with degenerate intrinsics are skipped with a debug/warn line rather than silently dropped.
| std::runtime_error | if the project yields no usable view. |
| cv::Mat reusex::gsplat::render_view | ( | const GaussianCloud & | gaussians, |
| const TrainingView & | view ) |
Rasterize gaussians from view.
Returns a BGR8 image the same size as the view, suitable for cv::imwrite. Requires CUDA.
|
inline |
RGB in [0,1] -> degree-0 SH coefficient.
Definition at line 24 of file GaussianCloud.hpp.
References kShC0.
| TrainResult reusex::gsplat::run_gsplat_stage | ( | ProjectDB & | db, |
| const GsplatStageOptions & | opt ) |
Load the seed cloud and views from db, train, and store the splat.
The trained model is written into db under GsplatStageOptions::
splat_name (schema v12), and additionally to out_ply when one is given. Both get the identical bytes, from one call to gaussian_ply_bytes().
db is therefore non-const for two reasons: the splat itself, and the pipeline_log start and finish rows every other create stage writes — rux log is how a user reconstructs what produced a project, and a stage that runs for hours without appearing there is invisible. All project data is read-only.
A run cancelled through TrainOptions::cancel_token still stores its splat — salvaging the model is the entire point of cancelling rather than killing the process — and closes its pipeline_log row as a success carrying a "CANCELLED" note (see the comment at the call site for why not a failure).
| std::runtime_error | if splat_name is empty, if checkpointing is enabled with nowhere to put the files, or if the seed cloud is missing — all before any training happens, because a long run whose output is silently discarded is worse than a refusal. |
| void reusex::gsplat::save_gaussian_ply | ( | const GaussianCloud & | gaussians, |
| const std::filesystem::path & | path ) |
Write the bytes of gaussian_ply_bytes() to path.
|
inline |
Degree-0 SH coefficient -> RGB in [0,1] (not clamped).
Definition at line 27 of file GaussianCloud.hpp.
References kShC0.
| TrainResult reusex::gsplat::train_gaussians | ( | const GaussianCloud & | init, |
| const std::vector< TrainingView > & | views, | ||
| const TrainOptions & | opt = {} ) |
Train Gaussians against posed views.
Requires a CUDA device. All parameters (means, log-scales, quaternions, logit-opacity, SH DC) are optimized jointly with Adam; the photometric loss is L1 + D-SSIM against one randomly drawn view per iteration.
| std::runtime_error | if no CUDA device is available, if views is empty, or if init contains no Gaussians. |
|
inlineconstexpr |
The 3D Gaussian Splatting DC spherical-harmonic basis function value, 0.5 * sqrt(1/pi).
Converting between a linear RGB colour in [0,1] and the degree-0 SH coefficient stored per Gaussian goes through it in both directions (see rgb_to_sh_dc / sh_dc_to_rgb).
Definition at line 21 of file GaussianCloud.hpp.
Referenced by rgb_to_sh_dc(), and sh_dc_to_rgb().