Ceres¶
Bundle Adjust Algorithm¶
-
class
kwiver::arrows::ceres::
bundle_adjust
¶ A class for bundle adjustment of feature tracks using Ceres.
Inherits from kwiver::vital::algorithm_impl< bundle_adjust, vital::algo::bundle_adjust >
Public Functions
-
bundle_adjust
()¶ Constructor.
-
~bundle_adjust
()¶ Destructor.
-
config_block_sptr
get_configuration
() const¶ Get this algorithm’s configuration block .
-
void
set_configuration
(vital::config_block_sptr config)¶ Set this algorithm’s properties via a config block.
-
bool
check_configuration
(vital::config_block_sptr config) const¶ Check that the algorithm’s currently configuration is valid.
-
void
optimize
(vital::camera_map_sptr &cameras, vital::landmark_map_sptr &landmarks, vital::feature_track_set_sptr tracks, vital::video_metadata_map_sptr metadata = nullptr) const¶ Optimize the camera and landmark parameters given a set of feature tracks.
Optimize the camera and landmark parameters given a set of tracks.
- Parameters
cameras
: the cameras to optimizelandmarks
: the landmarks to optimizetracks
: the feature tracks to use as constraintsmetadata
: the frame metadata to use as constraints
-
void
set_callback
(callback_t cb)¶ Set a callback function to report intermediate progress.
-
bool
trigger_callback
()¶ This function is called by a Ceres callback to trigger a kwiver callback.
-
class
priv
¶ Private implementation class.
Inherits from kwiver::arrows::ceres::solver_options, kwiver::arrows::ceres::camera_options
Public Functions
-
priv
()¶ Constructor.
Public Members
-
bool
verbose
¶ verbose output
-
LossFunctionType
loss_function_type
¶ the robust loss function type to use
-
double
loss_function_scale
¶ the scale of the loss function
-
camera_map::map_camera_t
cams
¶ the input cameras to update in place
-
landmark_map::map_landmark_t
lms
¶ the input landmarks to update in place
-
std::map<track_id_t, std::vector<double>>
landmark_params
¶ a map from track id to landmark parameters
-
std::map<frame_id_t, std::vector<double>>
camera_params
¶ a map from frame number to extrinsic parameters
-
std::vector<std::vector<double>>
camera_intr_params
¶ vector of unique camera intrinsic parameters
-
std::map<frame_id_t, unsigned int>
frame_to_intr_map
¶ a map from frame number to index of unique camera intrinsics in camera_intr_params
-
StateCallback
ceres_callback
¶ the ceres callback class
-
vital::logger_handle_t
m_logger
¶ Logger handle.
-
-
Optimize Cameras Algorithm¶
-
class
kwiver::arrows::ceres::
optimize_cameras
¶ A class for optimization of camera paramters using Ceres.
Inherits from kwiver::vital::algorithm_impl< optimize_cameras, vital::algo::optimize_cameras >
Public Functions
-
optimize_cameras
()¶ Constructor.
-
~optimize_cameras
()¶ Destructor.
-
optimize_cameras
(const optimize_cameras &other)¶ Copy Constructor.
-
config_block_sptr
get_configuration
() const¶ Get this algorithm’s configuration block .
-
void
set_configuration
(vital::config_block_sptr config)¶ Set this algorithm’s properties via a config block.
-
bool
check_configuration
(vital::config_block_sptr config) const¶ Check that the algorithm’s currently configuration is valid.
-
void
optimize
(kwiver::vital::camera_map_sptr &cameras, kwiver::vital::feature_track_set_sptr tracks, kwiver::vital::landmark_map_sptr landmarks, kwiver::vital::video_metadata_map_sptr metadata = nullptr) const¶ Optimize camera parameters given sets of landmarks and feature tracks.
We only optimize cameras that have associating tracks and landmarks in the given maps. The default implementation collects the corresponding features and landmarks for each camera and calls the single camera optimize function.
- Exceptions
invalid_value
: When one or more of the given pointer is Null.
- Parameters
cameras
: Cameras to optimize.tracks
: The feature tracks to use as constraints.landmarks
: The landmarks the cameras are viewing.metadata
: The optional metadata to constrain the optimization.
-
void
optimize
(vital::camera_sptr &camera, const std::vector<vital::feature_sptr> &features, const std::vector<vital::landmark_sptr> &landmarks, kwiver::vital::video_metadata_vector metadata = kwiver::vital::video_metadata_vector()) const¶ Optimize a single camera given corresponding features and landmarks.
This function assumes that 2D features viewed by this camera have already been put into correspondence with 3D landmarks by aligning them into two parallel vectors
- Parameters
camera
: The camera to optimize.features
: The vector of features observed bycamera
to use as constraints.landmarks
: The vector of landmarks corresponding tofeatures
.metadata
: The optional metadata to constrain the optimization.
-
Camera Position Smoothness Class¶
-
class
kwiver::arrows::ceres::
camera_position_smoothness
¶ Ceres camera smoothness functor.
Public Functions
-
camera_position_smoothness
(const double smoothness)¶ Constructor.
- template <typename T>
-
bool
operator()
(const T *const prev_pose, const T *const curr_pose, const T *const next_pose, T *residuals) const¶ Position smoothness error functor for use in Ceres.
- Parameters
prev_pos
: Camera pose data block at previous timecurr_pos
: Camera pose data block at current timenext_pos
: Camera pose data block at next timeresiduals
: Camera pose blocks contain 6 parameters: 3 for rotation(angle axis), 3 for center Only the camera centers are used in this function to penalize the difference between current position and the average between previous and next positions.
Public Static Functions
-
ceres::CostFunction *
create
(const double s)¶ Cost function factory.
-
Camera Limit Forward Motion Class¶
-
class
kwiver::arrows::ceres::
camera_limit_forward_motion
¶ Ceres camera limit forward motion functor.
This class is to reglarize camera motion to minimize the amount of motion in the camera looking direction. This is useful with zoom lenses at long focal lengths where distance and zoom are ambiguous. Adding this constraint allows the optimization to prefer fast zoom changes over fast position change.
Public Functions
-
camera_limit_forward_motion
(const double scale)¶ Constructor.
- template <typename T>
-
bool
operator()
(const T *const pose1, const T *const pose2, T *residuals) const¶ Camera forward motion error functor for use in Ceres.
- Parameters
pose1
: Camera pose data block at time 1pose2
: Camera pose data block at time 2residuals
: Camera pose blocks contain 6 parameters: 3 for rotation(angle axis), 3 for center
Public Members
-
double
scale_
¶ the magnitude of this constraint
Public Static Functions
-
ceres::CostFunction *
create
(const double s)¶ Cost function factory.
-
Distortion Poly Radial Class¶
-
class
kwiver::arrows::ceres::
distortion_poly_radial
¶ Class to hold to distortion function and traits.
Public Static Functions
- template <typename T>
-
static void
apply
(const T *dist_coeffs, const T *source_xy, T *distorted_xy)¶ Function to apply polynomial radial distortion.
- Parameters
dist_coeffs
: radial distortion coefficients (2)source_xy
: 2D point in normalized image coordinatesdistorted_xy
: 2D point in distorted normalized image coordinates
Distortion Poly Radial Tangential Class¶
-
class
kwiver::arrows::ceres::
distortion_poly_radial_tangential
¶ Class to hold to distortion function and traits.
Public Static Functions
- template <typename T>
-
static void
apply
(const T *dist_coeffs, const T *source_xy, T *distorted_xy)¶ Function to apply polynomial radial and tangential distortion.
- Parameters
dist_coeffs
: radial (3) and tangential (2) distortion coefficientssource_xy
: 2D point in normalized image coordinatesdistorted_xy
: 2D point in distorted normalized image coordinates
Distortion Ratpoly Radial Tangential Class¶
-
class
kwiver::arrows::ceres::
distortion_ratpoly_radial_tangential
¶ Class to hold to distortion function and traits.
Public Static Functions
- template <typename T>
-
static void
apply
(const T *dist_coeffs, const T *source_xy, T *distorted_xy)¶ Function to apply rational polynomial radial and tangential distortion.
- Parameters
dist_coeffs
: radial (6) and tangential (2) distortion coefficientssource_xy
: 2D point in normalized image coordinatesdistorted_xy
: 2D point in distorted normalized image coordinates