Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
vpgl_bundle_adjust Class Reference

Static functions for bundle adjustment. More...

#include <vpgl_bundle_adjust.h>

Public Member Functions

 vpgl_bundle_adjust ()
 Constructor. More...
 
 ~vpgl_bundle_adjust ()
 Destructor. More...
 
void set_use_m_estimator (bool use_m)
 
void set_m_estimator_scale (double scale)
 
void set_use_gradient (bool use_gradient)
 
void set_self_calibrate (bool self_calibrate)
 
void set_normalize_data (bool normalize)
 
void set_verbose (bool verbose)
 
void set_max_iterations (unsigned maxitr)
 
void set_x_tolerence (double xtol)
 
void set_g_tolerence (double gtol)
 
void set_epsilon (double eps)
 step size for finite differencing operations. More...
 
double end_error () const
 Return the ending error. More...
 
double start_error () const
 Return the starting error. More...
 
int num_iterations () const
 Return the number of iterations. More...
 
const std::vector< double > & final_weights () const
 Return the weights a the end of the optimization. More...
 
const vnl_vector< double > & cam_params () const
 Return the raw camera parameters. More...
 
const vnl_vector< double > & point_params () const
 Return the raw world point parameters. More...
 
void depth_reverse (std::vector< vpgl_perspective_camera< double > > &cameras, std::vector< vgl_point_3d< double > > &world_points)
 Approximately depth invert the scene. More...
 
bool optimize (std::vector< vpgl_perspective_camera< double > > &cameras, std::vector< vgl_point_3d< double > > &world_points, const std::vector< vgl_point_2d< double > > &image_points, const std::vector< std::vector< bool > > &mask)
 Bundle Adjust. More...
 

Static Public Member Functions

static void write_vrml (const std::string &filename, const std::vector< vpgl_perspective_camera< double > > &cameras, const std::vector< vgl_point_3d< double > > &world_points)
 Write cameras and points to a file in VRML 2.0 for debugging. More...
 

Private Member Functions

void normalize_points (std::vector< vgl_point_2d< double > > &image_points, double &nx, double &ny, double &ns)
 normalize image points to be mean centered with scale sqrt(2). More...
 
void reflect_points (const vgl_plane_3d< double > &plane, std::vector< vgl_point_3d< double > > &points)
 
void rotate_cameras (const vgl_vector_3d< double > &axis, std::vector< vpgl_perspective_camera< double > > &cameras)
 

Private Attributes

vpgl_bundle_adjust_lsqrba_func_
 The bundle adjustment error function. More...
 
vnl_vector< double > a_
 The last camera parameters. More...
 
vnl_vector< double > b_
 The last point parameters. More...
 
vnl_vector< double > c_
 The last global parameters. More...
 
std::vector< double > weights_
 The last estimated weights. More...
 
bool use_m_estimator_
 
double m_estimator_scale_
 
bool use_gradient_
 
bool self_calibrate_
 
bool normalize_data_
 
bool verbose_
 
unsigned int max_iterations_
 
double x_tol_
 
double g_tol_
 
double epsilon_
 
double start_error_
 
double end_error_
 
int num_iterations_
 

Detailed Description

Static functions for bundle adjustment.

Definition at line 27 of file vpgl_bundle_adjust.h.

Constructor & Destructor Documentation

◆ vpgl_bundle_adjust()

vpgl_bundle_adjust::vpgl_bundle_adjust ( )

Constructor.

Definition at line 22 of file vpgl_bundle_adjust.cxx.

◆ ~vpgl_bundle_adjust()

vpgl_bundle_adjust::~vpgl_bundle_adjust ( )

Destructor.

Definition at line 39 of file vpgl_bundle_adjust.cxx.

Member Function Documentation

◆ cam_params()

const vnl_vector<double>& vpgl_bundle_adjust::cam_params ( ) const
inline

Return the raw camera parameters.

Definition at line 57 of file vpgl_bundle_adjust.h.

◆ depth_reverse()

void vpgl_bundle_adjust::depth_reverse ( std::vector< vpgl_perspective_camera< double > > &  cameras,
std::vector< vgl_point_3d< double > > &  points 
)

Approximately depth invert the scene.

Apply this and re-optimize to get out of a common local minimum. Find the mean axis between cameras and points, mirror the points about a plane perpendicular to this axis, and rotate the cameras 180 degrees around this axis

Definition at line 116 of file vpgl_bundle_adjust.cxx.

◆ end_error()

double vpgl_bundle_adjust::end_error ( ) const
inline

Return the ending error.

Definition at line 48 of file vpgl_bundle_adjust.h.

◆ final_weights()

const std::vector<double>& vpgl_bundle_adjust::final_weights ( ) const
inline

Return the weights a the end of the optimization.

Definition at line 54 of file vpgl_bundle_adjust.h.

◆ normalize_points()

void vpgl_bundle_adjust::normalize_points ( std::vector< vgl_point_2d< double > > &  image_points,
double &  nx,
double &  ny,
double &  ns 
)
private

normalize image points to be mean centered with scale sqrt(2).

Returns
parameters such that original point are recovered as (ns*x+nx, ns*y+ny)

Definition at line 47 of file vpgl_bundle_adjust.cxx.

◆ num_iterations()

int vpgl_bundle_adjust::num_iterations ( ) const
inline

Return the number of iterations.

Definition at line 52 of file vpgl_bundle_adjust.h.

◆ optimize()

bool vpgl_bundle_adjust::optimize ( std::vector< vpgl_perspective_camera< double > > &  cameras,
std::vector< vgl_point_3d< double > > &  world_points,
const std::vector< vgl_point_2d< double > > &  image_points,
const std::vector< std::vector< bool > > &  mask 
)

Bundle Adjust.

Parameters
maskshould have the same number of entries as
cameras,andeach entry of
maskshould be the same size as
world_points.mask[i][j] is true if point j is visible from camera i
image_pointsand is a linear list of the 2D locations of the 3D points as seen by the cameras. There is one image point for every true in
mask.The following piece of code shows the structure of
image_pointsfor( int c = 0; c < num_cameras; c++ ){ for( int dp = 0; dp < num_world_points; dp++ ){ if( mask[c][dp] ) img_points.push_back( all_image_points[c*num_world_points+dp] ); } }

Definition at line 149 of file vpgl_bundle_adjust.cxx.

◆ point_params()

const vnl_vector<double>& vpgl_bundle_adjust::point_params ( ) const
inline

Return the raw world point parameters.

Definition at line 59 of file vpgl_bundle_adjust.h.

◆ reflect_points()

void vpgl_bundle_adjust::reflect_points ( const vgl_plane_3d< double > &  plane,
std::vector< vgl_point_3d< double > > &  points 
)
private

Definition at line 78 of file vpgl_bundle_adjust.cxx.

◆ rotate_cameras()

void vpgl_bundle_adjust::rotate_cameras ( const vgl_vector_3d< double > &  axis,
std::vector< vpgl_perspective_camera< double > > &  cameras 
)
private

Definition at line 93 of file vpgl_bundle_adjust.cxx.

◆ set_epsilon()

void vpgl_bundle_adjust::set_epsilon ( double  eps)
inline

step size for finite differencing operations.

Definition at line 45 of file vpgl_bundle_adjust.h.

◆ set_g_tolerence()

void vpgl_bundle_adjust::set_g_tolerence ( double  gtol)
inline

Definition at line 43 of file vpgl_bundle_adjust.h.

◆ set_m_estimator_scale()

void vpgl_bundle_adjust::set_m_estimator_scale ( double  scale)
inline

Definition at line 36 of file vpgl_bundle_adjust.h.

◆ set_max_iterations()

void vpgl_bundle_adjust::set_max_iterations ( unsigned  maxitr)
inline

Definition at line 41 of file vpgl_bundle_adjust.h.

◆ set_normalize_data()

void vpgl_bundle_adjust::set_normalize_data ( bool  normalize)
inline

Definition at line 39 of file vpgl_bundle_adjust.h.

◆ set_self_calibrate()

void vpgl_bundle_adjust::set_self_calibrate ( bool  self_calibrate)
inline

Definition at line 38 of file vpgl_bundle_adjust.h.

◆ set_use_gradient()

void vpgl_bundle_adjust::set_use_gradient ( bool  use_gradient)
inline

Definition at line 37 of file vpgl_bundle_adjust.h.

◆ set_use_m_estimator()

void vpgl_bundle_adjust::set_use_m_estimator ( bool  use_m)
inline

Definition at line 35 of file vpgl_bundle_adjust.h.

◆ set_verbose()

void vpgl_bundle_adjust::set_verbose ( bool  verbose)
inline

Definition at line 40 of file vpgl_bundle_adjust.h.

◆ set_x_tolerence()

void vpgl_bundle_adjust::set_x_tolerence ( double  xtol)
inline

Definition at line 42 of file vpgl_bundle_adjust.h.

◆ start_error()

double vpgl_bundle_adjust::start_error ( ) const
inline

Return the starting error.

Definition at line 50 of file vpgl_bundle_adjust.h.

◆ write_vrml()

void vpgl_bundle_adjust::write_vrml ( const std::string &  filename,
const std::vector< vpgl_perspective_camera< double > > &  cameras,
const std::vector< vgl_point_3d< double > > &  world_points 
)
static

Write cameras and points to a file in VRML 2.0 for debugging.

Definition at line 268 of file vpgl_bundle_adjust.cxx.

Member Data Documentation

◆ a_

vnl_vector<double> vpgl_bundle_adjust::a_
private

The last camera parameters.

Definition at line 114 of file vpgl_bundle_adjust.h.

◆ b_

vnl_vector<double> vpgl_bundle_adjust::b_
private

The last point parameters.

Definition at line 116 of file vpgl_bundle_adjust.h.

◆ ba_func_

vpgl_bundle_adjust_lsqr* vpgl_bundle_adjust::ba_func_
private

The bundle adjustment error function.

Definition at line 112 of file vpgl_bundle_adjust.h.

◆ c_

vnl_vector<double> vpgl_bundle_adjust::c_
private

The last global parameters.

Definition at line 118 of file vpgl_bundle_adjust.h.

◆ end_error_

double vpgl_bundle_adjust::end_error_
private

Definition at line 134 of file vpgl_bundle_adjust.h.

◆ epsilon_

double vpgl_bundle_adjust::epsilon_
private

Definition at line 131 of file vpgl_bundle_adjust.h.

◆ g_tol_

double vpgl_bundle_adjust::g_tol_
private

Definition at line 130 of file vpgl_bundle_adjust.h.

◆ m_estimator_scale_

double vpgl_bundle_adjust::m_estimator_scale_
private

Definition at line 123 of file vpgl_bundle_adjust.h.

◆ max_iterations_

unsigned int vpgl_bundle_adjust::max_iterations_
private

Definition at line 128 of file vpgl_bundle_adjust.h.

◆ normalize_data_

bool vpgl_bundle_adjust::normalize_data_
private

Definition at line 126 of file vpgl_bundle_adjust.h.

◆ num_iterations_

int vpgl_bundle_adjust::num_iterations_
private

Definition at line 135 of file vpgl_bundle_adjust.h.

◆ self_calibrate_

bool vpgl_bundle_adjust::self_calibrate_
private

Definition at line 125 of file vpgl_bundle_adjust.h.

◆ start_error_

double vpgl_bundle_adjust::start_error_
private

Definition at line 133 of file vpgl_bundle_adjust.h.

◆ use_gradient_

bool vpgl_bundle_adjust::use_gradient_
private

Definition at line 124 of file vpgl_bundle_adjust.h.

◆ use_m_estimator_

bool vpgl_bundle_adjust::use_m_estimator_
private

Definition at line 122 of file vpgl_bundle_adjust.h.

◆ verbose_

bool vpgl_bundle_adjust::verbose_
private

Definition at line 127 of file vpgl_bundle_adjust.h.

◆ weights_

std::vector<double> vpgl_bundle_adjust::weights_
private

The last estimated weights.

Definition at line 120 of file vpgl_bundle_adjust.h.

◆ x_tol_

double vpgl_bundle_adjust::x_tol_
private

Definition at line 129 of file vpgl_bundle_adjust.h.


The documentation for this class was generated from the following files: