Static functions for bundle adjustment. More...
#include <vpgl_bundle_adjust.h>
Public Member Functions | |
vpgl_bundle_adjust () | |
Constructor. | |
~vpgl_bundle_adjust () | |
Destructor. | |
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. | |
double | end_error () const |
Return the ending error. | |
double | start_error () const |
Return the starting error. | |
int | num_iterations () const |
Return the number of iterations. | |
const vcl_vector< double > & | final_weights () const |
Return the weights a the end of the optimization. | |
const vnl_vector< double > & | cam_params () const |
Return the raw camera parameters. | |
const vnl_vector< double > & | point_params () const |
Return the raw world point parameters. | |
void | depth_reverse (vcl_vector< vpgl_perspective_camera< double > > &cameras, vcl_vector< vgl_point_3d< double > > &world_points) |
Approximately depth invert the scene. | |
bool | optimize (vcl_vector< vpgl_perspective_camera< double > > &cameras, vcl_vector< vgl_point_3d< double > > &world_points, const vcl_vector< vgl_point_2d< double > > &image_points, const vcl_vector< vcl_vector< bool > > &mask) |
Bundle Adjust. | |
Static Public Member Functions | |
static void | write_vrml (const vcl_string &filename, const vcl_vector< vpgl_perspective_camera< double > > &cameras, const vcl_vector< vgl_point_3d< double > > &world_points) |
Write cameras and points to a file in VRML 2.0 for debugging. | |
Private Member Functions | |
void | normalize_points (vcl_vector< vgl_point_2d< double > > &image_points, double &nx, double &ny, double &ns) |
normalize image points to be mean centered with scale sqrt(2). | |
void | reflect_points (const vgl_plane_3d< double > &plane, vcl_vector< vgl_point_3d< double > > &points) |
void | rotate_cameras (const vgl_vector_3d< double > &axis, vcl_vector< vpgl_perspective_camera< double > > &cameras) |
Private Attributes | |
vpgl_bundle_adjust_lsqr * | ba_func_ |
The bundle adjustment error function. | |
vnl_vector< double > | a_ |
The last camera parameters. | |
vnl_vector< double > | b_ |
The last point parameters. | |
vnl_vector< double > | c_ |
The last global parameters. | |
vcl_vector< double > | weights_ |
The last estimated weights. | |
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_ |
Static functions for bundle adjustment.
Definition at line 24 of file vpgl_bundle_adjust.h.
vpgl_bundle_adjust::vpgl_bundle_adjust | ( | ) |
Constructor.
Definition at line 19 of file vpgl_bundle_adjust.cxx.
vpgl_bundle_adjust::~vpgl_bundle_adjust | ( | ) |
Destructor.
Definition at line 36 of file vpgl_bundle_adjust.cxx.
const vnl_vector<double>& vpgl_bundle_adjust::cam_params | ( | ) | const [inline] |
Return the raw camera parameters.
Definition at line 54 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::depth_reverse | ( | vcl_vector< vpgl_perspective_camera< double > > & | cameras, |
vcl_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 114 of file vpgl_bundle_adjust.cxx.
double vpgl_bundle_adjust::end_error | ( | ) | const [inline] |
Return the ending error.
Definition at line 45 of file vpgl_bundle_adjust.h.
const vcl_vector<double>& vpgl_bundle_adjust::final_weights | ( | ) | const [inline] |
Return the weights a the end of the optimization.
Definition at line 51 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::normalize_points | ( | vcl_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).
Definition at line 44 of file vpgl_bundle_adjust.cxx.
int vpgl_bundle_adjust::num_iterations | ( | ) | const [inline] |
Return the number of iterations.
Definition at line 49 of file vpgl_bundle_adjust.h.
bool vpgl_bundle_adjust::optimize | ( | vcl_vector< vpgl_perspective_camera< double > > & | cameras, |
vcl_vector< vgl_point_3d< double > > & | world_points, | ||
const vcl_vector< vgl_point_2d< double > > & | image_points, | ||
const vcl_vector< vcl_vector< bool > > & | mask | ||
) |
Bundle Adjust.
mask | should have the same number of entries as |
cameras,and | each entry of |
mask | should be the same size as |
world_points. | mask[i][j] is true if point j is visible from camera i |
image_points | and 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_points | for( 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 147 of file vpgl_bundle_adjust.cxx.
const vnl_vector<double>& vpgl_bundle_adjust::point_params | ( | ) | const [inline] |
Return the raw world point parameters.
Definition at line 56 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::reflect_points | ( | const vgl_plane_3d< double > & | plane, |
vcl_vector< vgl_point_3d< double > > & | points | ||
) | [private] |
Definition at line 75 of file vpgl_bundle_adjust.cxx.
void vpgl_bundle_adjust::rotate_cameras | ( | const vgl_vector_3d< double > & | axis, |
vcl_vector< vpgl_perspective_camera< double > > & | cameras | ||
) | [private] |
Definition at line 90 of file vpgl_bundle_adjust.cxx.
void vpgl_bundle_adjust::set_epsilon | ( | double | eps | ) | [inline] |
step size for finite differencing operations.
Definition at line 42 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_g_tolerence | ( | double | gtol | ) | [inline] |
Definition at line 40 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_m_estimator_scale | ( | double | scale | ) | [inline] |
Definition at line 33 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_max_iterations | ( | unsigned | maxitr | ) | [inline] |
Definition at line 38 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_normalize_data | ( | bool | normalize | ) | [inline] |
Definition at line 36 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_self_calibrate | ( | bool | self_calibrate | ) | [inline] |
Definition at line 35 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_use_gradient | ( | bool | use_gradient | ) | [inline] |
Definition at line 34 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_use_m_estimator | ( | bool | use_m | ) | [inline] |
Definition at line 32 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_verbose | ( | bool | verbose | ) | [inline] |
Definition at line 37 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::set_x_tolerence | ( | double | xtol | ) | [inline] |
Definition at line 39 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::start_error | ( | ) | const [inline] |
Return the starting error.
Definition at line 47 of file vpgl_bundle_adjust.h.
void vpgl_bundle_adjust::write_vrml | ( | const vcl_string & | filename, |
const vcl_vector< vpgl_perspective_camera< double > > & | cameras, | ||
const vcl_vector< vgl_point_3d< double > > & | world_points | ||
) | [static] |
Write cameras and points to a file in VRML 2.0 for debugging.
Definition at line 266 of file vpgl_bundle_adjust.cxx.
vnl_vector<double> vpgl_bundle_adjust::a_ [private] |
The last camera parameters.
Definition at line 111 of file vpgl_bundle_adjust.h.
vnl_vector<double> vpgl_bundle_adjust::b_ [private] |
The last point parameters.
Definition at line 113 of file vpgl_bundle_adjust.h.
The bundle adjustment error function.
Definition at line 109 of file vpgl_bundle_adjust.h.
vnl_vector<double> vpgl_bundle_adjust::c_ [private] |
The last global parameters.
Definition at line 115 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::end_error_ [private] |
Definition at line 131 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::epsilon_ [private] |
Definition at line 128 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::g_tol_ [private] |
Definition at line 127 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::m_estimator_scale_ [private] |
Definition at line 120 of file vpgl_bundle_adjust.h.
unsigned int vpgl_bundle_adjust::max_iterations_ [private] |
Definition at line 125 of file vpgl_bundle_adjust.h.
bool vpgl_bundle_adjust::normalize_data_ [private] |
Definition at line 123 of file vpgl_bundle_adjust.h.
int vpgl_bundle_adjust::num_iterations_ [private] |
Definition at line 132 of file vpgl_bundle_adjust.h.
bool vpgl_bundle_adjust::self_calibrate_ [private] |
Definition at line 122 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::start_error_ [private] |
Definition at line 130 of file vpgl_bundle_adjust.h.
bool vpgl_bundle_adjust::use_gradient_ [private] |
Definition at line 121 of file vpgl_bundle_adjust.h.
bool vpgl_bundle_adjust::use_m_estimator_ [private] |
Definition at line 119 of file vpgl_bundle_adjust.h.
bool vpgl_bundle_adjust::verbose_ [private] |
Definition at line 124 of file vpgl_bundle_adjust.h.
vcl_vector<double> vpgl_bundle_adjust::weights_ [private] |
The last estimated weights.
Definition at line 117 of file vpgl_bundle_adjust.h.
double vpgl_bundle_adjust::x_tol_ [private] |
Definition at line 126 of file vpgl_bundle_adjust.h.