Skip to content

Commit ead370a

Browse files
Deploying to gh-pages from @ ef6bf69 🚀
1 parent c89554b commit ead370a

File tree

170 files changed

+6853
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+6853
-143
lines changed

_images/tools_camera_solver_ui.png

19.5 KB
Loading
6.32 KB
Loading
3.45 KB
Loading
24.5 KB
Loading
6.65 KB
Loading
24 KB
Loading
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. _global-optimization-heading:
2+
3+
Global Optimization
4+
===================
5+
6+
The core :ref:`camera solver <camera-solver-overview-heading>` assumes
7+
known camera intrinsics. When intrinsic parameters such as focal
8+
length are unknown or only approximate, the **Global Optimization**
9+
step wraps the core solver to search for the values that produce the
10+
best reconstruction.
11+
12+
Overview
13+
--------
14+
15+
Global optimization treats the core camera solver as a black box. It
16+
repeatedly runs the full solve pipeline with different candidate
17+
parameter values, searching for the parameters that minimize overall
18+
reprojection error across the entire sequence.
19+
20+
This is computationally expensive -- each evaluation requires a
21+
complete camera solve -- but it allows the solver to recover
22+
parameters that cannot be estimated within the incremental SfM
23+
pipeline itself.
24+
25+
Search Strategies
26+
-----------------
27+
28+
Two search strategies are available:
29+
30+
**Differential Evolution (DE)** -- A population-based evolutionary
31+
optimization algorithm. A population of candidate parameter sets
32+
evolves over multiple generations, with mutation and crossover
33+
operators exploring the search space. Supports coarse-then-refined
34+
passes: a broad initial search narrows the parameter range, followed
35+
by a finer search within the narrowed bounds. This is generally the
36+
preferred strategy for efficiency.
37+
38+
**Uniform Grid Search (UGS)** -- Exhaustive evaluation at regular
39+
intervals across the parameter range. Simpler and easier to reason
40+
about, but slower than Differential Evolution for high-dimensional or
41+
wide-range searches.
42+
43+
Parameters
44+
----------
45+
46+
Currently, the global optimization step supports searching for
47+
**focal length** (applied uniformly across the sequence).
48+
49+
*Further detail on configuration, parameter ranges, and performance
50+
characteristics will be added in future.*
51+
52+
See Also
53+
--------
54+
55+
- :ref:`camera-solver-overview-heading` -- The core camera solver
56+
pipeline that is evaluated at each optimization step.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
.. _camera-solver-overview-heading:
2+
3+
Camera Solver Overview
4+
======================
5+
6+
The camera solver performs **incremental Structure-from-Motion (SfM)**,
7+
reconstructing camera motion and 3D point positions from 2D marker
8+
tracks in an image sequence.
9+
10+
**Input:**
11+
12+
- 2D marker tracks (per-frame screen-space positions).
13+
- Known camera intrinsics (focal length, film back size).
14+
15+
**Output:**
16+
17+
- Per-frame camera poses (rotation and translation).
18+
- 3D bundle positions (world-space coordinates for each tracked marker).
19+
20+
The solver is **deterministic** -- the same input data will always
21+
produce the same output. There is no random seeding or
22+
non-deterministic behaviour.
23+
24+
An optional :ref:`global-optimization-heading` step can wrap the
25+
solver to search for optimal global parameters (such as focal length).
26+
27+
Pipeline Overview
28+
-----------------
29+
30+
The solver runs in six phases:
31+
32+
1. Frame Analysis and Marker Selection
33+
2. Initial Two-Camera Reconstruction
34+
3. Incremental Camera Addition
35+
4. Bundle Validation and Filtering
36+
5. Final Global Bundle Adjustment
37+
6. Origin Frame Transform and Scale
38+
39+
Phase 1: Frame Analysis and Marker Selection
40+
---------------------------------------------
41+
42+
The solver analyzes all frames to select the best markers and frames
43+
for reconstruction, scoring by two criteria:
44+
45+
- **Parallax** -- how much markers move between frames. More motion
46+
provides more information for recovering 3D structure.
47+
48+
- **Uniformity** -- how evenly markers are spread across the image,
49+
measured by dividing the image into a grid and checking the
50+
distribution of points across cells. Well-spread markers give
51+
stronger geometric constraints than clustered ones.
52+
53+
The result is a selected subset of markers and the frames where
54+
those markers are visible.
55+
56+
Phase 2: Initial Two-Camera Reconstruction
57+
-------------------------------------------
58+
59+
A good starting pair is critical -- errors here propagate through
60+
the entire reconstruction.
61+
62+
The solver builds a frame graph evaluating all frame pairs by
63+
parallax and marker overlap, then selects the best pair. The
64+
relative pose between the two cameras is estimated using the
65+
**Essential Matrix** (computed via the 5-point or 8-point algorithm
66+
depending on the number of correspondences), which is decomposed
67+
into candidate rotation and translation solutions. The correct
68+
solution is chosen by triangulating points and verifying they are
69+
in front of both cameras.
70+
71+
Initial 3D points are triangulated using the **optimal angular
72+
method**, and a two-camera **bundle adjustment** refines the result.
73+
74+
Phase 3: Incremental Camera Addition
75+
--------------------------------------
76+
77+
With an initial reconstruction established, the solver adds cameras
78+
incrementally in two passes:
79+
80+
- **Pass 1 (Draft):** Adds skeleton key frames spread across the
81+
sequence, building a stable backbone.
82+
- **Pass 2 (Final):** Fills in all remaining frames.
83+
84+
For each new frame, the solver runs **PnP (Perspective-n-Point)**
85+
using the **SQPnP** algorithm to compute the camera pose from known
86+
3D points, validates the result, and refines with a single-camera
87+
bundle adjustment.
88+
89+
After each round of camera additions, a **global bundle adjustment**
90+
refines all cameras and points together. Additional markers are then
91+
triangulated and added to the reconstruction. Markers that fail
92+
geometric triangulation are placed at the **mean scene depth** as
93+
an initial estimate and refined by subsequent bundle adjustment --
94+
this ensures as many markers as possible contribute to the result.
95+
96+
Phase 4: Bundle Validation and Filtering
97+
-----------------------------------------
98+
99+
The solver validates the reconstruction by filtering out 3D bundles
100+
with high reprojection error or degenerate geometry, and checking for
101+
cameras converging to the same position, indicating a failed solve.
102+
103+
Phase 5: Final Global Bundle Adjustment
104+
----------------------------------------
105+
106+
A final bundle adjustment refines all cameras and 3D points
107+
together. Small noise is added to parameters to help escape local
108+
minima, and remaining markers are retriangulated and included.
109+
110+
Phase 6: Origin Frame Transform and Scale
111+
-------------------------------------------
112+
113+
SfM reconstructions live in an arbitrary coordinate system with no
114+
meaningful relationship to the real-world scene. The solver transforms
115+
the result to align with a user-specified **origin frame** and applies
116+
a **scene scale factor**, so the solved camera output is consistently
117+
scaled for use in MatchMove workflows.
118+
119+
Key Algorithms
120+
--------------
121+
122+
.. list-table::
123+
:header-rows: 1
124+
:widths: 30 70
125+
126+
* - Algorithm
127+
- Purpose
128+
* - Essential Matrix (5-point / 8-point)
129+
- Initial relative pose between two cameras
130+
* - SQPnP
131+
- Camera pose from 3D-2D correspondences
132+
* - Optimal Angular Triangulation
133+
- 3D point estimation from multiple views
134+
* - Depth-based Triangulation
135+
- Fallback for points that fail geometric triangulation
136+
* - Levenberg-Marquardt Bundle Adjustment
137+
- Non-linear refinement of all parameters; dense or sparse
138+
depending on problem size
139+
* - Bundle Validation
140+
- Reprojection error filtering and collapse detection
141+
142+
Bundle Adjustment
143+
-----------------
144+
145+
Bundle adjustment minimizes **reprojection error** -- the distance
146+
between where a 3D point projects into each camera and where the
147+
marker was observed. It jointly optimizes camera poses (rotation and
148+
translation) and 3D point positions using the Levenberg-Marquardt
149+
algorithm, with a dense or sparse solver selected based on problem
150+
size.
151+
152+
See Also
153+
--------
154+
155+
- :ref:`global-optimization-heading` -- Optional focal length
156+
optimization wrapping the core solver.

_sources/commands.rst.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
Commands
22
========
33

4-
Custom commands in `mmSolver` are used to perform many tasks, such as
5-
solving the scene, modifying the scene, or calculating values.
4+
mmSolver provides a set of custom Maya commands (MEL / Python) for
5+
performing solves, querying scene information, processing animation
6+
curves, working with images, and more. These commands are the
7+
low-level building blocks that the high-level Python API and tools
8+
build upon; advanced users can call them directly from scripts.
69

7-
You can see the nodes split into categories below:
10+
Commands are split into the following categories:
811

912
.. toctree::
1013
:maxdepth: 4

_sources/commands_display.rst.txt

Lines changed: 129 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,134 @@
11
Display Commands
22
================
33

4-
*To be written.*
4+
Display commands control mmSolver's custom Viewport 2.0 renderers.
5+
Two renderers are provided — MM Standard Renderer and MM Silhouette
6+
Renderer — each registered as a Viewport 2.0 override and documented
7+
in detail in :ref:`Viewport Renderers <renderer-ref>`.
58

6-
``mmRenderer`` Command
7-
++++++++++++++++++++++
9+
Each renderer exposes a thin Maya command that forces a refresh of the
10+
active 3D view. Settings for the Silhouette Renderer are stored on the
11+
``mmRenderGlobalsSilhouette`` node and adjusted via ``setAttr``.
812

9-
The ``mmRenderer`` command is unfinished and is disabled in the C++
10-
build by default.
13+
14+
``mmRendererStandard`` Command
15+
++++++++++++++++++++++++++++++
16+
17+
``mmRendererStandard`` triggers a forced refresh of the active Viewport
18+
2.0 panel when the MM Standard Renderer is active. It supports
19+
``-query`` mode (no flags beyond enabling query are defined). The
20+
command is not undoable.
21+
22+
See :ref:`renderer-ref` for how to activate and use the MM Standard
23+
Renderer.
24+
25+
Flags
26+
-----
27+
28+
The command accepts ``-query`` mode only. No additional flags are
29+
defined; calling the command refreshes the active view.
30+
31+
Return
32+
------
33+
34+
Returns nothing.
35+
36+
Example
37+
-------
38+
39+
Python Example:
40+
41+
.. code:: python
42+
43+
import maya.cmds
44+
45+
# Force a refresh of the active view.
46+
maya.cmds.mmRendererStandard()
47+
48+
MEL Example:
49+
50+
.. code:: text
51+
52+
mmRendererStandard;
53+
54+
55+
``mmRendererSilhouette`` Command
56+
+++++++++++++++++++++++++++++++++
57+
58+
``mmRendererSilhouette`` triggers a forced refresh of the active
59+
Viewport 2.0 panel when the MM Silhouette Renderer is active. It
60+
supports ``-query`` mode (no flags beyond enabling query are defined).
61+
The command is not undoable.
62+
63+
The silhouette effect is configured through the
64+
``mmRenderGlobalsSilhouette`` node, which is created automatically when
65+
the renderer is first activated. Use ``setAttr`` to change the
66+
settings described below.
67+
68+
See :ref:`renderer-silhouette-ref` for full usage instructions and a
69+
description of each setting.
70+
71+
Flags
72+
-----
73+
74+
The command accepts ``-query`` mode only. No additional flags are
75+
defined; calling the command refreshes the active view.
76+
77+
``mmRenderGlobalsSilhouette`` Node Attributes
78+
---------------------------------------------
79+
80+
The silhouette settings live on the ``mmRenderGlobalsSilhouette`` node.
81+
82+
======================== ========= =============== =========================================================
83+
Attribute Type Default Description
84+
======================== ========= =============== =========================================================
85+
``enable`` bool ``true`` Toggle the silhouette effect on or off.
86+
``overrideColor`` bool ``true`` Use the ``color`` attribute for all objects.
87+
``depthOffset`` float ``-1.0`` Depth separation between solid and wireframe geometry.
88+
``width`` float ``2.0`` Width of silhouette lines.
89+
``color`` float3 ``0, 1, 0`` Silhouette line colour (green by default).
90+
``alpha`` float ``1.0`` Opacity of silhouette lines.
91+
``cullFace`` enum ``Back`` Back-face culling; ``Back``, ``Front``, ``FrontAndBack``.
92+
``operationNum`` uint8 ``255`` (all) Limit rendering to the first N operations (debug).
93+
======================== ========= =============== =========================================================
94+
95+
Return
96+
------
97+
98+
Returns nothing.
99+
100+
Example
101+
-------
102+
103+
Python Example:
104+
105+
.. code:: python
106+
107+
import maya.cmds
108+
109+
# Force a refresh of the active view.
110+
maya.cmds.mmRendererSilhouette()
111+
112+
# Change the silhouette colour to red.
113+
maya.cmds.setAttr('mmRenderGlobalsSilhouette.color', 1, 0, 0, type='double3')
114+
115+
# Increase line width.
116+
maya.cmds.setAttr('mmRenderGlobalsSilhouette.width', 3.0)
117+
118+
# Disable the effect temporarily.
119+
maya.cmds.setAttr('mmRenderGlobalsSilhouette.enable', False)
120+
121+
MEL Example:
122+
123+
.. code:: text
124+
125+
mmRendererSilhouette;
126+
127+
// Change silhouette colour to red.
128+
setAttr mmRenderGlobalsSilhouette.color -type double3 1 0 0;
129+
130+
// Increase line width.
131+
setAttr mmRenderGlobalsSilhouette.width 3.0;
132+
133+
// Disable the effect temporarily.
134+
setAttr mmRenderGlobalsSilhouette.enable false;

0 commit comments

Comments
 (0)