Pool Selection API

The pool-selection contract (best_pool_model, select_on_grid!) and the grid kernels that score a pool's models across a width grid. The scoring and local-optimization contracts it builds on are on the Robust Estimation API page.

VisualGeometryToolkitCore.best_pool_model — Method
best_pool_model(scoring, pair::PoolPair, R; ws, scores) -> Int

The index of the best-scoring stored model of pair under scoring (a scorer at its width), scored on the pair's residual matrix R (num_points(pair) × num_models(pair), the pool frame's units): per model, score! of its residual column with its minimal sample (the model's sample points enter at zero residual, as in every scorer). The FIRST strictly best model wins; a non-finite score never wins; 0 (never a valid index) means no model scores above −Inf. A matrix of another shape is a DimensionMismatch. ws and scores are the scorer's workspace and per-point scratch, allocated for pair when omitted.

source
VisualGeometryToolkitCore.select_on_grid! — Method
select_on_grid!(idxs::AbstractMatrix{Int32}, P, scoring, grid, staged; kw...) -> idxs

The selections of scoring at every width of grid (its native axis, width_axis) over a staged batch of pairs: idxs[p, t] the stored model selected for pair p at grid[t] (0: none). P is the pairs' problem type (a family that carries neither its minimal sample size nor its codimension reads them from it). Further keywords are a family's own (a randomized family's per-(pair, column) generator rng_of) and are ignored by the others. The generic method reads the :pool staging: a loss-width family with a per-residual quality (has_residual_quality) is scored by exact_pm_score_kernel! and selected by argmax_models_kernel! on the staging's backend (per pair, every width in one launch, on sorted_squared_residuals); any other scoring per column by with_width(scoring, axis(grid[t])) then best_pool_model. Either way the FIRST strictly best model wins. A grid family implements its own.

source
VisualGeometryToolkitCore.selection_staging — Method
selection_staging(scoring) -> key

The staging a scoring's grid selection reads (stage_selection): scorings with the same key share ONE staged batch of a group of pairs. Default :pool (the pairs and their residual matrices as they are); a grid family with device kernels declares its own.

source
VisualGeometryToolkitCore.sorted_squared_residuals — Method
sorted_squared_residuals(pair::PoolPair, R) -> Matrix{Float32}

Per stored model of pair (a column), its squared residuals from the residual matrix R (num_points(pair) × num_models(pair)) with the model's minimal sample at zero (as every scorer enters it), sorted ascending: what the exact selection kernels read, and RANSACScoringDoneRight's staging. In the residuals' precision (Float32).

source
VisualGeometryToolkitCore.stage_selection — Method
stage_selection(key, pairs, residuals; backend) -> staged

The staged batch of pairs (light pool records) with their residual matrices for the scorings of staging key (selection_staging), on the compute backend (nothing: the staging's default). The :pool staging is (; pairs, residuals, backend), its backend default_device() unless one is supplied: the device its exact kernels run on.

source
VisualGeometryToolkitCore.argmax_models_kernel! — Method
OnBackend(backend; workgroupsize = 1)(argmax_models_kernel!)(errors_out, idxs_out, scores_pmt, M_per_pair, errors_imc_flat,
                               errors_offset, p_offset; ndrange = (n, T))

Per (pair, width) of a chunk: the FIRST strictly best model of scores_pmt[p, :, t] over the pair's M_per_pair[p] models (1 when none scores above −Inf), its error errors_imc_flat[errors_offset[p] + m] into errors_out[p, t] and, when idxs_out has rows, its index into idxs_out[p, t]. Padded work items exit untouched.

source
VisualGeometryToolkitCore.exact_pm_score_kernel! — Method
OnBackend(backend; workgroupsize = 1)(exact_pm_score_kernel!)(scores_out, sorted_sq_flat, pair_offset, K_per_pair, M_per_pair,
                                loss_widths, T_val, p_offset, scoring, support_sq; ndrange = (n, M_max))

Per (pair, model) of a chunk of n pairs: scores_out[p, m, t] (Float64, (chunk, M_max, T)) the sum of residual_quality(scoring, d², loss_widths[t]) over the model's squared residuals (sorted_sq_flat, ascending, from pair_offset[p], K_per_pair[p] per model), evaluated and accumulated in Float64. A non-finite residual is an outlier (skipped); the loop stops at support_sq (support_sq_loss_width). Chunk row p is pair p + p_offset; a model beyond M_per_pair[p] is left alone. A work item is a loop over the model's residuals: launch it at one item per workgroup through OnBackend, the stack's launch policy (every thread on the CPU, one warp per workgroup on a device).

source
VisualGeometryToolkitCore.support_sq_loss_width — Method
support_sq_loss_width(scoring, max_loss_width) -> Float64

The squared residual from which scoring's quality is exactly 0 at every width up to max_loss_width: max_loss_width² for a family of compact support (RANSAC, MSAC; RANSACScoringDoneRight's MAGSAC++ and smooth TLS), Inf for one that reaches 0 only asymptotically (the default). On sorted residuals the exact kernel stops there.

source

Index