Skip to content

Command Reference

This page shows what sfm --help and each command's --help print in sfmtool 0.4.1. For what a command does in full, see its spec in sfmtool's specs/cli/.

sfm

Usage: sfm [OPTIONS] COMMAND [ARGS]...

  SfM Tool - Fun with Structure from Motion.

Options:
  -h, --help  Show this message and exit.

Workspace Commands:
  camrig          Build .camrig camera rig files.
  extract-frames  Extract the frames of videos into one...
  insv2rig        Extract dual-fisheye frames from an Insta360...
  pano2rig        Convert equirectangular panoramas to...
  ws              Workspace-related operations.

Image Feature Commands:
  cluster-patches  Refine a cluster-bearing .matches file into...
  match            Match features between image pairs and write...
  pick-images      Choose the frames of a video a solve should...
  sift             Extract SIFT features and visualize .sift...

Reconstruction Commands:
  align                Align multiple .sfmr reconstructions.
  analyze              Run a deep-analysis report on a .sfmr...
  compare              Compare two .sfmr files.
  densify              Densify matches in a .sfmr file (experimental).
  embed-patches        Convert a sift_files reconstruction to...
  estimate-intrinsics  Estimate a shared focal length and camera...
  inspect              Inspect an sfmtool file, image, or 3D point...
  merge                Merge multiple aligned .sfmr files.
  motion               Analyze camera motion in image sequences or...
  solve                Run structure from motion on images or a...
  xform                Apply transformations to a .sfmr file.

Visualization Commands:
  epipolar        Visualize epipolar geometry between two...
  explorer        Launch the SfM Explorer 3D viewer.
  heatmap         Visualize reconstruction quality metrics as...
  panorama        Render an equirectangular panorama from a...
  render-patches  Render a reconstruction's oriented patches on...
  web-export      Write a reconstruction as a web page that...

Automation Commands:
  explorer-call  Call one tool on a running SfM Explorer's MCP...

Image Processing Commands:
  flow       Visualize optical flow between two images.
  undistort  Undistort all images in a reconstruction...

COLMAP Interop Commands:
  from-colmap-bin  Convert COLMAP .bin files to a .sfmr file.
  to-colmap-bin    Convert a .sfmr file to COLMAP .bin format.
  to-colmap-db     Create a COLMAP database from a .sfmr or...
  to-nerfstudio    Convert a pinhole .sfmr reconstruction to a...

Other Commands:
  version  Print the version and the facts that decide...

Workspace Commands

sfm camrig

Usage: sfm camrig [OPTIONS] COMMAND [ARGS]...

  Build .camrig camera rig files.

  Use `sfm inspect <FILE.camrig>` to inspect a rig file.

Options:
  -h, --help  Show this message and exit.

Commands:
  cp               Build a .camrig by copying from a .sfmr, .camrig or...
  create           Create a .camrig file for a directory of images.
  spherical-tiles  Build a spherical tile rig and write it to a .camrig...

sfm camrig cp

Usage: sfm camrig cp [OPTIONS] SOURCE OUTPUT_FILE

  Build a .camrig by copying from a .sfmr, .camrig or rig_config.json file.

  SOURCE is a `.sfmr` reconstruction, a `.camrig` file or a workspace's
  `rig_config.json`; OUTPUT_FILE is the `.camrig` to write. A selector chooses
  what to copy: `--rig` (a whole rig, `.sfmr` or `rig_config.json`),
  `--camera` (one camera as a single-sensor rig, `.sfmr` or `.camrig`), or
  `--sensors` (a subset of sensors, `.camrig` only). With no selector, a
  `.sfmr` falls back to its lone rig or lone camera, a `rig_config.json` to
  its lone rig, and a `.camrig` is copied whole.

  A rig of a `rig_config.json` becomes a `.camrig` that groups the same images
  into the same sensors and frames: each sensor's image pattern is derived
  from the image files under its `image_prefix`, and the command fails, naming
  the images, when no pattern can do that. Write OUTPUT_FILE in the folder of
  the `rig_config.json` (or under it, in a folder that holds all the rig's
  images); the patterns are relative to the folder of OUTPUT_FILE.

  Example usage:

      # Harvest refined intrinsics from a solved reconstruction
      sfm camrig cp sfmr/solve_001.sfmr photos.camrig --camera 0
      # Copy a solved rig into a reusable .camrig
      sfm camrig cp sfmr/rig_solve.sfmr studio.camrig --rig 0
      # Take three faces out of a six-face cubemap rig
      sfm camrig cp cubemap.camrig front.camrig --sensors 0-2
      # Convert the rig of a workspace's rig_config.json
      sfm camrig cp rig_config.json rig.camrig

Options:
  -h, --help              Show this message and exit.
  --rig INTEGER RANGE     `.sfmr` or `rig_config.json` source only: index of
                          the rig to copy.  [x>=0]
  --camera INTEGER RANGE  Index into the source's camera pool; copies that one
                          camera as a single-sensor rig.  [x>=0]
  --sensors TEXT          `.camrig` source only: sensor indices to keep, as an
                          integer range expression (e.g. 0-2, 0,2,4).
  --pattern TEXT          Image pattern for the output sensor. Only valid with
                          --camera.
  --name TEXT             Rig name stored in the file (default: the source rig
                          name, then the output file stem).

sfm camrig create

Usage: sfm camrig create [OPTIONS] IMAGE_PATTERN OUTPUT_FILE

  Create a .camrig file for a directory of images.

  Scans the images matched by IMAGE_PATTERN — a .camrig image pattern (globs
  and/or %d-style frame fields) resolved relative to the OUTPUT_FILE directory
  and stored verbatim in the rig — and writes a one-camera .camrig. Intrinsics
  come from pycolmap EXIF inference unless overridden. The command fails if
  the matched images are inconsistent (mixed resolutions, mixed inferred
  models, varying focal lengths) so the caller can narrow the pattern and
  build separate rigs.

  Example usage:

      sfm camrig create 'images/*' my_images.camrig

      sfm camrig create '*.jpg' rig.camrig --camera-model OPENCV \
      --resolution 4000x3000 \         --params
      2800,2800,2000,1500,-0.08,0.01,0,0

Options:
  -h, --help                      Show this message and exit.
  --camera-model [pinhole|simple_pinhole|simple_radial|radial|opencv|opencv_fisheye|full_opencv|simple_radial_fisheye|radial_fisheye|thin_prism_fisheye|rad_tan_thin_prism_fisheye]
                                  COLMAP camera model. Overrides the EXIF-
                                  inferred model; required when --params is
                                  used.
  --resolution TEXT               Image resolution as WIDTHxHEIGHT (e.g.
                                  4000x3000). Every matched image must have
                                  this resolution.
  --focal-length FLOAT            Focal length in pixels; sets both fx and fy.
  --focal-length-x FLOAT          Focal length fx in pixels.
  --focal-length-y FLOAT          Focal length fy in pixels.
  --principal-point-x FLOAT       Principal point cx in pixels.
  --principal-point-y FLOAT       Principal point cy in pixels.
  --params TEXT                   Full camera parameter list in COLMAP order,
                                  comma-separated (e.g. 1400,1400,960,540).
                                  Requires --camera-model.
  --name TEXT                     Rig name stored in the file (default: the
                                  output file stem).

sfm camrig spherical-tiles

Usage: sfm camrig spherical-tiles [OPTIONS] OUTPUT_FILE

  Build a spherical tile rig and write it to a .camrig file.

  Discretises the sphere into N co-centric pinhole tiles and stores the rig as
  OUTPUT_FILE. The tile look directions come from a relaxed sphere-point set;
  pass --seed for a reproducible layout.

  Example usage:

      sfm camrig spherical-tiles tiles.camrig --n 1280 --equirect-width 1024

      sfm camrig spherical-tiles tiles.camrig --n 320 --arc-per-pixel 0.012 \
      --overlap-factor 1.2 --seed 42

Options:
  -h, --help                Show this message and exit.
  --n INTEGER               Number of tiles in the rig (>= 2).  [required]
  --equirect-width INTEGER  Target equirectangular width in pixels; sets the
                            per-tile pixel size to 2*pi / width. Mutually
                            exclusive with --arc-per-pixel.
  --arc-per-pixel FLOAT     Angular size of one tile pixel, in radians.
                            Mutually exclusive with --equirect-width.
  --overlap-factor FLOAT    Tile FOV safety margin over the worst-case gap
                            between tiles.  [default: 1.15]
  --centre FLOAT...         Rig optical centre in world space (three floats: x
                            y z).  [default: 0.0, 0.0, 0.0]
  --atlas-cols INTEGER      Atlas column count (default: ceil(sqrt(n))).
  --seed INTEGER            Relaxer seed for reproducible tile placement.
  --name TEXT               Rig name stored in the file (default: the output
                            file stem).

sfm extract-frames

Usage: sfm extract-frames [OPTIONS] VIDEOS...

  Extract the frames of videos into one numbered JPEG sequence per video.

  Each VIDEO becomes the directory OUTPUT/<name>/, <name> being the video's
  file name without its extension, holding frame_000001.jpg, frame_000002.jpg,
  ... in presentation order and a video-frames.json record of each frame's
  time in the video. ffmpeg 5.1 or newer and ffprobe must be on PATH. Frames
  are upright (the video's rotation metadata is applied), and a variable frame
  rate is sampled without duplicating frames. HDR video (HLG or PQ) is
  converted to sRGB by one fixed recipe, the same for every pixel of every
  frame.

  Every input is checked before anything is created: an Insta360 .insv file
  (use `sfm insv2rig`), an image, a file that is not a video, an HDR video
  tagged other than BT.2020 narrow range, two videos whose names differ only
  in letter case or extension, and a frame directory that exists and is not
  empty are refused.

  Example usage:

      sfm extract-frames walk1.mp4 walk2.MOV -o captures/garden

      sfm extract-frames orbit.mov -o frames --fps full --max-frame-size full

Options:
  -h, --help                Show this message and exit.
  -o, --output DIRECTORY    The directory the frame directories go in, one per
                            video, named after the video. Created when
                            missing; it need not be in a workspace.
                            [required]
  --fps N|FULL              Frames per second of video time to keep, or `full`
                            for every frame.  [default: 10]
  --max-frame-size PX|FULL  The largest long side of a written frame, in
                            pixels (at least 64). A larger frame is scaled
                            down, a smaller one is never scaled up; `full`
                            writes every frame at the video's size.  [default:
                            1920]
  --hdr-exposure STOPS      The exposure change, in stops, of every HDR
                            video's frames: their light is multiplied by
                            2^STOPS before the highlight roll-off. The same
                            for every frame and recorded. [default: 0; only
                            with an HDR video]

sfm insv2rig

Usage: sfm insv2rig [OPTIONS] INPUT_FILE

  Extract dual-fisheye frames from an Insta360 .insv video file.

  Reads an Insta360 .insv video file and extracts every frame as a pair of
  fisheye images (left and right), then writes a .camrig file describing the
  back-to-back fisheye rig.

  The output directory must be inside an initialized workspace (via 'sfm ws
  init').

  Example usage:

      sfm ws init my_workspace/     sfm insv2rig video.insv -o
      my_workspace/images/seq1

Options:
  -h, --help         Show this message and exit.
  -o, --output PATH  Output directory for fisheye images (inside a workspace).
                     [required]

sfm pano2rig

Usage: sfm pano2rig [OPTIONS] INPUT_DIR

  Convert equirectangular panoramas to perspective face images for rig-aware
  SfM.

  Reads equirectangular (360) panorama images from INPUT_DIR and generates
  perspective face images under the OUTPUT directory, then writes a .camrig
  file describing the six-face cubemap rig.

  Generates a standard 6-face cubemap (front, right, back, left, top, bottom)
  with 90-degree FOV. Face images are written to <output>/front/,
  <output>/right/, etc.

  The output directory must be inside an initialized workspace (via 'sfm ws
  init').

  Example usage:

      sfm ws init my_workspace/     sfm pano2rig panoramas/ -o
      my_workspace/images

      sfm ws init my_workspace/     sfm pano2rig panoramas/ -o
      my_workspace/images --face-size 1024

Options:
  -h, --help                    Show this message and exit.
  -o, --output PATH             Output directory for face images (inside a
                                workspace).  [required]
  --face-size INTEGER           Face image size in pixels (default: pano_width
                                / 4).
  --jpeg-quality INTEGER RANGE  JPEG quality for output face images (1-100,
                                default: 95).  [1<=x<=100]

sfm ws

Usage: sfm ws [OPTIONS] COMMAND [ARGS]...

  Workspace-related operations.

Options:
  -h, --help  Show this message and exit.

Commands:
  init     Initialize a workspace with configuration.
  upgrade  Bring a workspace and every file in it to the current file...

sfm ws init

Usage: sfm ws init [OPTIONS] [WORKSPACE_DIR]

  Initialize a workspace with configuration.

  Creates a .sfm-workspace.json file in the specified directory (or current
  directory if not specified) with default feature extraction settings.

  Example usage:

      sfm ws init

      sfm ws init my_workspace

      sfm ws init --feature-tool opencv opencv_workspace

      sfm ws init --dsp dsp_workspace

      sfm ws init --image-to-gray G --quantize-bits 8 green_workspace

Options:
  -h, --help                      Show this message and exit.
  --feature-tool [colmap|opencv|sfmtool]
                                  Feature extraction tool: sfmtool (default),
                                  colmap, or opencv.
  --dsp / --no-dsp                Enable/disable domain size pooling (COLMAP
                                  only, default: disabled).
  --max-features INTEGER          Maximum features per image (COLMAP and
                                  sfmtool, default: 8192).
  --gpu / --no-gpu                Enable/disable GPU acceleration for SIFT
                                  extraction (COLMAP only, default: enabled).
  --affine-shape / --no-affine-shape
                                  Enable/disable affine shape estimation for
                                  SIFT (COLMAP only, default: disabled).
                                  Incompatible with GPU — use --no-gpu with
                                  --affine-shape.
  --image-to-gray FORMULA         The formula over R, G and B that converts an
                                  image to grey (sfmtool only, default:
                                  0.2126*R + 0.7152*G + 0.0722*B).
  --quantize-bits B               Round the grey conversion's value to B bits,
                                  1 to 16 (sfmtool only, default: no
                                  rounding).
  -f, --force                     Allow creating a workspace even if it's
                                  nested or already exists.

sfm ws upgrade

Usage: sfm ws upgrade [OPTIONS] [PATH]

  Bring a workspace and every file in it to the current file versions.

  Back up the workspace first: the command rewrites .sfmr, .matches and
  .camrig files in place and deletes the old features folders, so it cannot be
  undone.

  The workspace is found from PATH (or the current directory) by the upward
  search for .sfm-workspace.json, and the run upgrades the whole tree of
  workspaces it belongs to, so PATH must be in the outermost one. Version 1
  .sift files are converted to version 2 in new features folders, without
  extracting them again; each .sfmr and .matches file that names an old
  folder, or is older than the current version, is rewritten at its own path;
  a version 1 .camrig file is rewritten as version 2; a .kdf index built from
  an old folder is deleted; each version 1 workspace file is rewritten as
  version 2, keeping every option; and the old features folders are deleted. A
  file the current reader refuses is left as it is, and so are the folders it
  names. A run that stops part way, by Ctrl+C or a failed file, can be run
  again to finish.

  Example usage:

      sfm ws upgrade --dry-run

      sfm ws upgrade my_workspace

Options:
  -h, --help  Show this message and exit.
  --dry-run   Find the files and print what the upgrade would do, writing
              nothing.

Image Feature Commands

sfm cluster-patches

Usage: sfm cluster-patches [OPTIONS]

  Refine a cluster-bearing .matches file into patch clusters.

  Per cluster: exclude members whose own patch does not pin a position, pick a
  reference member (largest SIFT scale), refine a Gaussian-windowed-ZNCC
  affine warp from the reference's patch to every other member (seeded from
  the SIFT affine shapes, at the best-scoring of --rotation-starts rotations
  of that seed), vet members by achieved ZNCC and translation drift, read each
  surviving member's own patch again at its refined shape and refuse those
  that do not pin a position there as a whole or have too many cells that do
  not, and keep at most one member per image. With --piecewise, every kept
  member's patch is then cut into nine cells that are registered separately
  against the member's image, an affine map fitted to their shifts updates the
  member's shape where the whole-patch ZNCC does not fall, and each cell's
  displacement, ZNCC and status are stored beside the member. Each member is
  stored fully absolute — its affine SHAPE (the refined warp composed onto the
  reference feature's detector shape) plus its refined keypoint position — so
  a consumer reads a member's extent and position with no .sift lookup. Writes
  a NEW .matches file that copies the input's images and clusters sections and
  adds the cluster_patches enrichment (write-once workflow, like adding two-
  view geometries).

  Example:
      sfm cluster-patches -i matches/clusters.matches

Options:
  -h, --help                      Show this message and exit.
  -i, --input FILE                Cluster-bearing .matches file (from sfm
                                  match --cluster).  [required]
  -o, --output FILE               Output .matches path (default: the input
                                  with a -patches suffix).
  --patch-size FLOAT RANGE        Full edge length of the template each member
                                  is compared over, in keypoint-frame units. A
                                  larger template compares members over more
                                  of the texture around the feature.
                                  [default: 12.0; x>0.0]
  --resolution INTEGER RANGE      Template samples per axis.  [default: 25;
                                  x>=3]
  --min-zncc FLOAT RANGE          Member acceptance threshold on the achieved
                                  windowed ZNCC.  [default: 0.85;
                                  -1.0<=x<=1.0]
  --max-shift-scales FLOAT RANGE  Refuse a member (rejected_shift) whose
                                  refined position moved further from its SIFT
                                  detection than this many times its refined
                                  scale, the square root of the refined affine
                                  shape's determinant (source px).  [default:
                                  2.0; x>=0.0]
  --max-member-zncc-self-similarity-radius FLOAT RANGE
                                  Exclude cluster members whose own patch does
                                  not pin a 2D position, before reference
                                  selection and refinement: the member's ZNCC
                                  self-similarity radius, how far its
                                  template-grid patch can slide over itself
                                  and still match itself as well as a true
                                  match between two views would, is above this
                                  bar (template-grid px). Flat and edge-only
                                  patches read 3, the largest radius, so a bar
                                  of 3 or more turns nothing out; `0` disables
                                  the gate. See specs/core/patch/zncc-self-
                                  similarity-radius.md.  [default: 2.5;
                                  x>=0.0]
  --regate-at-refined-shape / --no-regate-at-refined-shape
                                  Read the member gate again, with the same
                                  bar, on each member's own patch at its
                                  refined shape and position (after
                                  --piecewise, where that moved it), for every
                                  member that passes the ZNCC and shift gates,
                                  and mark a member over the bar there
                                  rejected_unlocalizable_refined. See
                                  specs/core/patch/cluster-patch-
                                  refinement.md.  [default: regate-at-refined-
                                  shape]
  --max-capped-cells INTEGER RANGE
                                  The most of the nine cells of a member's own
                                  patch at its refined shape that may read the
                                  largest ZNCC self-similarity radius (3, '3
                                  or further'); a member with more is marked
                                  rejected_unlocalizable_cells. 9 turns
                                  nothing out.  [default: 8; 0<=x<=9]
  --rotation-starts INTEGER RANGE
                                  Before the affine fit, score the reference's
                                  patch against each member at this many
                                  rotations of its SIFT seed, evenly spaced
                                  over a full turn with the seed's own
                                  rotation first, and start the fit from the
                                  best-scoring one. The two SIFT orientations
                                  can disagree across a scale change, and the
                                  fit cannot turn far from where it starts. 1
                                  starts only from the SIFT seed. See
                                  specs/core/patch/cluster-patch-
                                  refinement.md.  [default: 12; x>=1]
  --piecewise / --no-piecewise    After the affine fit, register each of the
                                  reference's nine cells separately against
                                  each kept member's image, starting at the
                                  member's fitted shape, and store each cell's
                                  displacement, ZNCC and status in the output
                                  (format version 8 per-cell columns). An
                                  affine map fitted to the cells' shifts
                                  updates the member's shape and position
                                  wherever the whole-patch ZNCC does not fall.
                                  See specs/core/patch/cluster-patch-
                                  refinement.md.  [default: no-piecewise]

sfm match

Usage: sfm match [OPTIONS] [PATHS]...

  Match features between image pairs and write a .matches file.

  Requires a workspace initialized with 'sfm ws init' and SIFT features
  extracted with 'sfm sift --extract'.

  Examples:     # Exhaustive matching     sfm match --exhaustive images/

      # Sequential matching for ordered collections     sfm match --sequential
      images/

      # Flow-based matching for sequential video     sfm match --flow images/

      # Background-floor track-cluster matching (writes the clusters     #
      .matches, deterministically; no COLMAP involved)     sfm match --cluster
      images/

      # Derive the verified pairwise+TVG .matches COLMAP's mapper needs
      sfm match --derive-pairs matches/my-clusters.matches

      # With feature count limit     sfm match --exhaustive --max-features
      4096 images/

      # Merge matches from different methods     sfm match --merge seq.matches
      exhaustive.matches -o combined.matches

Options:
  -h, --help                      Show this message and exit.
  -e, --exhaustive                Run exhaustive pairwise matching.
  --max-features INTEGER RANGE    Maximum number of features to use from each
                                  image.  [x>=1]
  -o, --output PATH               Output .matches file path. If not specified,
                                  generates a timestamped filename.
  -r, --range RANGE|NAME          A range expression of file numbers to use
                                  from the input directories. A range is file
                                  numbers and spans separated by commas, and a
                                  span may take a step after a ':', as in '7',
                                  '1-100', '1-10,20,30-40' or '1-100:10'
                                  (every 10th number from 1 to 100). A value
                                  with a letter in it is instead the name of a
                                  named image list of the workspace (see
                                  --named-image-list); give one name and one
                                  range, as two -r options, to keep the list's
                                  members whose frame number is in the range.
                                  A slice after the name, quoted, takes part
                                  of the list by position, as for a Python
                                  list: 'NAME[:30]' is its first 30 images,
                                  'NAME[-30:]' its last 30 and 'NAME[::3]'
                                  every third one.
  --named-image-list NAME         Use the images of this named image list,
                                  defined in the workspace's .sfm-named-image-
                                  lists.json, in place of image paths. The
                                  workspace is found from the current
                                  directory. With -r RANGE, keep only the
                                  members whose frame number is in RANGE. A
                                  slice after the name, such as 'NAME[:30]',
                                  then takes part of the list's images by
                                  position.
  -s, --sequential                Run sequential matching (pairs nearby images
                                  in sequence order). Best for ordered image
                                  collections with known capture order.
  --sequential-overlap INTEGER RANGE
                                  Number of overlapping image pairs for
                                  --sequential. Default: 10.  [x>=1]
  --flow                          Use optical flow-based matching instead of
                                  exhaustive descriptor matching. Best for
                                  sequential video frames with small inter-
                                  frame motion.
  --flow-preset [fast|default|high_quality]
                                  Optical flow quality preset for --flow.
                                  Default: default.
  --flow-skip INTEGER RANGE       Sliding window size for --flow. 1 = adjacent
                                  pairs only. Default: 5.  [x>=1]
  --cluster                       Use the background-floor track-cluster
                                  matcher: cluster all images' descriptors at
                                  once instead of matching image pairs.
  --cluster-alpha FLOAT RANGE     Background-floor radius multiplier for
                                  --cluster. Default: 0.8.  [x>0.0]
  --cluster-d INTEGER RANGE       Background rank for --cluster: the d-th-
                                  nearest distance sets the floor. Default:
                                  10.  [x>=1]
  --cluster-preset [accurate|balanced|fast]
                                  Kd-tree forest preset for --cluster.
                                  Default: accurate.
  --derive-pairs                  Derive the verified pairwise + two-view-
                                  geometry .matches from a clusters-bearing
                                  .matches file (written by --cluster). PATHS
                                  is that one file. This is the artifact
                                  COLMAP's mapper needs; nothing in sfmtool's
                                  own pipeline reads two-view geometries.
  --camera-model [pinhole|simple_pinhole|simple_radial|radial|opencv|opencv_fisheye|full_opencv|simple_radial_fisheye|radial_fisheye|thin_prism_fisheye|rad_tan_thin_prism_fisheye]
                                  Camera model to use: overrides auto-
                                  detection, and refits to this model the
                                  cameras a .camrig or camera_config.json
                                  supplies.
  --merge                         Merge multiple .matches files into one.
                                  PATHS should be .matches files instead of
                                  image directories.

sfm pick-images

Usage: sfm pick-images [OPTIONS] [PATHS]...

  Choose the frames of a video a solve should use, and write them as a named
  image list.

  Walks each sequence from its first frame, choosing frames about --target-
  step percent of the image's long side apart, with no step past the next
  frame keeping fewer than --min-step-matches mutual matches, and a frame
  blurred against its neighbours swapped for a sharper one. Where the steps
  chosen show a near foreground in front of a distant view, the local density
  term shortens the target by up to --max-density-gain times, measuring with
  the camera of the .camrig that covers the frames, or, with no .camrig, with
  the camera a focal vote finds on the first 30 frames chosen without the
  term, as `sfm estimate-intrinsics` finds it on a cluster match of them; the
  vote writes nothing. Each frame read, or predicted to be read, gets a .sift
  file, extracted with the workspace's settings; with a feature tool other
  than sfmtool, every input frame is extracted first. With --write-list NAME
  the chosen frames are written as the named image list NAME, for `sfm solve
  -r NAME`.

  With --new-workspace DIR, PATHS are videos: the command creates a workspace
  at DIR with the workspace options, as `sfm ws init DIR` does, extracts each
  video into DIR/<name>/ as `sfm extract-frames -o DIR` does, and chooses from
  the frames; every input is checked before anything is created. --prune-
  images then deletes the frames not chosen.

  Example usage:

      sfm pick-images frames/ --write-list walk1

      sfm pick-images --new-workspace garden walk.mp4 --write-list picked

Options:
  -h, --help                      Show this message and exit.
  --new-workspace DIR             Create a workspace at DIR, which must be
                                  missing or empty and not inside a workspace,
                                  extract the videos given as PATHS into it,
                                  one frame directory DIR/<name>/ per video as
                                  `sfm extract-frames` writes them, and choose
                                  from their frames.
  --fps N|FULL                    Frames per second of video time to extract,
                                  or `full` for every frame. Only with --new-
                                  workspace.  [default: 10]
  --max-frame-size PX|FULL        The largest long side of an extracted frame,
                                  in pixels (at least 64), or `full` for the
                                  video's size. Only with --new-workspace.
                                  [default: 1920]
  --hdr-exposure STOPS            The exposure change, in stops, of every HDR
                                  video's frames, as `sfm extract-frames
                                  --hdr-exposure` sets it. [default: 0] Only
                                  with --new-workspace and an HDR video.
  --prune-images                  After the list and the JSON file are
                                  written, delete the extracted frames not
                                  chosen, those -r left out included, and
                                  their .sift files. Only with --new-
                                  workspace.
  --feature-tool [colmap|opencv|sfmtool]
                                  Feature extraction tool: sfmtool (default),
                                  colmap, or opencv. The workspace's setting;
                                  only with --new-workspace.
  --dsp / --no-dsp                Enable/disable domain size pooling (COLMAP
                                  only, default: disabled). The workspace's
                                  setting; only with --new-workspace.
  --max-features INTEGER          Maximum features per image (COLMAP and
                                  sfmtool, default: 8192). The workspace's
                                  setting; only with --new-workspace.
  --gpu / --no-gpu                Enable/disable GPU acceleration for SIFT
                                  extraction (COLMAP only, default: enabled).
                                  The workspace's setting; only with --new-
                                  workspace.
  --affine-shape / --no-affine-shape
                                  Enable/disable affine shape estimation for
                                  SIFT (COLMAP only, default: disabled).
                                  Incompatible with GPU — use --no-gpu with
                                  --affine-shape. The workspace's setting;
                                  only with --new-workspace.
  --image-to-gray FORMULA         The formula over R, G and B that converts an
                                  image to grey (sfmtool only, default:
                                  0.2126*R + 0.7152*G + 0.0722*B). The
                                  workspace's setting; only with --new-
                                  workspace.
  --quantize-bits B               Round the grey conversion's value to B bits,
                                  1 to 16 (sfmtool only, default: no
                                  rounding). The workspace's setting; only
                                  with --new-workspace.
  --write-list NAME               Write the chosen frames as the named image
                                  list NAME in the workspace's .sfm-named-
                                  image-lists.json. Without it the command
                                  only reports.
  --force                         Replace the list NAME if the workspace
                                  already defines one.
  -r, --range RANGE|NAME          A range expression of file numbers to choose
                                  from in the input directories. A range is
                                  file numbers and spans separated by commas,
                                  and a span may take a step after a ':', as
                                  in '7', '1-100', '1-10,20,30-40' or
                                  '1-100:10' (every 10th number from 1 to
                                  100). A value with a letter in it is instead
                                  the name of a named image list of the
                                  workspace (see --named-image-list); give one
                                  name and one range, as two -r options, to
                                  keep the list's members whose frame number
                                  is in the range. A slice after the name,
                                  quoted, takes part of the list by position,
                                  as for a Python list: 'NAME[:30]' is its
                                  first 30 images, 'NAME[-30:]' its last 30
                                  and 'NAME[::3]' every third one.
  --named-image-list NAME         Use the images of this named image list,
                                  defined in the workspace's .sfm-named-image-
                                  lists.json, in place of image paths. The
                                  workspace is found from the current
                                  directory. With -r RANGE, keep only the
                                  members whose frame number is in RANGE. A
                                  slice after the name, such as 'NAME[:30]',
                                  then takes part of the list's images by
                                  position.
  --target-step PERCENT           The base target: the step to aim for between
                                  two chosen frames, the median displacement
                                  of their matched features in percent of the
                                  image's long side, before the local density
                                  term divides it by its gain.  [default:
                                  10.0]
  --max-density-gain GAIN         The most the local density term divides the
                                  base target by, where the steps chosen show
                                  a near foreground in front of a distant
                                  view. The term measures with the camera of
                                  the .camrig that covers a sequence's frames,
                                  or, with none, of a pilot focal vote on the
                                  sequence's first 30 chosen frames; 1 turns
                                  it off and runs no pilot.  [default: 3.0]
  --step-band FRACTION            How far a step may be from the target and
                                  still be accepted: within target x (1 +/-
                                  FRACTION).  [default: 0.3]
  --neighbour-blur-ratio RATIO    A frame about to be chosen is blurred
                                  against its neighbours, and swapped for a
                                  sharper one, when its sharpness is below
                                  RATIO times the sharpest of the frames up to
                                  2 positions away.  [default: 0.85]
  --min-step-matches N            The match floor: a step past the next frame
                                  keeps at least N mutual matches. The step to
                                  the next frame is always taken, so a capture
                                  whose neighbouring frames match with fewer
                                  keeps every frame.  [default: 600; x>=1]
  --json FILE                     Also write the whole report, every frame
                                  read and pair matched, to this JSON file.

sfm sift

Usage: sfm sift [OPTIONS] [PATHS]...

  Extract SIFT features and visualize .sift feature files.

  Use `sfm inspect <FILE.sift>` to inspect a feature file.

Options:
  -h, --help                      Show this message and exit.
  -e, --extract                   Extract features from the specified image
                                  files.
  -d, --draw PATH                 Draw SIFT features with ellipses on images
                                  and save to this directory.
  --filter-sfm PATH               Only draw features used in this .sfmr
                                  reconstruction file (only with --draw).
  -r, --range RANGE|NAME          A range expression of file numbers to use
                                  from the input directories. A range is file
                                  numbers and spans separated by commas, and a
                                  span may take a step after a ':', as in '7',
                                  '1-100', '1-10,20,30-40' or '1-100:10'
                                  (every 10th number from 1 to 100). A value
                                  with a letter in it is instead the name of a
                                  named image list of the workspace (see
                                  --named-image-list); give one name and one
                                  range, as two -r options, to keep the list's
                                  members whose frame number is in the range.
                                  A slice after the name, quoted, takes part
                                  of the list by position, as for a Python
                                  list: 'NAME[:30]' is its first 30 images,
                                  'NAME[-30:]' its last 30 and 'NAME[::3]'
                                  every third one.
  --named-image-list NAME         Use the images of this named image list,
                                  defined in the workspace's .sfm-named-image-
                                  lists.json, in place of image paths. The
                                  workspace is found from the current
                                  directory. With -r RANGE, keep only the
                                  members whose frame number is in RANGE. A
                                  slice after the name, such as 'NAME[:30]',
                                  then takes part of the list's images by
                                  position.
  -t, --num-threads INTEGER       Number of threads for feature extraction
                                  (default: -1 uses all available cores)
  --tool [colmap|opencv|sfmtool]  Feature extraction tool. If not specified,
                                  uses workspace configuration.
  --dsp / --no-dsp                Enable/disable domain size pooling (requires
                                  --tool colmap; default: disabled). In
                                  workspace mode, DSP comes from the workspace
                                  configuration.

Reconstruction Commands

sfm align

Usage: sfm align [OPTIONS] REFERENCE_SFMR ALIGN_SFMR_PATHS...

  Align multiple .sfmr reconstructions.

  This command aligns ALIGN_SFMR files to the REFERENCE_SFMR coordinate frame.
  The reference file and all aligned files are saved to OUTPUT_DIR.

  Two alignment methods are available: - points (default): Aligns using
  corresponding 3D points found via shared features.   Uses RANSAC by default
  to reject outlier correspondences.

  - cameras: Aligns using matched camera positions and orientations.

  REFERENCE_SFMR is the reconstruction that defines the reference coordinate
  frame. ALIGN_SFMR_PATHS are the reconstructions to align to the reference
  frame.

  All files must be .sfmr files.

  If any reconstruction cannot be aligned, the command names it with the
  reason and exits with status 1; the reference and the reconstructions that
  were aligned are still saved.

  Examples:

      sfm align reference.sfmr recon1.sfmr -o aligned/

      sfm align reference.sfmr recon1.sfmr -o aligned/ --method cameras

      sfm align reference.sfmr recon1.sfmr -o aligned/ --no-ransac

Options:
  -h, --help                      Show this message and exit.
  -o, --output-dir DIRECTORY      Output directory for aligned reconstructions
                                  (required)  [required]
  --method [cameras|points]       Alignment method: points (default) uses
                                  corresponding 3D points, cameras uses camera
                                  poses
  --confidence FLOAT RANGE        Confidence threshold for image matches
                                  (camera method only, default: 0.7)
                                  [0.0<=x<=1.0]
  --ransac / --no-ransac          Enable/disable RANSAC outlier rejection for
                                  point-based alignment (default: enabled)
  --ransac-percentile FLOAT RANGE
                                  Percentile of correspondence distances to
                                  use as RANSAC threshold (default: 95.0).
                                  [0.0<=x<=100.0]
  --ransac-iterations INTEGER RANGE
                                  Number of RANSAC iterations for point-based
                                  alignment (default: 1000)  [x>=1]

sfm analyze

Usage: sfm analyze [OPTIONS] RECONSTRUCTION_PATH

  Run a deep-analysis report on a .sfmr reconstruction.

  Exactly one analysis mode must be selected. For a quick summary of any
  sfmtool file, use `sfm inspect` instead.

  With --coviz, constructs and prints the covisibility graph showing which
  images share 3D points and how many points they share.

  With --z-range, prints per-image Z depth ranges and histograms from the
  depth statistics stored in the .sfmr file.

  With --frustum, constructs and prints the frustum intersection graph showing
  which camera frustums overlap and their estimated intersection volumes.

  With --images, prints a detailed per-image connectivity table showing for
  each image: number of observations, distances to other cameras, closest
  images by shared observations, and graph connectivity metrics.

  With --metrics, prints per-image metrics analysis showing reprojection error
  breakdown (mean, median, max), observation count, and mean track length for
  each image.

  With --depth-reliability, prints per-point triangulation conditioning: the
  inverse-depth z-score (depth / sigma, low => near-infinity) and the normal-
  matrix condition number, summarised across the finite points. It then
  reports the point-or-bearing likelihood-ratio test: the measured
  reprojection noise it weights rays by, its depth score over finite points
  and points at infinity, and the points whose verdict disagrees with how they
  are stored. --sigma-px and --depth-likelihood-ratio-threshold override the
  test's noise level and threshold.

  RECONSTRUCTION_PATH must be a .sfmr file.

  Examples:

      sfm analyze reconstruction.sfmr --coviz

      sfm analyze reconstruction.sfmr --z-range

      sfm analyze reconstruction.sfmr --frustum

      sfm analyze reconstruction.sfmr --frustum --near-percentile 10 --far-
      percentile 90

      sfm analyze reconstruction.sfmr --images

      sfm analyze reconstruction.sfmr --metrics

      sfm analyze reconstruction.sfmr --metrics --range 1-10

      sfm analyze reconstruction.sfmr --depth-reliability

      sfm analyze reconstruction.sfmr --depth-reliability --sigma-px 0.5

Options:
  -h, --help                      Show this message and exit.
  --coviz                         Construct and print the covisibility graph.
  --z-range                       Print per-image Z depth ranges and
                                  histograms from stored depth statistics.
  --frustum                       Construct and print the frustum intersection
                                  graph.
  --images                        Print per-image connectivity information
                                  table.
  --metrics                       Print per-image metrics analysis
                                  (reprojection error breakdown).
  --depth-reliability             Print per-point triangulation conditioning
                                  (inverse-depth z-score, condition number)
                                  and the point-or-bearing likelihood-ratio
                                  test, with the points whose verdict
                                  disagrees with how they are stored.
  --sigma-px FLOAT RANGE          Per-axis pixel noise the point-or-bearing
                                  test weights its rays by (default: the
                                  reconstruction's measured reprojection
                                  noise). Only with --depth-reliability.
                                  [x>0.0]
  --depth-likelihood-ratio-threshold FLOAT RANGE
                                  The threshold the point-or-bearing test's
                                  verdict applies (default: 25): a point is
                                  finite when its bearing cost and either its
                                  depth score or its midpoint bound reach it.
                                  Only with --depth-reliability.  [x>=0.0]
  -r, --range RANGE|NAME          Range expression of file numbers to include.
                                  Only with --metrics. A range is file numbers
                                  and spans separated by commas, and a span
                                  may take a step after a ':', as in '7',
                                  '1-100', '1-10,20,30-40' or '1-100:10'
                                  (every 10th number from 1 to 100). A value
                                  with a letter in it is instead the name of a
                                  named image list of the workspace (see
                                  --named-image-list); give one name and one
                                  range, as two -r options, to keep the list's
                                  members whose frame number is in the range.
                                  A slice after the name, quoted, takes part
                                  of the list by position, as for a Python
                                  list: 'NAME[:30]' is its first 30 images,
                                  'NAME[-30:]' its last 30 and 'NAME[::3]'
                                  every third one.
  --named-image-list NAME         Use only the reconstruction's images that
                                  are members of this named image list,
                                  defined in the .sfm-named-image-lists.json
                                  of the reconstruction's workspace. With -r
                                  RANGE, keep only the members whose frame
                                  number is in RANGE. A slice after the name,
                                  such as 'NAME[:30]', then takes part of the
                                  members the reconstruction holds by
                                  position.
  --near-percentile FLOAT RANGE   Percentile for near Z plane (default: 5.0).
                                  [0.0<=x<=100.0]
  --far-percentile FLOAT RANGE    Percentile for far Z plane (default: 95.0).
                                  [0.0<=x<=100.0]
  --samples INTEGER RANGE         Number of Monte Carlo samples per frustum
                                  pair (default: 100).  [x>=100]

sfm compare

Usage: sfm compare [OPTIONS] RECONSTRUCTION1 RECONSTRUCTION2

  Compare two .sfmr files.

  This command compares two .sfmr files by: - Aligning them and reporting the
  transformation - Comparing camera intrinsics - Comparing images and their
  extrinsics - Decomposing the shared cameras into internally-rigid fragments
  - Comparing feature usage for matching images - Comparing corresponding 3D
  points

  The fragment decomposition detects solves whose cameras form several
  internally-consistent groups at different scales/orientations (which a
  single alignment papers over), plus individually misplaced frames. It is
  printed when it finds anything beyond one clean component; --fragments
  prints it always.

  RECONSTRUCTION1 and RECONSTRUCTION2 must be .sfmr files. RECONSTRUCTION1
  will be used as the reference for alignment.

  Corresponding 3D points are matched either by feature index (the default
  when both reconstructions share their .sift files) or by 2D keypoint
  coordinate (``--by-coordinate``), which works even when the two
  reconstructions were built with different feature backends.

  Example:

      sfm compare reconstruction1.sfmr reconstruction2.sfmr

Options:
  -h, --help                      Show this message and exit.
  --by-coordinate / --by-feature-index
                                  Match corresponding 3D points by 2D keypoint
                                  coordinate (works across different SIFT
                                  backends) or by feature index (requires
                                  identical .sift files). Default: auto-select
                                  coordinate matching when every shared image
                                  uses a different SIFT file.
  --pixel-threshold FLOAT RANGE   Max 2D keypoint distance (pixels) for --by-
                                  coordinate matching.  [default: 2.0; x>0]
  --fragments                     Always print the fragment decomposition
                                  (RANSAC similarity components over the
                                  shared cameras). Without the flag the
                                  section appears only when the decomposition
                                  finds more than one component or outlier
                                  frames.
  --fragment-pos-threshold FLOAT RANGE
                                  Fragment consensus: max position error as %
                                  of the reference scene scale for a camera to
                                  join a component.  [default: 3.5; x>0]
  --fragment-rot-threshold FLOAT RANGE
                                  Fragment consensus: max rotation error in
                                  degrees for a camera to join a component.
                                  [default: 5.0; x>0]
  --fragment-min-size INTEGER RANGE
                                  Smallest camera count that still counts as a
                                  fragment component; smaller consensus sets
                                  are reported as individual outlier frames.
                                  [default: 5; x>=2]
  --strips PATH                   Render the corresponding points the two
                                  solves place most differently as a side-by-
                                  side patch-strip montage written to this PNG
                                  (reference left, target right). Needs each
                                  reconstruction's workspace images and .sift
                                  files.
  --strips-num INTEGER RANGE      Number of differing points to render with
                                  --strips.  [default: 16; x>=1]
  --strips-views INTEGER RANGE    Cap tiles (observing views) per strip with
                                  --strips (0 = all).  [default: 8; x>=0]
  --strips-context INTEGER RANGE  Render wider NxN-pixel context tiles around
                                  each point (must exceed the 32px patch),
                                  with a green box marking the validated
                                  extent (0 = off).  [default: 96; x>=0]
  --strips-rank [overview|distance|view-angle|ncc|ncc-gap|image-radius|feature-size|world-size]
                                  What --strips surfaces: overview (a few
                                  points from each category), or a single
                                  quantity - distance (alignment
                                  disagreement), view-angle (triangulation
                                  angle), ncc (per-solve photoconsistency),
                                  ncc-gap (gap between the solves; slower),
                                  image-radius (keypoint distance from the
                                  principal point), feature-size (keypoint
                                  feature size in pixels), or world-size
                                  (feature size as a metric surface
                                  footprint). Use --strips-end to pick the end
                                  of the axis.  [default: overview]
  --strips-end [high|low]         Which end of the --strips-rank axis to show
                                  (default: the axis's natural end, e.g. high
                                  for distance/ncc-gap/image-radius, low for
                                  view-angle/ncc).
  --strips-refine / --strips-no-refine
                                  Turn the listed points to their grown-plane
                                  normals before rendering --strips.
                                  [default: strips-refine]
  --strips-labels LEFT,RIGHT      Names for the two columns in --strips
                                  (RECONSTRUCTION1,RECONSTRUCTION2), used in
                                  the headers and the per-row R/T and unique-
                                  only labels.  [default: reference,target]

sfm densify

Usage: sfm densify [OPTIONS] INPUT_SFMR OUTPUT_SFMR

  Densify matches in a .sfmr file (experimental).

  By default, finds covisibility pairs (pairs already sharing 3D points) and
  sweep-matches them at higher features to find new correspondences.

  With --frustum, additionally finds frustum intersection pairs (geometric
  overlap) that don't already share 3D points.

  Example usage:

      sfm densify input.sfmr output.sfmr --max-features 2048

      sfm densify input.sfmr output.sfmr --max-features 2048 --frustum

      sfm densify input.sfmr output.sfmr --ba-release-focal

Options:
  -h, --help                      Show this message and exit.
  --max-features INTEGER RANGE    Maximum number of features to use from each
                                  image (uses largest features)  [x>=1]
  --sweep-window-size INTEGER     Window size for sweep matching (default: 30)
  --distance-threshold FLOAT      Maximum descriptor distance for matches
                                  (default: None)
  --ba-release-focal              Release the focal length in bundle
                                  adjustment
  --ba-release-principal-point    Release the principal point in bundle
                                  adjustment
  --ba-release-distortion         Release the distortion parameters in bundle
                                  adjustment
  --filter-max-reproj-error FLOAT
                                  Maximum reprojection error for filtering
                                  points (default: 4.0 pixels)
  --filter-min-track-length INTEGER
                                  Minimum track length (observations) for
                                  filtering points (default: 3)
  --filter-min-tri-angle FLOAT    Minimum triangulation angle for filtering
                                  points (default: 1.5 degrees)
  --filter-isolated-median-ratio FLOAT
                                  Filter points more isolated than the median
                                  NN distance times this number (default: 2.0,
                                  0 to disable)
  --close-pair-threshold INTEGER  Maximum distance between image numbers to be
                                  considered 'close' (default: 4)
  --max-close-pairs INTEGER       Maximum number of close pairs to keep
                                  (default: None = all close pairs)
  --max-distant-pairs INTEGER     Maximum number of distant pairs to keep
                                  (default: 5000)
  --distant-pair-search-multiplier INTEGER
                                  Search through this many times max-distant-
                                  pairs to find the best ones (default: 3)
  --frustum                       Also find and match frustum intersection
                                  pairs (slower, finds pairs with no shared
                                  points yet).
  --enable-geometric-filtering    Enable motion-invariant geometric filtering
                                  using affine shapes (experimental)
  --geometric-size-ratio-max FLOAT
                                  Maximum allowed size ratio for geometric
                                  filtering (default: 1.25)
  --geometric-angle-diff-max FLOAT
                                  Maximum allowed angle difference in degrees
                                  for geometric filtering (default: 15.0)

sfm embed-patches

Usage: sfm embed-patches [OPTIONS] INPUT_PATH [OUTPUT_PATH]

  Convert a sift_files reconstruction to embedded_patches.

  Builds a patch frame for each point (mean-viewing normal, turned to its
  grown-plane normal), expands and vets each point's patch views, aligns the
  per-view keypoints to each point's reference render and refines them to sub-
  pixel, then writes a NEW embedded_patches .sfmr that loads and verifies with
  no .sift companion. The input is never modified.

  INPUT_PATH is a sift_files reconstruction (e.g. straight from `sfm solve`);
  its .sift files must still be present where it was created. OUTPUT_PATH,
  when omitted, is written next to the input as `<stem>-embedded.sfmr` (then
  `-embedded-2.sfmr`, ... if taken), mirroring `sfm xform`.

  The observation set is the input track reshaped — expanded by vetting,
  trimmed by per-view discards, then compacted — so point and observation
  counts generally differ from the input.

  An input that is already embedded_patches and stores reference observations
  keeps them: each such point's views are aligned to its own reference
  observation and its bitmap is rendered from it at the final keypoints. A
  point takes the reference-view rule's pick where it stores none, where the
  obliquity cut or the localizer drops its reference, or where its reference
  does not render at its keypoint.

  Examples:
      # Straight from a solve; writes solve-embedded.sfmr next to the input.
      sfm embed-patches solve.sfmr

      # Explicit output, tighter budgets.
      sfm embed-patches solve.sfmr out.sfmr \
          --search 4 --min-relative-zncc 0.75

Options:
  -h, --help                      Show this message and exit.
  --min-relative-zncc FLOAT       Minimum ZNCC a view must reach, as a
                                  fraction of its peers' — admits candidate
                                  views, and drops poorly-registering ones
                                  when the views are aligned to the reference
                                  render, by their blur-matched score against
                                  it.  [default: 0.7]
  --min-absolute-zncc FLOAT       Refuse an observation whose blur-matched
                                  score against the point's reference render
                                  is below this absolute floor. 0 disables it.
                                  [default: 0.5]
  --max-member-zncc-self-similarity-radius FLOAT
                                  Refuse an observation whose OWN patch tile
                                  pins no 2D position: its ZNCC self-
                                  similarity radius, how far the tile can
                                  slide over itself and still match itself, is
                                  above this, in patch-grid pixels. It throws
                                  out a flat sky or water crop, or a lone
                                  straight edge, before it is scored. The
                                  radius reads at most 3, so 3 or more turns
                                  nothing out; 0 disables it. The default,
                                  2.5, is the bench's bar. See
                                  specs/core/patch/zncc-self-similarity-
                                  radius.md.  [default: 2.5]
  --search FLOAT                  The reach of each view's search around its
                                  starting keypoint, in patch-grid pixels.
                                  [default: 6.0]
  --max-shift-px FLOAT            Discard an observation whose keypoint sits
                                  more than this from the point's projection,
                                  in source-image pixels.  [default: 3.0]
  --min-views INTEGER             Drop a point left with fewer surviving
                                  observations after discards.  [default: 2]
  --patch-size FLOAT              Full edge length of each point's patch, in
                                  multiples of the SIFT feature size. A
                                  smaller patch gives the normal and keypoint
                                  refinement less texture to compare.
                                  [default: 11.0]
  --subpixel / --no-subpixel      Run the photometric sub-pixel keypoint
                                  refinement (LK / ECC Gauss-Newton against
                                  the point's reference render) once per round
                                  (see --rounds). --no-subpixel uses the
                                  localizer's keypoints as they are. See
                                  specs/core/patch/keypoint-subpixel-
                                  refinement.md.  [default: subpixel]
  --rounds INTEGER RANGE          Number of (normal-refinement, keypoint-
                                  refinement) rounds, alternating the two.
                                  Each round fits every patch normal again by
                                  the grown plane, then re-refines its
                                  keypoints (the LK sub-pixel pass, see
                                  --subpixel), feeding each result into the
                                  next. The discrete keypoint localizer runs
                                  once in the first round as the seed; later
                                  rounds refine from the previous round's
                                  normals and keypoints.  [default: 2; x>=1]
  --max-obliquity-deg FLOAT RANGE
                                  In every round, before the sub-pixel
                                  keypoint refinement, drop each observation
                                  that views its surfel more than this many
                                  degrees off the (refined) patch normal, the
                                  reference observation included — a grazing
                                  view renders as a degenerate smear that
                                  biases the keypoint fits and the next
                                  round's normal. `90` keeps all views
                                  (disables the filter).  [default: 80.0;
                                  0.0<=x<=90.0]
  --max-zncc-self-similarity-radius FLOAT RANGE
                                  Cull points whose patch bitmap pins no 2D
                                  position, EARLY — right after round 1's
                                  localize + sub-pixel refine, before the
                                  multi-round refinement: its ZNCC self-
                                  similarity radius, how far the bitmap can
                                  slide over itself and still match itself, is
                                  above this, in patch-grid pixels. It removes
                                  points on a straight edge or a flat patch,
                                  which the agreement gate lets through. Each
                                  shift is correlated over the samples the
                                  bitmap holds on both sides, as the member
                                  gates read their tiles. The radius reads at
                                  most 3, so 3 or more turns nothing out; 0
                                  disables the cull. The default, 2.5, is the
                                  member gate's. See specs/core/patch/zncc-
                                  self-similarity-radius.md.  [default: 2.5;
                                  x>=0.0]
  --localize-search-strategy [exhaustive|plus_descent]
                                  How the keypoint localizer searches each
                                  view's shift window for the best match to
                                  the reference render. 'exhaustive' (default)
                                  scores every shift in the window and takes
                                  the highest peak. 'plus_descent' climbs from
                                  the starting keypoint to the nearest peak,
                                  scoring fewer shifts, and stops at a side
                                  peak more often when the start is 2 px or
                                  more off. See specs/core/patch/patch-
                                  keypoint-localization.md.  [default:
                                  exhaustive]
  --sampler [per_view|bilinear|bilinear_mip|anisotropic]
                                  How view selection, keypoint localization,
                                  sub-pixel refinement and the stored bitmap
                                  sample the image pyramid (the grown-plane
                                  normal uses its own sampling). 'per_view'
                                  chooses for each view: 'anisotropic' where
                                  'bilinear_mip' would read the view's less
                                  compressed axis too coarsely, 'bilinear_mip'
                                  otherwise. The other three use one sampler
                                  for every view: 'bilinear' reads the full-
                                  resolution level only; 'bilinear_mip' reads
                                  the pyramid level nearest the view's
                                  compression, which limits aliasing on views
                                  at a different scale; 'anisotropic' also
                                  samples obliquely seen patches correctly;
                                  its cost against 'bilinear_mip' depends on
                                  the view and on whether the CPU has AVX2.
                                  See specs/core/camera/image-warping.md.
                                  [default: per_view]

sfm estimate-intrinsics

Usage: sfm estimate-intrinsics [OPTIONS]

  Estimate a shared focal length and camera model from cluster matches.

  Image pairs drawn from the cluster tracks each vote through whichever
  estimator their geometry can observe, and the pooled log-median is the focal
  consensus. No structure is estimated, so the answer cannot be biased by the
  depth/focal compensation of structure-based estimation. Under `--model auto`
  the pinhole vote runs first, and the equidistant-fisheye column is added --
  and arbitrated against the pinhole one on their certified mass of model-
  informative scan votes -- only when that pinhole vote comes back weak. The
  report says which of the two happened, and why.

  -r selects the file's images to estimate from, as `sfm solve -r` selects
  them from a .matches file: only members on those images vote. The vote
  estimates one camera, so images the workspace gives different cameras (each
  sensor of a .camrig rig, each one-sensor .camrig, each camera_config.json)
  are never pooled: each camera is estimated from its own images and reported
  on its own.

  The report is the product: a capture with no consensus still exits 0.
  Passing --write-camrig also commits the estimate as a one-sensor .camrig,
  which `sfm solve` picks up as the intrinsics prior for the images its
  pattern matches.

  --write-camrig-per-sequence groups the file's images into sequences as `sfm
  pick-images` does (one folder's files whose names differ only in the file
  number), estimates each sequence from its own images, and writes its .camrig
  beside it: images/shopA_00001.jpg ... give images/shopA.camrig with the
  pattern shopA_%05d.jpg, and shopB/00001.jpg ... give shopB/shopB.camrig with
  the pattern %05d.jpg. A sequence the vote reaches no consensus on gets no
  file; the command fails only when no file is written.

  Example:
      sfm estimate-intrinsics -i matches/clusters.matches
      sfm estimate-intrinsics -i matches/clusters.matches \
          --write-camrig images.camrig
      sfm estimate-intrinsics -i matches/clusters.matches -r video1 \
          --write-camrig video1.camrig
      sfm estimate-intrinsics -i matches/clusters.matches \
          --write-camrig-per-sequence

Options:
  -h, --help                      Show this message and exit.
  -i, --input FILE                Cluster-bearing .matches file (from sfm
                                  match --cluster).  [required]
  -r, --range RANGE|NAME          A range expression of file numbers: estimate
                                  from only the .matches file's images whose
                                  file number it holds. A range is file
                                  numbers and spans separated by commas, and a
                                  span may take a step after a ':', as in '7',
                                  '1-100', '1-10,20,30-40' or '1-100:10'
                                  (every 10th number from 1 to 100). A value
                                  with a letter in it is instead the name of a
                                  named image list of the workspace (see
                                  --named-image-list); give one name and one
                                  range, as two -r options, to keep the list's
                                  members whose frame number is in the range.
                                  A slice after the name, quoted, takes part
                                  of the list by position, as for a Python
                                  list: 'NAME[:30]' is its first 30 images,
                                  'NAME[-30:]' its last 30 and 'NAME[::3]'
                                  every third one.
  --named-image-list NAME         Use only the .matches file's images that are
                                  among this named image list's images, with
                                  the list read from the .sfm-named-image-
                                  lists.json of the file's workspace. With -r
                                  RANGE, keep only the members whose frame
                                  number is in RANGE. A slice after the name,
                                  such as 'NAME[:30]', takes part of the
                                  list's images by position.
  --model [auto|pinhole|fisheye]  Camera-model columns to run: `auto` votes
                                  pinhole-only and runs both columns,
                                  arbitrating between them, when that vote
                                  comes back weak; the named forms run one
                                  column and skip arbitration.  [default:
                                  auto]
  --write-camrig FILE             Write the estimate as a one-sensor .camrig
                                  at this path.
  --pattern TEXT                  Image pattern stored in the .camrig;
                                  defaults to the selected images' common
                                  directory plus one '*' segment per directory
                                  level below it, ending '*<ext>' for the
                                  extension their names share, and narrowed to
                                  their names' common prefix
                                  ('<prefix>*<ext>') when it would otherwise
                                  match images of the file that -r left out.
  --write-camrig-per-sequence     Write one one-sensor .camrig per image
                                  sequence of the file, each estimated from
                                  that sequence's images only, in the
                                  sequence's folder, named after the part of
                                  its file names before the number, or after
                                  the folder when that part is empty.
  --force                         Allow --write-camrig or --write-camrig-per-
                                  sequence to overwrite existing files.
  --json                          Emit the full vote result as JSON on stdout
                                  instead of the report.
  --seed INTEGER                  RANSAC / pair-sampling seed; same inputs,
                                  seed and --draws give the same output.
                                  [default: 0]
  --draws INTEGER RANGE           RANSAC draws per pair vote; a pair votes the
                                  log-space median of its draws when more than
                                  half of them vote.  [default: 1; x>=1]

sfm inspect

Usage: sfm inspect [OPTIONS] TARGET [REST]...

  Inspect an sfmtool file, image, or 3D point and print a summary.

  TARGET is a file path or a 3D point ID. A file's type is determined by
  extension:

    .sfmr     reconstruction
    .sift     feature file
    .matches  feature matches
    .camrig   camera rig
    image     .png / .jpg / .jpeg

  A 3D point ID has the form ``pt3d_<hash>_<index>`` (as shown by the GUI and
  verbose reconstruction reports). It is resolved by finding the .sfmr whose
  content hash matches ``<hash>`` within the workspace: pass the workspace
  directory (or any path inside it) as the optional second argument; the
  workspace is found by searching that directory and its parents. It defaults
  to the current directory.

  Without --verbose, prints a short summary. With --verbose, prints the full
  detail — for a point ID, the complete triangulation analysis, which reads
  the inline keypoints or, without them, the workspace ``.sift`` files.

  With --strips, TARGET is a .sfmr and the remaining arguments are points to
  render as a patch-strip montage (see --strips). A ``sift_files``
  reconstruction is converted to embedded patches first, and the listed points
  are turned to their grown-plane normals; an ``embedded_patches`` one is
  rendered as stored.

  For deep-analysis reports on a reconstruction (covisibility, frustum, depth,
  per-image metrics), use `sfm analyze`.

  Examples:

      sfm inspect reconstruction.sfmr

      sfm inspect image_001.sift --verbose

      sfm inspect pt3d_220747a8_96414

      sfm inspect pt3d_220747a8_96414 /data/KerryPark360 --verbose

      sfm inspect --strips reconstruction.sfmr 0-9 pt3d_220747a8_96414 -o
      strips.png

Options:
  -h, --help                    Show this message and exit.
  --strips                      Render the listed points of a .sfmr as a
                                patch-strip montage (labels | reference patch
                                | per-view observation strip) for visually
                                evaluating point quality. TARGET is the .sfmr;
                                the remaining arguments are points to render
                                (pt3d_<hash>_<index> ids and/or point-index
                                range expressions like '5', '5-12', '1,4,7'),
                                rendered in the order listed.
  -o, --output PATH             Output PNG path for --strips (default:
                                <stem>_strips.png in the current directory).
  --strips-views INTEGER RANGE  Cap observation tiles (views) per point with
                                --strips (0 = all).  [default: 8; x>=0]
  --context FLOAT RANGE         With --strips, pad each per-observation patch
                                with this fraction of extra context around it
                                (1.0 = +100%), drawing a border at the patch
                                extent. 0 = tight patches with no border. The
                                reference patch always renders tight.
                                [default: 1.0; x>=0]
  -v, --verbose                 Print detailed information instead of a short
                                summary.

sfm merge

Usage: sfm merge [OPTIONS] RECONSTRUCTION_PATHS...

  Merge multiple aligned .sfmr files.

  This command merges multiple .sfmr files that are already in the same
  coordinate frame (e.g., from 'sfm align') into a single unified
  reconstruction.

  The merge process: - Deduplicates cameras with identical parameters - Merges
  images (uses first occurrence's pose for overlapping images) - Finds
  corresponding 3D points across reconstructions using feature matching -
  Filters correspondences using percentile-based thresholding (scale-
  invariant) - Merges corresponding points (averages positions, combines
  observations) - Refines camera poses using PnP + RANSAC against the merged
  point cloud - Combines all tracks into a unified reconstruction

  RECONSTRUCTION_PATHS must be sift_files .sfmr files that are already aligned
  and were made from the same feature folder. The inputs are checked before
  the merge starts.

  Example:

      sfm merge aligned/ref.sfmr aligned/recon1.sfmr -o merged.sfmr

Options:
  -h, --help                Show this message and exit.
  -o, --output PATH         Output path for merged .sfmr file.  [required]
  --merge-percentile FLOAT  Percentile of correspondence distances to use as
                            threshold (default: 95.0).

sfm motion

Usage: sfm motion [OPTIONS] [PATHS]...

  Analyze camera motion in image sequences or reconstructions for
  discontinuities.

  Input can be image paths/directories (analyzes frame-to-frame optical flow)
  or a single .sfmr file (analyzes camera motion with flow cross-check).

  Image sequence mode:
      Detects numbered sequences among the input images, then uses adaptive-stride
      optical flow to find discontinuities within each sequence.

  Examples:
      sfm motion images/
      sfm motion images/ --initial-stride 16
      sfm motion images/ -r 1-100
      sfm motion -r walk1_sharp

Options:
  -h, --help               Show this message and exit.
  -r, --range RANGE|NAME   A range expression of file numbers to use from the
                           input directories. A range is file numbers and
                           spans separated by commas, and a span may take a
                           step after a ':', as in '7', '1-100',
                           '1-10,20,30-40' or '1-100:10' (every 10th number
                           from 1 to 100). A value with a letter in it is
                           instead the name of a named image list of the
                           workspace (see --named-image-list); give one name
                           and one range, as two -r options, to keep the
                           list's members whose frame number is in the range.
                           A slice after the name, quoted, takes part of the
                           list by position, as for a Python list: 'NAME[:30]'
                           is its first 30 images, 'NAME[-30:]' its last 30
                           and 'NAME[::3]' every third one.
  --named-image-list NAME  Use the images of this named image list, defined in
                           the workspace's .sfm-named-image-lists.json, in
                           place of image paths. The workspace is found from
                           the current directory. With -r RANGE, keep only the
                           members whose frame number is in RANGE. A slice
                           after the name, such as 'NAME[:30]', then takes
                           part of the list's images by position.
  --initial-stride N       Initial stride for adaptive sampling. Default: 1.
                           [x>=1]
  --min-stride N           Minimum stride. Default: 1.  [x>=1]
  --max-stride N           Maximum stride. Default: 32.  [x>=2]
  --no-adaptive            Disable adaptive stride adjustment. Keep the stride
                           fixed.
  --save-flow-dir PATH     Directory to save optical flow color images.
  --json PATH              Write a machine-readable JSON report of the
                           analysis to this path.

sfm solve

Usage: sfm solve [OPTIONS] [PATHS]...

  Run structure from motion on images or a .matches file.

  Input can be image paths/directories (runs feature matching internally) or a
  single .matches file (uses pre-computed matches).

  Examples:     # From images (incremental)     sfm solve -i path/to/images/

      # From a pre-computed .matches file     sfm solve -i tvg-
      matches/my.matches

      # Use global SfM (COLMAP's global mapper)     sfm solve -g
      path/to/images/

      # Sequential overlap mode     sfm solve -i path/to/images/ --seq-overlap
      100,20

      # The images of a named image list of the workspace     sfm solve -i -r
      walk1_sharp

      # The first 30 images of the list, from its pre-computed matches     sfm
      solve -g tvg-matches/walk1_sharp.matches -r 'walk1_sharp[:30]'

Options:
  -h, --help                      Show this message and exit.
  --colmap-dir DIRECTORY          Directory for the COLMAP database and
                                  intermediate files.
  --max-features INTEGER RANGE    Maximum number of features to use from each
                                  image.  [x>=1]
  -r, --range RANGE|NAME          A range expression of file numbers to use
                                  from the input directories, or from the
                                  images of a .matches file. A range is file
                                  numbers and spans separated by commas, and a
                                  span may take a step after a ':', as in '7',
                                  '1-100', '1-10,20,30-40' or '1-100:10'
                                  (every 10th number from 1 to 100). A value
                                  with a letter in it is instead the name of a
                                  named image list of the workspace (see
                                  --named-image-list); give one name and one
                                  range, as two -r options, to keep the list's
                                  members whose frame number is in the range.
                                  A slice after the name, quoted, takes part
                                  of the list by position, as for a Python
                                  list: 'NAME[:30]' is its first 30 images,
                                  'NAME[-30:]' its last 30 and 'NAME[::3]'
                                  every third one.
  --named-image-list NAME         Use the images of this named image list,
                                  defined in the workspace's .sfm-named-image-
                                  lists.json, in place of image paths. The
                                  workspace is found from the current
                                  directory. With -r RANGE, keep only the
                                  members whose frame number is in RANGE. A
                                  slice after the name, such as 'NAME[:30]',
                                  then takes part of the list's images by
                                  position. With a .matches file, use only the
                                  file's images that are among the list's
                                  images, with the list read from the file's
                                  workspace.
  -i, --incremental               Run incremental structure from motion.
  -g, --global                    Run global structure from motion with
                                  COLMAP's global mapper.
  --sfmr-dir PATH                 Directory for .sfmr files. Default:
                                  workspace/sfmr.
  -s, --seed INTEGER              Random seed for reproducible
                                  reconstructions.
  -o, --output PATH               Output .sfmr file path.
  --seq-overlap TEXT              Sequential overlap mode: 'WINDOW,OVERLAP'
                                  (e.g., '100,20').
  --refine-rig / --no-refine-rig  Refine sensor-from-rig poses during bundle
                                  adjustment.
  --flow-match                    Use optical flow-based matching instead of
                                  exhaustive descriptor matching.
  --flow-preset [fast|default|high_quality]
                                  Optical flow quality preset for --flow-
                                  match. Default: default.
  --flow-skip INTEGER RANGE       Sliding window size for --flow-match.
                                  Default: 5.  [x>=1]
  --camera-model [pinhole|simple_pinhole|simple_radial|radial|opencv|opencv_fisheye|full_opencv|simple_radial_fisheye|radial_fisheye|thin_prism_fisheye|rad_tan_thin_prism_fisheye]
                                  Camera model to use: overrides auto-
                                  detection, and refits to this model the
                                  cameras a .camrig or camera_config.json
                                  supplies.
  --detect-infinity / --no-detect-infinity
                                  Reclassify points whose depth the solve
                                  could not pin down as points at infinity.
                                  Enabled by default.

sfm xform

Usage: sfm xform [OPTIONS] INPUT_PATH [OUTPUT_PATH]

  Apply transformations to a .sfmr file.

  This command applies a sequence of transformations and filters to a
  reconstruction in a single pass. Transformations are applied in the order
  they appear on the command line.

  INPUT_PATH must be a .sfmr file. OUTPUT_PATH is the path for the output
  .sfmr file. If omitted, the output is written next to the input as
  ``{stem}-transformed.sfmr``, falling back to ``{stem}-transformed-2.sfmr``
  (then ``-3``, ...) when that name is taken.

  Available transformations:

  Geometric Transformations:
    --rotate axisX,axisY,axisZ,angle    Rotate around axis
    --translate X,Y,Z                   Translate by vector
    --scale S                           Scale by factor
    --scale-by-measurements FILE        Scale to physical units using measurements YAML

  Filters:
    --include-range RANGE               Keep only images with file numbers in range
    --exclude-range RANGE               Exclude images with file numbers in range
    --include-glob PATTERN              Keep only images matching glob pattern
    --exclude-glob PATTERN              Exclude images matching glob pattern
    --remove-short-tracks size          Remove points with track length <= size
    --remove-narrow-tracks angle        Remove points with viewing angle < threshold
    --remove-large-features size        Remove points with max feature size > threshold
    --remove-isolated factor,spec       Remove isolated points (NN distance filter)
    --filter-by-reprojection-error val  Remove points with reprojection error > threshold
    --filter-by-zncc-self-similarity-radius val  Remove points whose patch bitmap slides over itself > val (patch-grid px)
    --filter-by-patch-size MULT         Remove points with world-space patch size > MULT x median
    --include-by-distribution COUNT[,verbose]  Keep COUNT well-distributed cameras/rig frames

  Points at infinity:
    --find-points-at-infinity SPEC      Discover points at infinity: eps_deg[,desc_thresh[,min_views[,sigma_px]]]
    --classify-points-at-infinity [SIGMA_PX]  Store each point as the point-or-bearing test decides
    --max-features N                    Cap features per image for --find-points-at-infinity (largest first)

  Camera model:
    --camera-model MODEL[,KEY=VAL...]   Fit another model to each camera (e.g. SFMTOOL_FISHEYE,coeffs=8)
    --drop-image-adjustments PARAMS     Stop cameras varying per-image parameters (parameters=, cameras=)

  Optimization:
    --bundle-adjust [PARAMS]            Apply bundle adjustment (cameras=, cross=, principal_point=, image_*=, scanlines=)
    --refine-normals [method=NAME]      Turn each patch to its grown-plane or pairwise-flow normal (reads source images)
    --refine-keypoints [PARAMS]         Refine per-observation keypoints to sub-pixel (reads source images)
    --localize-keypoints [PARAMS]       Cross-view keypoint search; drops non-registering views (reads source images)

  Representation:
    --to-embedded-patches [PARAMS]      Convert sift_files → embedded_patches (no photometric adaptation; reads .sift)

  Heavy columns:
    --drop-thumbnails                   Discard the per-image thumbnails
    --drop-patch-bitmaps                Discard the per-point patch bitmaps (frames kept)
    --add-thumbnails                    Build thumbnails from the .sift files, else the photographs
    --add-patch-bitmaps [PARAMS]        Render patch bitmaps at the stored frames (reads source images)
    --minimal [PARAMS]                  Drop both, and save minimal metadata (for a file that travels); wspath=<path> states the recorded workspace path

  Alignment:
    --align-to path.sfmr                Align to another reconstruction
    --align-to-input                    Align back to original input

  Examples:

      # Rotate 90 degrees around Y axis
      sfm xform in.sfmr out.sfmr --rotate 0,1,0,90deg

      # Translate then rotate (order matters!)
      sfm xform in.sfmr out.sfmr --translate 3,5,-2 --rotate 0,1,0,90deg

      # Filter short tracks, then scale
      sfm xform in.sfmr out.sfmr --remove-short-tracks 2 --scale 0.5

      # Multiple operations in sequence
      sfm xform in.sfmr out.sfmr \
          --remove-short-tracks 2 \
          --rotate 1,0,0,90deg \
          --translate 0,0,-5 \
          --scale 0.01

      # Filter and optimize with bundle adjustment
      sfm xform in.sfmr out.sfmr --remove-short-tracks 2 --bundle-adjust

      # Upgrade SIMPLE_RADIAL → RADIAL to refine k2 during bundle adjustment
      sfm xform in.sfmr out.sfmr --camera-model RADIAL --bundle-adjust

      # Move a fisheye to the spline model, then refine its focal and spline
      sfm xform in.sfmr out.sfmr --camera-model SFMTOOL_FISHEYE,coeffs=8 --bundle-adjust

      # Release each image's radial correction and rolling shutter, racing
      # rows against columns where the scanlines are not known
      sfm xform in.sfmr out.sfmr --bundle-adjust image_radial_bspline=on,image_rolling_shutter=on

      # Drop each image's principal-point offset, then solve one principal
      # point per camera
      sfm xform in.sfmr out.sfmr --drop-image-adjustments parameters=principal_point --bundle-adjust principal_point=on

      # Discover points at infinity, capping features per image
      sfm xform in.sfmr out.sfmr --find-points-at-infinity 0.1,200,2 --max-features 2000

      # Bundle-adjust, then refine surface normals against the final geometry
      sfm xform in.sfmr out.sfmr --bundle-adjust --refine-normals

      # Refine keypoints to sub-pixel and refine normals in one pass
      sfm xform in.sfmr out.sfmr --refine-keypoints --refine-normals

      # Refine normals with the pairwise-flow normal (seconds of one thread per point)
      sfm xform in.sfmr out.sfmr --refine-normals method=pairwise_flow

      # Search keypoints into the photometric basin (drops non-registering
      # views), then sharpen the survivors to sub-pixel
      sfm xform in.sfmr out.sfmr --localize-keypoints --refine-keypoints

      # The smallest file for a repository, and the same with thumbnails kept
      sfm xform in.sfmr out.sfmr --minimal
      sfm xform in.sfmr out.sfmr --minimal --add-thumbnails

      # A ground truth checked in inside its own workspace, so the file records
      # the workspace it sits in rather than the path it was written from
      sfm xform in.sfmr ws/ground_truth.sfmr --minimal wspath=.

      # Re-render the patch bitmaps at a different resolution
      sfm xform in.sfmr out.sfmr --drop-patch-bitmaps --add-patch-bitmaps resolution=32

Options:
  -h, --help                      Show this message and exit.
  --rotate TEXT                   Rotate around axis: axisX,axisY,axisZ,angle
                                  (e.g., '0,1,0,90deg')
  --translate TEXT                Translate by vector: X,Y,Z (e.g., '3,5,-2')
  --scale TEXT                    Scale by factor: S (e.g., '2.0')
  --remove-short-tracks TEXT      Remove points with track length <= size
                                  (e.g., '2')
  --bundle-adjust TEXT            Apply bundle adjustment to refine camera
                                  poses and 3D points. A reconstruction with a
                                  SFMTOOL_FISHEYE or SFMTOOL_PINHOLE camera is
                                  adjusted by sfmtool with the focal and the
                                  lens distortion released, and each point
                                  stored as a position or a direction by its
                                  rays at the end; 'cameras=0+1' releases only
                                  those cameras' lenses, and 'cross=off' keeps
                                  every point in the representation it has
                                  (e.g. '--bundle-adjust
                                  cameras=0,cross=off'). 'principal_point=on'
                                  releases each released camera's principal
                                  point too. 'image_focal=on',
                                  'image_principal_point=on',
                                  'image_radial_bspline=on' and
                                  'image_rolling_shutter=on' release that
                                  field of each image, by sfmtool's
                                  adjustment, and
                                  'scanlines=rows|columns|unknown' chooses the
                                  scanlines the rolling-shutter rates are
                                  solved on.
  --refine-normals TEXT           Turn each finite point's patch to its grown-
                                  plane normal: one plane fitted to the
                                  photographs the point is seen in.
                                  'method=pairwise_flow' turns it to its
                                  pairwise-flow normal instead, fitted to the
                                  optical flow between pairs of its views, at
                                  its default settings; it costs seconds of
                                  one thread per point against tens of
                                  milliseconds for the grown plane.
                                  'method=grown_plane' is the default. A
                                  turned point's bitmap is rendered again
                                  where the reconstruction stores bitmaps
                                  (--add-patch-bitmaps adds them), and its
                                  observations are read again. Moves no point
                                  and no keypoint. Requires an
                                  embedded_patches reconstruction (convert
                                  first with --to-embedded-patches); reads the
                                  workspace source images, which must still be
                                  present where it was created.
  --refine-keypoints TEXT         Refine per-observation 2D keypoints to sub-
                                  pixel by photometric alignment of every view
                                  to the point's reference render (never worse
                                  than the seed; the reference observation's
                                  keypoint and the track structure are
                                  unchanged). Optional comma-separated
                                  key=value params (e.g.
                                  'max_gn_steps=20,sampler=anisotropic').
                                  Renders and persists the per-point RGBA
                                  patch textures at the refined keypoints by
                                  default so the output is self-contained;
                                  pass 'bitmaps=false' to skip the render
                                  (e.g. on an intermediate stage). A point
                                  that stores a reference observation keeps it
                                  and is rendered from it, unless it does not
                                  render at its keypoint; then nothing is
                                  aligned to it, and with bitmaps the point
                                  records none (with 'bitmaps=false' every
                                  point keeps the reference it stores).
                                  Requires an embedded_patches reconstruction
                                  (convert first with --to-embedded-patches);
                                  reads the workspace source images, which
                                  must still be present where it was created.
  --localize-keypoints TEXT       Localize per-observation 2D keypoints by a
                                  discrete search that aligns every view to
                                  the point's reference render, from the
                                  stored keypoints; the reference observation
                                  is the one the point stores, or the
                                  reference-view rule's pick where it stores
                                  none or the stored one grazes the patch
                                  plane (it is then dropped with the other
                                  grazing views), and its keypoint is not
                                  moved; where the stored one does not render
                                  at its keypoint, nothing is aligned to it.
                                  Structural, not in-place: views that don't
                                  co-register are dropped, points falling
                                  below min_views are culled, and the track
                                  structure is rebuilt from the survivors;
                                  stored patch bitmaps are dropped (re-run
                                  --refine-keypoints to regenerate them, since
                                  it renders bitmaps by default). Each point
                                  keeps its stored reference observation where
                                  its image is still in the track, and
                                  otherwise records the one its views were
                                  aligned to, or none. Optional comma-
                                  separated key=value params (e.g.
                                  'search=8,min_views=3'). Requires an
                                  embedded_patches reconstruction (convert
                                  first with --to-embedded-patches); reads the
                                  workspace source images, which must still be
                                  present where it was created.
  --to-embedded-patches TEXT      Convert sift_files → embedded_patches
                                  without photometric adaptation: mean-view uv
                                  frames, keypoints + image hashes copied from
                                  the .sift files. Optional comma-separated
                                  key=value params (e.g. 'normal=mean_viewing,
                                  extent=feature_size,extent_value=5'). Reads
                                  the .sift files, which must still be present
                                  where the reconstruction was created. After
                                  this op the reconstruction is
                                  embedded_patches.
  --drop-thumbnails               Discard the per-image thumbnail column,
                                  keeping every row. Reads no files. --add-
                                  thumbnails builds it back from the .sift
                                  files or the photographs.
  --drop-patch-bitmaps            Discard the per-point patch bitmap column,
                                  keeping the patch frames, normals and
                                  reference observations, so a later step can
                                  render the same bitmaps onto them.
  --add-thumbnails                Build the thumbnail column from each image's
                                  verified .sift copy, which is already
                                  reduced, and otherwise from its source
                                  photograph, decoded and resized as the SIFT
                                  extractors do. An embedded_patches file
                                  checks each photograph it reads against its
                                  recorded image hash; an image neither source
                                  can supply fails the step. A no-op when
                                  thumbnails are present.
  --add-patch-bitmaps TEXT        Render the patch bitmap column at the stored
                                  frames and keypoints, moving nothing: each
                                  point from its stored reference observation,
                                  and a point with none from the observation
                                  the reference-view rule picks, which is
                                  recorded; where the rule finds no eligible
                                  view, the point gets a zero row and records
                                  -1. Optional 'resolution=<R>,sampler=<S>'
                                  (defaults 24 and per_view). Requires an
                                  embedded_patches reconstruction; reads the
                                  workspace source images. A no-op when
                                  bitmaps are present.
  --minimal TEXT                  Write the smallest file that still holds the
                                  whole reconstruction: --drop-patch-bitmaps
                                  --drop-thumbnails at this position, and a
                                  save with an empty absolute workspace path
                                  and tool_options holding only this
                                  invocation's transforms. Optional
                                  'wspath=<path>' records that as the relative
                                  workspace path instead of measuring one,
                                  e.g. wspath=. for an output written inside
                                  its workspace.
  --remove-narrow-tracks TEXT     Remove points with viewing angle < threshold
                                  (e.g., '5deg')
  --remove-large-features TEXT    Remove points where max SIFT feature size >
                                  threshold in pixels (e.g., '50')
  --remove-isolated TEXT          Remove isolated points (factor,value_spec)
                                  (e.g., '3.0,median')
  --align-to TEXT                 Align to another reconstruction (path to
                                  .sfmr file)
  --align-to-input                Align back to original input reconstruction
  --filter-by-reprojection-error TEXT
                                  Remove points with reprojection error >
                                  threshold (e.g., '2.0')
  --filter-by-zncc-self-similarity-radius TEXT
                                  Remove points whose stored patch bitmap can
                                  slide over itself further than this and
                                  still match itself, in patch-grid px from 0
                                  to 3 (e.g., '2.5'): the ZNCC self-similarity
                                  radius, which reads under 1 for a corner or
                                  texture and 3 for an edge or a flat patch. 0
                                  turns it off. Needs a reconstruction with
                                  patch bitmaps.
  --filter-by-patch-size TEXT     Remove points whose world-space patch size
                                  exceeds a multiple of the median (e.g.
                                  '3.0'). Size is the geometric mean of a
                                  patch's two world half-extents; the
                                  threshold is data-derived per
                                  reconstruction. Needs an embedded_patches
                                  reconstruction.
  --scale-by-measurements TEXT    Scale to physical units using a YAML
                                  measurements file with known point-pair
                                  distances
  --include-range TEXT            Keep only images with file numbers in range
                                  (e.g., '1-10', '1,3,5-7')
  --exclude-range TEXT            Exclude images with file numbers in range
                                  (e.g., '1-10', '1,3,5-7')
  --include-glob TEXT             Keep only images whose name matches a glob
                                  pattern (e.g., '*fisheye_left*')
  --exclude-glob TEXT             Exclude images whose name matches a glob
                                  pattern (e.g., '*fisheye_right*')
  --include-by-distribution TEXT  Keep COUNT strategically distributed
                                  cameras/rig frames; append ',verbose' for a
                                  per-step trace (e.g., '16' or '16,verbose')
  --camera-model TEXT             Fit a camera of another model to each camera
                                  over the angles where it is trusted: MODEL[,
                                  coeffs=N,fit_to=DEG,spline_domain=DEG,camera
                                  s=0+1] (e.g., 'SFMTOOL_FISHEYE,coeffs=8' or
                                  'RADIAL'). Prints a per-camera report.
  --drop-image-adjustments TEXT   Stop cameras varying per-image parameters,
                                  folding the images' mean into each camera:
                                  parameters=NAME+NAME[,cameras=0+1], the
                                  names among focal, principal_point,
                                  radial_bspline and rolling_shutter (e.g.,
                                  'parameters=principal_point'). Poses and
                                  points are not moved.
  --find-points-at-infinity TEXT  Discover points at infinity:
                                  eps_deg[,desc_thresh[,min_views[,sigma_px]]]
                                  (e.g. '0.1,200,2'). Each candidate track is
                                  decided with the point-or-bearing test; the
                                  optional sigma_px is the per-axis pixel
                                  noise to weight the rays by, measured from
                                  the reconstruction by default.
  --classify-points-at-infinity TEXT
                                  Decide every point with the point-or-bearing
                                  test: demote a finite point whose rays ask
                                  for no depth to a point at infinity, and
                                  promote a point at infinity whose rays ask
                                  for one to the fitted point. The optional
                                  value is the per-axis pixel noise to weight
                                  the rays by (e.g. '0.5'); by default it is
                                  measured from the reconstruction.
  --max-features INTEGER RANGE    Cap features per image for --find-points-at-
                                  infinity (largest first)  [x>=1]

Visualization Commands

sfm epipolar

Usage: sfm epipolar [OPTIONS] RECONSTRUCTION_PATH [IMAGE1] [IMAGE2]

  Visualize epipolar geometry between two images from a reconstruction.

  RECONSTRUCTION_PATH must be a .sfmr file.

  Two modes are available:

  1. Single pair mode (default): Specify IMAGE1 and IMAGE2 with --draw

  2. Adjacent pairs mode: Use --pairs-dir to process all adjacent pairs

  Example with filenames:

      sfm epipolar reconstruction.sfmr IMG_001.jpg IMG_005.jpg --draw
      output.png

  Example with file numbers:

      sfm epipolar reconstruction.sfmr 1 5 --draw output.png

  With rectification:

      sfm epipolar reconstruction.sfmr 1 5 --rectify --draw rectified.png

  Adjacent pairs mode:

      sfm epipolar reconstruction.sfmr --pairs-dir output_dir/

Options:
  -h, --help                      Show this message and exit.
  -d, --draw PATH                 Draw epipolar visualization and save to this
                                  path. Writes two files: the given PATH plus
                                  a sibling '<stem>_other<ext>' for the second
                                  image.
  --max-features INTEGER RANGE    Maximum number of shared features to
                                  visualize. Default: all shared features.
                                  [x>=1]
  --line-thickness INTEGER RANGE  Thickness of epipolar lines in pixels.
                                  Default: 1.  [x>=1]
  --feature-size INTEGER RANGE    Size of feature point markers in pixels.
                                  Default: 3.  [x>=1]
  --rectify / --no-rectify        Whether to rectify images.
  --undistort                     Remove lens distortion before drawing
                                  (mutually exclusive with --rectify).
  --draw-lines / --no-lines       Whether to draw epipolar lines or horizontal
                                  scanlines.
  --side-by-side / --separate     Output a single side-by-side image, or two
                                  separate images (the second suffixed
                                  `_other` per --draw).
  --sweep-with-max-features INTEGER RANGE
                                  Run sort-and-sweep matching with this many
                                  features from the original SIFT features.
                                  Requires --draw.  [x>=1]
  --sweep-window-size INTEGER RANGE
                                  Window size for sort-and-sweep matching.
                                  Default: 30. (Only with --sweep-with-max-
                                  features)  [x>=1]
  --pairs-dir PATH                Process all adjacent pairs in sequence and
                                  save to this directory.

sfm explorer

Usage: sfm explorer [OPTIONS] [SFMR_FILES]...

  Launch the SfM Explorer 3D viewer.

  Every path given is loaded as its own node in the viewer's scene graph, so
  several reconstructions can be compared side by side in one 3D space.

  The viewer comes up in whatever window placement and panel arrangement was
  saved to ~/.sfm-explorer-default-layout.json by its Panels > Save Layout...
  menu item; --no-default-layout starts from the stock grid instead.

  With --mcp the viewer also hosts an MCP endpoint an agent can drive it
  through: the scene graph, the selection, the 3D camera, the window and its
  panels, and a screenshot of the viewport. The window says so while it is
  live, in its title bar and in the Scene panel. See specs/gui/mcp-server.md.

Options:
  --mcp PORT           Host a Model Context Protocol endpoint on 127.0.0.1, so
                       an agent can drive the viewer window. Off unless asked
                       for. Defaults to port 8787; 0 takes an ephemeral port,
                       printed at startup.  [0<=x<=65535]
  --no-default-layout  Start with the stock panel grid, ignoring any layout
                       saved at ~/.sfm-explorer-default-layout.json.
  --help               Show this message and exit.

sfm heatmap

Usage: sfm heatmap [OPTIONS] RECONSTRUCTION_PATH

  Visualize reconstruction quality metrics as heatmaps on images.

  Renders colored overlays showing per-feature quality metrics:

  - reproj: Reprojection error (pixels) - how well 3D points project back
  - tracks: Track length - number of images observing each point
  - angle: Triangulation angle (degrees) - baseline quality

  Each metric uses an appropriate colormap by default: - reproj: error
  (green=good, red=bad) - tracks: tracks (blue=few, red=many) - angle: viridis
  (purple=small, yellow=large)

  Output images are saved with the metric inserted before any trailing number
  (e.g., image_001 with metric reproj -> image_reproj_001.png).

  Examples:

      # Generate all heatmaps for a reconstruction     sfm heatmap result.sfmr
      -o heatmaps/

      # Generate only reprojection error heatmaps     sfm heatmap result.sfmr
      -o heatmaps/ --metric reproj

      # Use custom colormap and larger markers     sfm heatmap result.sfmr -o
      heatmaps/ --colormap jet --radius 8

Options:
  -h, --help                      Show this message and exit.
  -o, --output PATH               Output directory for heatmap images.
                                  [required]
  --metric [reproj|tracks|angle|all]
                                  Metric to visualize: reproj (reprojection
                                  error), tracks (track length), angle
                                  (triangulation angle), or all (default).
  --colormap [viridis|plasma|jet|coolwarm|error|tracks]
                                  Colormap to use. Default depends on metric.
  --radius INTEGER                Radius of feature circles in pixels
                                  (default: 5).
  --alpha FLOAT                   Opacity of overlay (0.0-1.0, default: 0.7).

sfm panorama

Usage: sfm panorama [OPTIONS] RECONSTRUCTION_PATH

  Render an equirectangular panorama from a posed reconstruction.

  Composites the reconstruction's source images onto a sphere of spherical
  tiles, selects the photometrically-agreeing cluster per tile, and resamples
  the result through a full-sphere equirectangular camera. Uncovered regions
  are written as black.

  Examples:

      # Render a 2160x1080 panorama     sfm panorama result.sfmr -o pano.png

      # Higher resolution with images in an explicit directory     sfm
      panorama result.sfmr -o pano.png --equirect-width 4096 \
      --image-dir images/

      # Render with a pre-built rig (tile density decoupled from output size)
      sfm panorama result.sfmr -o pano.png --camrig tiles.camrig \
      --equirect-width 4096

Options:
  -h, --help                 Show this message and exit.
  -o, --output PATH          Output panorama image path (e.g. pano.png).
                             [required]
  --image-dir DIRECTORY      Directory the reconstruction's image names are
                             relative to (default: the reconstruction's
                             workspace directory).
  -r, --range RANGE|NAME     Composite only images whose file number matches
                             this range expression. A range is file numbers
                             and spans separated by commas, and a span may
                             take a step after a ':', as in '7', '1-100',
                             '1-10,20,30-40' or '1-100:10' (every 10th number
                             from 1 to 100). A value with a letter in it is
                             instead the name of a named image list of the
                             workspace (see --named-image-list); give one name
                             and one range, as two -r options, to keep the
                             list's members whose frame number is in the
                             range. A slice after the name, quoted, takes part
                             of the list by position, as for a Python list:
                             'NAME[:30]' is its first 30 images, 'NAME[-30:]'
                             its last 30 and 'NAME[::3]' every third one.
  --named-image-list NAME    Use only the reconstruction's images that are
                             members of this named image list, defined in the
                             .sfm-named-image-lists.json of the
                             reconstruction's workspace. With -r RANGE, keep
                             only the members whose frame number is in RANGE.
                             A slice after the name, such as 'NAME[:30]', then
                             takes part of the members the reconstruction
                             holds by position.
  --near-image TEXT          Composite only images spatially near this
                             reference image (matched by name or path suffix).
                             Requires --near-count and/or --near-radius.
  --near-count INTEGER       With --near-image, keep the N images whose
                             cameras are closest to the reference (the
                             reference is always included).
  --near-radius FLOAT        With --near-image, keep images whose cameras are
                             within this world-space distance of the
                             reference.
  --equirect-width INTEGER   Output width in pixels; height is width / 2
                             (default: 2160).
  --n-tiles INTEGER          Number of spherical tiles in the synthesized rig
                             (default: 320; ignored when --camrig is given).
  --camrig FILE              Load the spherical-tile rig from this .camrig
                             file instead of synthesizing one. Takes
                             precedence over --n-tiles (which is then
                             ignored); --equirect-width controls only the
                             output resolution.
  --batch-size INTEGER       Tiles composited per batch; smaller bounds peak
                             memory (default: 32).
  --dtype [float32|float16]  Per-batch stack storage; float16 halves memory at
                             some precision cost (default: float32).
  -k INTEGER                 Nearest tiles blended when resampling; k=1 is
                             closest-tile (default: 1).
  --seed INTEGER             Rig relaxer seed (default: 1234).
  --inlier-threshold FLOAT   Photometric RANSAC inlier threshold in luma units
                             (default: 8.0).
  --gamma FLOAT              Photometric RANSAC tone exponent (default: 1.0).
  --ransac-seed INTEGER      Photometric RANSAC seed (default: 0).

sfm render-patches

Usage: sfm render-patches [OPTIONS] RECONSTRUCTION_PATH

  Render a reconstruction's oriented patches on top of its source images.

  For each registered image, every per-point oriented patch (the quad spanned
  by its in-plane half-extent vectors, centred on the point) is projected into
  the frame and composited onto the source image, for visually inspecting the
  reconstruction's geometry and patches.

  The reconstruction must be ``embedded_patches`` (it carries the per-point
  patch frames), e.g. from:

      sfm xform in.sfmr out.sfmr --to-embedded-patches
      # for --mode texture, build bitmaps too:
      sfm xform in.sfmr out.sfmr --to-embedded-patches --add-patch-bitmaps

  Patches are painted back-to-front (painter's algorithm); there is no true
  occlusion, so a distant patch can show through a nearer one.

  Examples:

      # Textured patches with outlines (needs bitmaps)
      sfm render-patches out.sfmr -o renders/ --border
      # Honest alignment check, no confidence bleed-through
      sfm render-patches out.sfmr -o renders/ --opaque
      # Normal field on small images, scaled up for legibility
      sfm render-patches out.sfmr -o renders/ --mode normal --upscale 3

Options:
  -h, --help                      Show this message and exit.
  -o, --output PATH               Output directory for the rendered overlay
                                  images.  [required]
  --mode [texture|normal|flat|wire]
                                  Patch fill: texture (warp the patch bitmap),
                                  normal (shade by surface normal), flat
                                  (point colour), or wire (outline only).
                                  Default: texture.
  --border / --no-border          Outline each patch quad.
  --border-color TEXT             Border colour as 'R,G,B' (default: 0,255,0).
  --border-thickness INTEGER      Border thickness in pixels.
  --alpha FLOAT                   Global patch opacity (0.0-1.0, default:
                                  1.0).
  --opaque FLOAT                  Texture mode: paint texels whose confidence
                                  alpha exceeds this threshold (0-1) at full
                                  opacity and drop the rest, for an honest
                                  alignment check with no bleed-through. Bare
                                  --opaque uses 0.1; omit for the confidence-
                                  weighted blend.
  --scale FLOAT                   Shrink/grow each patch quad about its centre
                                  (e.g. 0.5). Note: scaling away from 1.0
                                  breaks texture-to-image alignment.
  --upscale FLOAT                 Upscale the output canvas (and projected
                                  coords) for legibility on small images.
  --backface-cull / --no-backface-cull
                                  Skip patches whose normal faces away from
                                  the camera (default: on).
  --images TEXT                   Restrict to images whose name contains this
                                  substring (repeatable). Default: all
                                  registered images.

sfm web-export

Usage: sfm web-export [OPTIONS] RECONSTRUCTION_PATH

  Write a reconstruction as a web page that draws it in 3D.

  The output directory holds static files: a viewer page (index.html), its
  script (web-export.js), the scene description (scene.json) and JPEG atlases
  of the patch bitmaps and the image thumbnails. Open index.html from a static
  web server, point an iframe at it, or publish the directory as the files of
  a claude.ai artifact. The page draws the points, their textured patches and
  the cameras with each image's thumbnail, and can be turned with a mouse or
  with touch on a phone. three.js is loaded from cdn.jsdelivr.net.

  The thumbnails of the photographs are in the output, so sharing it shares
  them. Use --no-thumbnails to leave them out.

  Examples:

      sfm web-export scene.sfmr -o site/
      sfm web-export scene.sfmr -o site/ --patch-size 12 --max-points 50000
      sfm web-export scene.sfmr -o small/ --single-file

Options:
  -h, --help                    Show this message and exit.
  -o, --output DIRECTORY        Directory to write. Created if missing;
                                refused if it exists and is not empty, unless
                                --overwrite.  [required]
  --overwrite                   Replace the files this command writes in an
                                existing directory.
  --no-patches                  Leave out the patch atlas; points are drawn as
                                round splats in their stored colour.
  --no-thumbnails               Leave out the thumbnail atlas; frustums are
                                drawn as wireframes only.
  --patch-size INTEGER RANGE    Resample patch tiles to this many texels a
                                side (for example 12) to shrink the atlas.
                                Default: the file's bitmap size.  [x>=1]
  --jpeg-quality INTEGER RANGE  JPEG quality for both atlases.  [default: 85;
                                1<=x<=100]
  --max-points INTEGER RANGE    Keep the N points with the most observations;
                                the rest are left out.  [x>=1]
  --start-image TEXT            Open the page looking through this image's
                                camera (its name as the reconstruction stores
                                it) instead of framing the whole scene.
  --single-file                 Write one self-contained index.html with the
                                data and atlases inline; refused if it would
                                pass 16 MB.

Automation Commands

sfm explorer-call

Usage: sfm explorer-call [OPTIONS] [TOOL] [ARGS]

  Call one tool on a running SfM Explorer's MCP endpoint.

  ARGS is the tool's arguments as one JSON object: given inline, as @FILE to
  read it from a file, or as - to read it from standard input. It defaults to
  {}. Reading it from a file or from standard input avoids quoting JSON for a
  shell.

  Before it connects, the command checks the call against the viewer's own
  tool catalog and argument parser, as compiled into this sfmtool: a tool name
  the catalog does not have is refused with the nearest names, and arguments
  that do not parse are refused with the message the viewer would send. It
  then compares the running viewer's tool list with that catalog, and refuses
  the call when they differ; --validate-tool-names-only checks only the tool
  name, against the running viewer's list.

  A text reply is printed whole. An image in the reply is written to --out-dir
  as STEM.png (STEM_1.png and on for more) and its path printed. The exit
  status is 0 when the viewer answered, 1 when the command refused the call, 2
  for a usage error, 3 when the viewer refused the call, and 4 when no
  endpoint answered. See specs/cli/automation/explorer-call-command.md.

Options:
  --mcp PORT                   The port of the viewer's MCP endpoint on
                               127.0.0.1, as given to `sfm explorer --mcp`.
                               [default: 8787; 1<=x<=65535]
  --list-tools                 Print each tool's name, kind and the first
                               sentence of its description, from this
                               sfmtool's catalog, without connecting.
  --schema                     Print TOOL's tools/list entry, with its
                               description and input schema, from this
                               sfmtool's catalog, without connecting.
  --validate-tool-names-only   Check only that TOOL is in the running viewer's
                               tool list, and let the viewer check the
                               arguments. For a viewer built from other
                               sources than this sfmtool, whose catalog
                               differs.
  --batch PATH                 Call TOOL once for each line of PATH, a JSON-
                               lines file of argument objects, or - for
                               standard input, and print one JSON line per
                               call.
  --field PATH                 Print one field of the reply instead of the
                               whole reply: keys and list indexes joined by
                               dots, such as track.0.camera_image.
  --out-dir DIRECTORY          Where an image in the reply is written.
                               [default: .]
  --name STEM                  File stem for an image in the reply. Defaults
                               to the tool name.
  --wait-for-endpoint SECONDS  Keep trying to reach the endpoint for up to
                               SECONDS, for a viewer that is still starting.
                               [x>=0]
  --wait-until-finished        With get_background_tasks: repeat the call once
                               a second until its reply shows no task running
                               or waiting, then print that reply.
  --help                       Show this message and exit.

Image Processing Commands

sfm flow

Usage: sfm flow [OPTIONS] IMAGE1 IMAGE2

  Visualize optical flow between two images.

  Computes dense optical flow from IMAGE1 to IMAGE2 using the Rust DIS
  algorithm, moves IMAGE1's SIFT keypoints along it, and reports how many land
  within --tolerance of an IMAGE2 keypoint (a hit). Both images need .sift
  files and must have the same dimensions. --descriptor-threshold affects the
  printed statistics only; --max-features affects the drawing only. With
  --draw, '<stem>_flow<ext>' shows the flow field, hue encoding direction and
  saturation magnitude.

  Without --reconstruction:
      Draws only the hits, each in its own palette colour: the keypoint in
      IMAGE1, and in IMAGE2 the advected position joined by a line to the
      IMAGE2 keypoint it landed near.

  With --reconstruction:
      Compares flow advection against reconstruction correspondences:
      - GREEN: flow agrees with sfmr (advected position near matched keypoint)
      - RED: sfmr correspondence that flow does not explain
      - YELLOW: flow hit that is not an sfmr correspondence

  Print statistics only (no image output):
      sfm flow img1.jpg img2.jpg

  Draw visualization:
      sfm flow img1.jpg img2.jpg --draw output.png

  Compare with reconstruction:
      sfm flow img1.jpg img2.jpg --draw output.png -r reconstruction.sfmr

  Side-by-side output:
      sfm flow img1.jpg img2.jpg --draw output.png --side-by-side

  High quality flow:
      sfm flow img1.jpg img2.jpg --draw output.png --preset high_quality

Options:
  -h, --help                      Show this message and exit.
  -d, --draw PATH                 Save flow visualization to this path. If
                                  omitted, only prints statistics. Writes
                                  derived files next to PATH:
                                  '<stem>_flow<ext>' for the flow field, plus
                                  '<stem>_A<ext>'/'<stem>_B<ext>' for the
                                  annotated images (or PATH itself with
                                  --side-by-side).
  --preset [fast|default|high_quality]
                                  Optical flow quality preset. Default:
                                  default.
  -r, --reconstruction PATH       Compare flow against correspondences from
                                  this .sfmr reconstruction.
  --max-features INTEGER RANGE    Maximum number of features to visualize.
                                  Default: all.  [x>=1]
  --tolerance FLOAT RANGE         Pixel tolerance for matching advected
                                  positions to keypoints. Default: 3.0.
                                  [x>=0.1]
  --descriptor-threshold FLOAT RANGE
                                  L2 descriptor distance threshold for
                                  filtering good matches. Default: 100.0.
                                  [x>=0.0]
  --feature-size INTEGER RANGE    Size of feature point markers in pixels.
                                  Default: 4.  [x>=1]
  --line-thickness INTEGER RANGE  Thickness of lines in pixels. Default: 1.
                                  [x>=1]
  --side-by-side / --separate     Output a single side-by-side image or two
                                  separate images (_A and _B).

sfm undistort

Usage: sfm undistort [OPTIONS] RECONSTRUCTION_PATH

  Undistort all images in a reconstruction using camera parameters.

  For each image in the reconstruction, this command loads the corresponding
  camera model and undistorts the image to a best-fit pinhole camera with
  square pixels. Produces a full workspace with undistorted images,
  transformed .sift files, and a new .sfmr reconstruction.

  By default, the output workspace is created next to the .sfmr file:
  reconstruction.sfmr -> reconstruction_undistorted/

  The output workspace contains:     .sfm-workspace.json, undistorted images,
  .sift files, sfmr/undistorted.sfmr

  RECONSTRUCTION_PATH must be a .sfmr file.

  Example:     sfm undistort reconstruction.sfmr     sfm undistort
  reconstruction.sfmr --fit outside     sfm undistort reconstruction.sfmr -o
  /tmp/undistorted

Options:
  -h, --help                 Show this message and exit.
  --fit [inside|outside]     Pinhole fit mode. 'inside' (default) ensures no
                             black borders — all output pixels are backed by
                             source data. 'outside' ensures no cropping — all
                             source pixels are included, but borders may be
                             black.
  --filter [aniso|bilinear]  Resampling filter. 'aniso' (default) uses
                             anisotropic filtering for higher quality,
                             reducing aliasing in areas of high compression.
                             'bilinear' is faster but may alias near image
                             edges.
  -o, --output PATH          Output directory. Defaults to
                             <sfmr_stem>_undistorted/ next to the .sfmr file.

COLMAP Interop Commands

sfm from-colmap-bin

Usage: sfm from-colmap-bin [OPTIONS] COLMAP_RECONSTRUCTION_PATH

  Convert COLMAP .bin files to a .sfmr file.

  Reads a COLMAP reconstruction directory containing cameras.bin, images.bin,
  and points3D.bin and converts to the .sfmr format used by sfmtool.

  The --image-dir option is required to resolve workspace paths and find .sift
  files for each image.

  COLMAP_RECONSTRUCTION_PATH is the path to the COLMAP reconstruction
  directory (e.g., colmap_workspace/reconstruction/0/).

  Example usage:

      # Import a COLMAP reconstruction
      sfm from-colmap-bin colmap_output/0/ \
          --image-dir my_workspace/images/ \
          -o reconstruction.sfmr

      # Specify tool provenance     sfm from-colmap-bin colmap_output/0/ \
      --image-dir my_workspace/images/ \         -o reconstruction.sfmr \
      --tool-name glomap

Options:
  -h, --help                      Show this message and exit.
  --image-dir DIRECTORY           Directory containing the images (used to
                                  find workspace and .sift files).  [required]
  -o, --output PATH               Output .sfmr file path.  [required]
  --tool-name TEXT                Name of the tool that created the
                                  reconstruction (e.g., 'colmap', 'glomap').
                                  Default: 'unknown'.
  --detect-infinity / --no-detect-infinity
                                  Reclassify points whose depth the solve
                                  could not pin down as points at infinity.
                                  Enabled by default.

sfm to-colmap-bin

Usage: sfm to-colmap-bin [OPTIONS] INPUT_SFMR OUTPUT_DIR

  Convert a .sfmr file to COLMAP .bin format.

  Exports the reconstruction to COLMAP's binary format, creating files in the
  output directory:

  - cameras.bin: Camera intrinsic parameters
  - images.bin: Image poses and camera assignments
  - points3D.bin: 3D point cloud with tracks
  - rigs.bin: Rig definitions
  - frames.bin: Frame groupings

  This is useful for importing sfmtool reconstructions into COLMAP for further
  processing, visualization, or dense reconstruction.

  Example usage:

      sfm to-colmap-bin reconstruction.sfmr colmap_output/
      sfm to-colmap-bin reconstruction.sfmr colmap_output/ -r 10-50
      sfm to-colmap-bin reconstruction.sfmr colmap_output/ -r 10-50 --filter-points
      colmap gui --import_path colmap_output/

Options:
  -h, --help               Show this message and exit.
  -r, --range RANGE|NAME   Export only images whose file number matches this
                           range expression. Observations on excluded images
                           are dropped. A range is file numbers and spans
                           separated by commas, and a span may take a step
                           after a ':', as in '7', '1-100', '1-10,20,30-40' or
                           '1-100:10' (every 10th number from 1 to 100). A
                           value with a letter in it is instead the name of a
                           named image list of the workspace (see --named-
                           image-list); give one name and one range, as two -r
                           options, to keep the list's members whose frame
                           number is in the range. A slice after the name,
                           quoted, takes part of the list by position, as for
                           a Python list: 'NAME[:30]' is its first 30 images,
                           'NAME[-30:]' its last 30 and 'NAME[::3]' every
                           third one.
  --named-image-list NAME  Use only the reconstruction's images that are
                           members of this named image list, defined in the
                           .sfm-named-image-lists.json of the reconstruction's
                           workspace. With -r RANGE, keep only the members
                           whose frame number is in RANGE. A slice after the
                           name, such as 'NAME[:30]', then takes part of the
                           members the reconstruction holds by position.
  --filter-points          With --range or --named-image-list, also drop 3D
                           points that have no remaining observations. Default
                           is to keep all 3D points.

sfm to-colmap-db

Usage: sfm to-colmap-db [OPTIONS] INPUT_PATH OUTPUT_DB_PATH

  Create a COLMAP database from a .sfmr or .matches file.

  INPUT_PATH must be either a .sfmr reconstruction file or a .matches file.
  OUTPUT_DB_PATH is where the COLMAP database file is written (e.g.
  database.db).

  From a .sfmr file:
    Creates a database with camera intrinsics, pose priors, keypoints,
    descriptors, and optionally two-view geometries with fundamental
    matrices computed from relative poses (for guided matching).

  From a .matches file:
    Creates a database with cameras, keypoints, descriptors, and
    pre-computed matches/two-view geometries from the file.

  Example usage:

      # From a reconstruction (with guided matching data)
      sfm to-colmap-db reconstruction.sfmr database.db

      # From a reconstruction, skip two-view geometry pre-population     sfm
      to-colmap-db reconstruction.sfmr database.db --no-guided-matching

      # From pre-computed matches     sfm to-colmap-db matches.matches
      database.db

Options:
  -h, --help                      Show this message and exit.
  --max-features INTEGER RANGE    Maximum number of features per image (only
                                  for .sfmr input).  [x>=1]
  --no-guided-matching            Disable pre-population of two-view
                                  geometries (only for .sfmr input).
  --camera-model [pinhole|simple_pinhole|simple_radial|radial|opencv|opencv_fisheye|full_opencv|simple_radial_fisheye|radial_fisheye|thin_prism_fisheye|rad_tan_thin_prism_fisheye]
                                  Camera model to use (e.g., OPENCV, PINHOLE):
                                  overrides auto-detection, and refits to this
                                  model the cameras a .camrig or
                                  camera_config.json supplies. Only for
                                  .matches input.

sfm to-nerfstudio

Usage: sfm to-nerfstudio [OPTIONS] INPUT_SFMR [OUTPUT_DIR]

  Convert a pinhole .sfmr reconstruction to a Nerfstudio dataset.

  Writes transforms.json, sparse_pc.ply, images/, and pyramid directories in
  the layout that nerfstudio's NerfstudioDataParser accepts. The output is
  directly trainable with `ns-train nerfacto --data <output>`.

  Input cameras must be pinhole (zero distortion). Run `sfm undistort` first
  if your reconstruction has lens distortion.

  OUTPUT_DIR defaults to <input>_nerfstudio/ next to the .sfmr.

  Example usage:

      sfm to-nerfstudio undistorted.sfmr my_dataset/
      sfm to-nerfstudio undistorted.sfmr my_dataset/ -r 10-50
      ns-train nerfacto --data my_dataset/

Options:
  -h, --help                      Show this message and exit.
  --num-downscales INTEGER RANGE  Number of image pyramid levels (writes
                                  images_2/, images_4/, ...). 0 disables.
                                  [default: 3; x>=0]
  --jpeg-quality INTEGER RANGE    JPEG quality for downsampled pyramid images.
                                  [default: 95; 1<=x<=100]
  --include-colmap                Also write a sparse/ directory with COLMAP
                                  .bin files.
  -r, --range RANGE|NAME          Export only images whose file number matches
                                  this range expression. Observations on
                                  excluded images are dropped. A range is file
                                  numbers and spans separated by commas, and a
                                  span may take a step after a ':', as in '7',
                                  '1-100', '1-10,20,30-40' or '1-100:10'
                                  (every 10th number from 1 to 100). A value
                                  with a letter in it is instead the name of a
                                  named image list of the workspace (see
                                  --named-image-list); give one name and one
                                  range, as two -r options, to keep the list's
                                  members whose frame number is in the range.
                                  A slice after the name, quoted, takes part
                                  of the list by position, as for a Python
                                  list: 'NAME[:30]' is its first 30 images,
                                  'NAME[-30:]' its last 30 and 'NAME[::3]'
                                  every third one.
  --named-image-list NAME         Use only the reconstruction's images that
                                  are members of this named image list,
                                  defined in the .sfm-named-image-lists.json
                                  of the reconstruction's workspace. With -r
                                  RANGE, keep only the members whose frame
                                  number is in RANGE. A slice after the name,
                                  such as 'NAME[:30]', then takes part of the
                                  members the reconstruction holds by
                                  position.
  --filter-points                 With --range or --named-image-list, also
                                  drop 3D points that have no remaining
                                  observations. Default is to keep all 3D
                                  points.

Other Commands

sfm version

Usage: sfm version [OPTIONS]

  Print the version and the facts that decide how sfmtool runs here.

  The first line is the package version and, unless the code is the release
  that version names, the commit it comes from, as `git describe` gives it.
  After it come the build, the install, Python, the OS, the CPU, the thread
  count, the SIMD level, memory, the GPU adapter, pycolmap with its CUDA
  support, numpy, OpenCV and ffmpeg, one per line, for bug reports.

Options:
  --bare  Print only the version line, which reads no other fact and is fast.
  --json  Print the same facts as one JSON object. With --bare, only its
          `sfmtool` key.
  --help  Show this message and exit.