MVG

Algorithm Implementations

hierarchical_bundle_adjust

class hierarchical_bundle_adjust : public kwiver::vital::algo::bundle_adjust

Public Functions

PLUGGABLE_IMPL (hierarchical_bundle_adjust, "Run a bundle adjustment algorithm in a temporally hierarchical fashion" " (useful for video)", PARAM_DEFAULT(initial_sub_sample, unsigned int, "Sub-sample the given cameras by this factor. Gaps will " "then be filled in by iterations of interpolation.", 1), PARAM_DEFAULT(interpolation_rate, unsigned int, "Number of cameras to fill in each iteration. When this " "is set to 0, we will interpolate all missing cameras " "at the first moment possible.", 0), PARAM_DEFAULT(rmse_reporting_enabled, bool, "Enable the reporting of RMSE statistics at various " "stages of this algorithm. Constant calculating of RMSE " "may effect run time of the algorithm.", false), PARAM(sba_impl, vital::algo::bundle_adjust_sptr, "pointer to the nested algorithm"), PARAM(camera_optimizer, vital::algo::optimize_cameras_sptr, "pointer to the nested algorithm"), PARAM(lm_triangulator, vital::algo::triangulate_landmarks_sptr, "pointer to the nested algorithm")) virtual ~hierarchical_bundle_adjust() noexcept

Destructor.

virtual bool check_configuration(vital::config_block_sptr config) const

Check that the algorithm’s configuration vital::config_block is valid.

virtual void optimize(vital::camera_map_sptr &cameras, vital::landmark_map_sptr &landmarks, vital::feature_track_set_sptr tracks, vital::sfm_constraints_sptr constraints = nullptr) const

Optimize the camera and landmark parameters given a set of tracks.

Making naive assuptions:

  • cameras we are given are in sequence (no previous sub-sampling and no frame gaps)

  • given camera map evenly interpolates with the current configuration

  • Assuming that all frames we interpolate have tracks/landmarks with which to optimize that camera over.

class priv

initialize_cameras_landmarks_basic

class initialize_cameras_landmarks_basic : public kwiver::vital::algo::initialize_cameras_landmarks

A class for initialization of cameras and landmarks.

Public Functions

PLUGGABLE_IMPL (initialize_cameras_landmarks_basic, "Run SfM to iteratively estimate new cameras and landmarks" " using feature tracks.", PARAM_DEFAULT(verbose, bool, "If true, write status messages to the terminal showing " "debugging information", false), PARAM_DEFAULT(init_from_last, bool, "If true, and a camera optimizer is specified, initialize " "the camera using the closest exiting camera and optimize", false), PARAM_DEFAULT(retriangulate_all, bool, "If true, re-triangulate all landmarks observed by a newly " "initialized camera.  Otherwise, only triangulate or " "re-triangulate landmarks that are marked for initialization.", false), PARAM_DEFAULT(reverse_ba_error_ratio, double, "After final bundle adjustment, if the Necker reversal of " "the solution increases the RMSE by less than this factor, " "then run a bundle adjustment on the reversed data and " "choose the final solution with the lowest error.  Set to " "zero to disable.", 2.0), PARAM_DEFAULT(next_frame_max_distance, unsigned int, "Limit the selection of the next frame to initialize to " "within this many frames of an already initialized frame. " "If no valid frames are found, double the search range " "until a valid frame is found. " "A value of zero disables this limit", 0), PARAM_DEFAULT(global_ba_rate, double, "Run a global bundle adjustment every time the number of " "cameras in the system grows by this multiple.", 1.5), PARAM_DEFAULT(interim_reproj_thresh, double, "Threshold for rejecting landmarks based on reprojection " "error (in pixels) during intermediate processing steps.", 5.0), PARAM_DEFAULT(final_reproj_thresh, double, "Relative threshold for rejecting landmarks based on " "reprojection error relative to the median error after " "the final bundle adjustment.  For example, a value of 2 " "mean twice the median error", 2.0), PARAM_DEFAULT(zoom_scale_thresh, double, "Threshold on image scale change used to detect a camera " "zoom. If the resolution on target changes by more than " "this fraction create a new camera intrinsics model.", 0.1), PARAM_DEFAULT(base_camera_focal_length, double, "focal length of the base camera model", 1.0), PARAM_DEFAULT(base_camera_principal_point, vital::vector_2d, "The principal point of the base camera model \"x y\".\n" "It is usually safe to assume this is the center of the " "image.", vital::vector_2d({ 0, 0 })), PARAM_DEFAULT(base_camera_aspect_ratio, double, "the pixel aspect ratio of the base camera model", 1.5), PARAM_DEFAULT(base_camera_skew, double, "The skew factor of the base camera model.\n" "This is almost always zero in any real camera.", 0.0), PARAM(base_camera, vital::camera_intrinsics_sptr, "base camera model parameters group"), PARAM(essential_mat_estimator, vital::algo::estimate_essential_matrix_sptr, "pointer to the nested algorithm"), PARAM(camera_optimizer, vital::algo::optimize_cameras_sptr, "pointer to the nested algorithm"), PARAM(lm_triangulator, vital::algo::triangulate_landmarks_sptr, "pointer to the nested algorithm"), PARAM(bundle_adjuster, vital::algo::bundle_adjust_sptr, "pointer to the nested algorithm")) virtual ~initialize_cameras_landmarks_basic()

Destructor.

initialize_cameras_landmarks_basic(const initialize_cameras_landmarks_basic &other)

Copy Constructor.

virtual bool check_configuration(vital::config_block_sptr config) const

Check that the algorithm’s currently configuration is valid.

virtual void initialize(vital::camera_map_sptr &cameras, vital::landmark_map_sptr &landmarks, vital::feature_track_set_sptr tracks, vital::sfm_constraints_sptr constraints = nullptr) const

Initialize the camera and landmark parameters given a set of feature tracks The algorithm creates an initial estimate of any missing cameras and landmarks using the available cameras, landmarks, and feature tracks. If the input cameras map is a NULL pointer then the algorithm should try to initialize all cameras covered by the track set. If the input camera map exists then the algorithm should only initialize cameras on frames for which the camera is set to NULL. Frames not in the map will not be initialized. This allows the caller to control which subset of cameras to initialize without needing to manipulate the feature tracks. The analogous behavior is also applied to the input landmarks map to select which track IDs should be used to initialize landmarks.

Note

This algorithm may optionally revise the estimates of existing cameras and landmarks passed as input.

Parameters:
  • cameras[inout] the cameras to initialize

  • landmarks[inout] the landmarks to initialize

  • tracks[in] the feature tracks to use as constraints

  • metadata[in] the frame metadata to use as constraints

virtual void set_callback(callback_t cb)

Set a callback function to report intermediate progress.

class priv

initialize_cameras_landmarks

class initialize_cameras_landmarks : public kwiver::vital::algo::initialize_cameras_landmarks

A class for initialization of cameras and landmarks.

Public Functions

PLUGGABLE_IMPL (initialize_cameras_landmarks, "Run SfM to estimate new cameras and landmarks " "using feature tracks.", PARAM_DEFAULT(verbose, bool, "If true, write status messages to the terminal showing " "debugging information", false), PARAM_DEFAULT(force_common_intrinsics, bool, "If true, then all cameras will share a single set of camera " "intrinsic parameters", true), PARAM_DEFAULT(frac_frames_for_init, double, "fraction of keyframes used in relative pose initialization", -1.0), PARAM_DEFAULT(min_frame_to_frame_matches, unsigned int, "Minimum number of frame-to-frame feature matches " "required to attempt reconstruction", 100), PARAM_DEFAULT(interim_reproj_thresh, double, "Threshold for rejecting landmarks based on reprojection " "error (in pixels) during intermediate processing steps.", 10.0), PARAM_DEFAULT(final_reproj_thresh, double, "Relative threshold for rejecting landmarks based on " "reprojection error relative to the median error after " "the final bundle adjustment.  For example, a value of 2 " "mean twice the median error", 2.0), PARAM_DEFAULT(zoom_scale_thresh, double, "Threshold on image scale change used to detect a camera " "zoom. If the resolution on target changes by more than " "this fraction create a new camera intrinsics model.", 0.1), PARAM_DEFAULT(base_camera_focal_length, double, "focal length of the base camera model", 1.0), PARAM_DEFAULT(base_camera_principal_point, vital::vector_2d, "The principal point of the base camera model \"x y\".\n" "It is usually safe to assume this is the center of the " "image.", vital::vector_2d({ 0, 0 })), PARAM_DEFAULT(base_camera_aspect_ratio, double, "the pixel aspect ratio of the base camera model", 1.5), PARAM_DEFAULT(base_camera_skew, double, "The skew factor of the base camera model.\n" "This is almost always zero in any real camera.", 0.0), PARAM_DEFAULT(max_cams_in_keyframe_init, int, "the maximum number of cameras to reconstruct in " "initialization step before switching to resectioning " "remaining cameras.", 20), PARAM_DEFAULT(metadata_init_permissive_triang_thresh, double, "threshold to apply to triangulation in the first " "permissive rounds of metadata based reconstruction " "initialization", 10000.0), PARAM_DEFAULT(feature_angle_threshold, double, "feature must have this triangulation angle to keep, in degrees", 2.0), PARAM_DEFAULT(do_final_sfm_cleaning, bool, "run a final sfm solution cleanup when solution is complete", false), PARAM(essential_mat_estimator, vital::algo::estimate_essential_matrix_sptr, "pointer to the nested algorithm"), PARAM(camera_optimizer, vital::algo::optimize_cameras_sptr, "pointer to the nested algorithm"), PARAM(lm_triangulator, vital::algo::triangulate_landmarks_sptr, "pointer to the nested algorithm"), PARAM(bundle_adjuster, vital::algo::bundle_adjust_sptr, "pointer to the nested algorithm"), PARAM(global_bundle_adjuster, vital::algo::bundle_adjust_sptr, "pointer to the nested algorithm"), PARAM(estimate_pnp, vital::algo::estimate_pnp_sptr, "pointer to the nested algorithm"), PARAM(canonical_estimator, vital::algo::estimate_canonical_transform_sptr, "pointer to the nested algorithm"), PARAM(similarity_estimator, vital::algo::estimate_similarity_transform_sptr, "pointer to the nested algorithm")) virtual ~initialize_cameras_landmarks()

Destructor.

virtual bool check_configuration(vital::config_block_sptr config) const

Check that the algorithm’s currently configuration is valid.

virtual void initialize(vital::camera_map_sptr &cameras, vital::landmark_map_sptr &landmarks, vital::feature_track_set_sptr tracks, vital::sfm_constraints_sptr constraints = nullptr) const

Initialize the camera and landmark parameters given a set of tracks.

Initialize the camera and landmark parameters given a set of feature tracks The algorithm creates an initial estimate of any missing cameras and landmarks using the available cameras, landmarks, and feature tracks. It may optionally revise the estimates of exisiting cameras and landmarks.

Parameters:
  • cameras[inout] the cameras to initialize

  • landmarks[inout] the landmarks to initialize

  • tracks[in] the feature tracks to use as constraints

  • metadata[in] the frame metadata to use as constraints

virtual void set_callback(callback_t cb)

Set a callback function to report intermediate progress.

integrate_depth_maps

class integrate_depth_maps : public kwiver::vital::algo::integrate_depth_maps

Public Functions

PLUGGABLE_IMPL (integrate_depth_maps, "CPU depth map fusion", PARAM_DEFAULT(ray_potential_thickness, double, "Distance that the TSDF covers sloping from Rho to zero. " "Units are in voxels.", 20.0), PARAM_DEFAULT(ray_potential_rho, double, "Maximum magnitude of the TDSF", 1.0), PARAM_DEFAULT(ray_potential_eta, double, "Fraction of rho to use for free space constraint. " "Requires 0 <= Eta <= 1.", 1.0), PARAM_DEFAULT(ray_potential_epsilon, double, "Fraction of rho to use in occluded space. " "Requires 0 <= Epsilon <= 1.", 0.01), PARAM_DEFAULT(ray_potential_delta, double, "Distance from the surface before the TSDF is truncate. " "Units are in voxels", 10.0), PARAM_DEFAULT(voxel_spacing_factor, double, "Multiplier on voxel spacing.  Set to 1.0 for voxel " "sizes that project to 1 pixel on average.", 1.0), PARAM_DEFAULT(grid_spacing, array3, "Relative spacing for each dimension of the grid", array3({ 1., 1., 1. }))) virtual ~integrate_depth_maps()

Destructor.

virtual void initialize() override

Constructor.

virtual bool check_configuration(vital::config_block_sptr config) const

Check that the algorithm’s currently configuration is valid.

virtual void integrate(kwiver::vital::vector_3d const &minpt_bound, kwiver::vital::vector_3d const &maxpt_bound, std::vector<kwiver::vital::image_container_sptr> const &depth_maps, std::vector<kwiver::vital::image_container_sptr> const &weight_maps, std::vector<kwiver::vital::camera_perspective_sptr> const &cameras, kwiver::vital::image_container_sptr &volume, kwiver::vital::vector_3d &spacing) const

Integrate multiple depth maps with per-pixel weights into a common volume

The weight maps in this variant encode how much weight to give each depth pixel in the integration sum. If the vector of weight_maps is empty then all depths are given full weight.

Note

the volume data is stored as a 3D image. Metadata fields on the image specify the origin and scale of the volume in world coordinates.

Parameters:
  • minpt_bound[in] the min point of the bounding region

  • maxpt_bound[in] the max point of the bounding region

  • depth_maps[in] the set of floating point depth map images

  • weight_maps[in] the set of floating point [0,1] weight maps

  • cameras[in] the set of cameras, one for each depth map

  • volume[inout] the fused volumetric data

  • spacing[out] the spacing between voxels in each dimension

triangulate_landmarks

class triangulate_landmarks : public kwiver::vital::algo::triangulate_landmarks

A class for triangulating landmarks from feature tracks and cameras using Eigen

Public Functions

PLUGGABLE_IMPL (triangulate_landmarks, "Triangulate landmarks from tracks and cameras" " using a simple least squares solver.", PARAM_DEFAULT(homogeneous, bool, "Use the homogeneous method for triangulating points. " "The homogeneous method can triangulate points at or near " "infinity and discard them.", false), PARAM_DEFAULT(ransac, bool, "Use RANSAC in triangulating the points", true), PARAM_DEFAULT(min_angle_deg, float, "minimum angle required to triangulate a point.", 1.0f), PARAM_DEFAULT(inlier_threshold_pixels, float, "reprojection error threshold in pixels.", 2.0f), PARAM_DEFAULT(frac_track_inliers_to_keep_triangulated_point, float, "fraction of measurements in track that must be inliers to " "keep the triangulated point", 0.5f), PARAM_DEFAULT(max_ransac_samples, int, "maximum number of samples to take in RANSAC triangulation", 20), PARAM_DEFAULT(conf_thresh, double, "RANSAC sampling terminates when this confidences in the " "solution is reached.", 0.99)) virtual ~triangulate_landmarks()

Destructor.

virtual bool check_configuration(vital::config_block_sptr config) const

Check that the algorithm’s currently configuration is valid.

virtual void triangulate(vital::camera_map_sptr cameras, vital::feature_track_set_sptr tracks, vital::landmark_map_sptr &landmarks) const

Triangulate the landmark locations given sets of cameras and feature tracks

This function only triangulates the landmarks with indicies in the landmark map and which have support in the tracks and cameras. Note: triangulate modifies the inlier/outlier flags in tracks. It also sets the cosine of the maximum observation angle and number of observations in the landmarks.

Parameters:
  • cameras[in] the cameras viewing the landmarks

  • tracks[in] the feature tracks to use as constraints

  • landmarks[inout] the landmarks to triangulate

virtual void triangulate(vital::camera_map_sptr cameras, vital::track_map_t tracks, vital::landmark_map_sptr &landmarks) const

Triangulate the landmark locations given sets of cameras and feature tracks

This function only triangulates the landmarks with indicies in the landmark map and which have support in the tracks and cameras. Note: triangulate modifies the inlier/outlier flags in tracks. It also sets the cosine of the maximum observation angle and number of observations in the landmarks.

Parameters:
  • cameras[in] the cameras viewing the landmarks

  • tracks[in] the feature tracks to use as constraints in a map

  • landmarks[inout] the landmarks to triangulate