Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
vpgl_ba_fixed_k_lsqr Class Reference

a class for bundle adjustment with fixed intrinsic parameters. More...

#include <vpgl_ba_fixed_k_lsqr.h>

Inheritance diagram for vpgl_ba_fixed_k_lsqr:
Inheritance graph
[legend]

Public Types

enum  UseGradient
 
enum  UseWeights
 

Public Member Functions

 vpgl_ba_fixed_k_lsqr (std::vector< vpgl_calibration_matrix< double > > K, const std::vector< vgl_point_2d< double > > &image_points, const std::vector< std::vector< bool > > &mask)
 Constructor. More...
 
 vpgl_ba_fixed_k_lsqr (std::vector< vpgl_calibration_matrix< double > > K, const std::vector< vgl_point_2d< double > > &image_points, const std::vector< vnl_matrix< double > > &inv_covars, const std::vector< std::vector< bool > > &mask)
 Constructor. More...
 
 ~vpgl_ba_fixed_k_lsqr () override=default
 
void jac_Aij (unsigned int i, unsigned int j, vnl_double_3x4 const &Pi, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Aij) override
 compute the Jacobian Aij. More...
 
void jac_Bij (unsigned int i, unsigned int j, vnl_double_3x4 const &Pi, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Bij) override
 compute the Jacobian Bij. More...
 
void jac_Cij (unsigned int i, unsigned int j, vnl_double_3x4 const &Pi, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Cij) override
 compute the Jacobian Cij. More...
 
vgl_homg_point_3d< double > param_to_point (int j, const double *bj, const vnl_vector< double > &c) const override
 construct the More...
 
vnl_vector_fixed< double, 4 > param_to_pt_vector (int j, const double *bj, const vnl_vector< double > &c) const override
 construct the More...
 
vpgl_perspective_camera< double > param_to_cam (int i, const double *ai, const vnl_vector< double > &c) const override
 construct the More...
 
vnl_double_3x4 param_to_cam_matrix (int i, const double *ai, const vnl_vector< double > &c) const override
 compute a 3x4 camera matrix of camera More...
 
void f (vnl_vector< double > const &a, vnl_vector< double > const &b, vnl_vector< double > const &c, vnl_vector< double > &e) override
 Compute all the reprojection errors. More...
 
void fij (int i, int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_vector< double > &fij) override
 Compute the residuals from the ith component of a, the jth component of b, and all of c. More...
 
void jac_blocks (vnl_vector< double > const &a, vnl_vector< double > const &b, vnl_vector< double > const &c, std::vector< vnl_matrix< double > > &A, std::vector< vnl_matrix< double > > &B, std::vector< vnl_matrix< double > > &C) override
 Compute the sparse Jacobian in block form. More...
 
virtual void jac_Aij (unsigned int i, unsigned int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Aij)
 
virtual void jac_Aij (unsigned int i, unsigned int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Aij)
 
virtual void jac_Bij (unsigned int i, unsigned int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Bij)
 
virtual void jac_Bij (unsigned int i, unsigned int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Bij)
 
virtual void jac_Cij (unsigned int i, unsigned int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Cij)
 
virtual void jac_Cij (unsigned int i, unsigned int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Cij)
 
void compute_weight_ij (int i, int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_vector< double > const &fij, double &weight) override
 Use an M-estimator to compute weights. More...
 
void set_residual_scale (double scale)
 set the residual scale for the robust estimation. More...
 
vgl_homg_point_3d< double > param_to_point (int j, const vnl_vector< double > &b, const vnl_vector< double > &c) const
 construct the More...
 
vnl_vector_fixed< double, 4 > param_to_pt_vector (int j, const vnl_vector< double > &b, const vnl_vector< double > &c) const
 construct the More...
 
vpgl_perspective_camera< double > param_to_cam (int i, const vnl_vector< double > &a, const vnl_vector< double > &c) const
 construct the More...
 
vnl_double_3x4 param_to_cam_matrix (int i, const vnl_vector< double > &a, const vnl_vector< double > &c) const
 construct the More...
 
void reset ()
 reset the weights. More...
 
void throw_failure ()
 
void clear_failure ()
 
virtual void fd_jac_blocks (vnl_vector< double > const &a, vnl_vector< double > const &b, vnl_vector< double > const &c, std::vector< vnl_matrix< double > > &A, std::vector< vnl_matrix< double > > &B, std::vector< vnl_matrix< double > > &C, double stepsize)
 
virtual void compute_weights (vnl_vector< double > const &a, vnl_vector< double > const &b, vnl_vector< double > const &c, vnl_vector< double > const &f, vnl_vector< double > &weights)
 
virtual void apply_weights (vnl_vector< double > const &weights, vnl_vector< double > &f)
 
virtual void apply_weights (vnl_vector< double > const &weights, std::vector< vnl_matrix< double > > &A, std::vector< vnl_matrix< double > > &B, std::vector< vnl_matrix< double > > &C)
 
void fd_jac_Aij (int i, int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Aij, double stepsize)
 
void fd_jac_Bij (int i, int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Bij, double stepsize)
 
void fd_jac_Cij (int i, int j, vnl_vector< double > const &ai, vnl_vector< double > const &bj, vnl_vector< double > const &c, vnl_matrix< double > &Cij, double stepsize)
 
virtual void apply_weight_ij (int i, int j, double const &weight, vnl_vector< double > &fij)
 
virtual void apply_weight_ij (int i, int j, double const &weight, vnl_matrix< double > &Aij, vnl_matrix< double > &Bij, vnl_matrix< double > &Cij)
 
virtual void trace (int iteration, vnl_vector< double > const &a, vnl_vector< double > const &b, vnl_vector< double > const &c, vnl_vector< double > const &e)
 
unsigned int number_of_params_a (int i) const
 
unsigned int number_of_params_b (int j) const
 
unsigned int number_of_params_c () const
 
unsigned int number_of_residuals (int k) const
 
unsigned int number_of_residuals (int i, int j) const
 
unsigned int index_a (int i) const
 
unsigned int index_b (int j) const
 
unsigned int index_e (int k) const
 
unsigned int number_of_a () const
 
unsigned int number_of_b () const
 
unsigned int number_of_e () const
 
bool has_gradient () const
 
bool has_weights () const
 
const vnl_crs_indexresidual_indices () const
 

Static Public Member Functions

static vnl_vector< double > create_param_vector (const std::vector< vpgl_perspective_camera< double > > &cameras)
 Create the parameter vector a from a vector of cameras. More...
 
static vnl_vector< double > create_param_vector (const std::vector< vgl_point_3d< double > > &world_points)
 Create the parameter vector b from a vector of 3D points. More...
 
static vnl_double_3x3 rod_to_matrix (vnl_vector< double > const &r)
 Fast conversion of rotation from Rodrigues vector to matrix. More...
 
static void jac_inhomg_3d_point (vnl_double_3x4 const &P, vnl_vector< double > const &pt, vnl_matrix< double > &J)
 compute the 2x3 Jacobian of camera projection with respect to point location df/dpt where $f(pt) = P*pt$. More...
 
static void jac_camera_center (vnl_double_3x3 const &M, vnl_vector< double > const &C, vnl_vector< double > const &pt, vnl_matrix< double > &J)
 compute the 2x3 Jacobian of camera projection with respect to camera center df/dC where $f(C) = [M | -M*C]*pt$. More...
 
static void jac_camera_rotation (vnl_double_3x3 const &K, vnl_vector< double > const &C, vnl_vector< double > const &r, vnl_vector< double > const &pt, vnl_matrix< double > &J)
 compute the 2x3 Jacobian of camera projection with respect to camera rotation df/dr where $f(r) = K*rod_to_matrix(r)*[I | -C]*pt$. More...
 

Public Attributes

 no_gradient
 
 use_gradient
 
 no_weights
 
 use_weights
 
bool failure
 

Protected Attributes

std::vector< vpgl_calibration_matrix< double > > K_
 The fixed internal camera calibration. More...
 
std::vector< vnl_double_3x3Km_
 The fixed internal camera calibration in matrix form. More...
 
std::vector< vgl_point_2d< double > > image_points_
 The corresponding points in the image. More...
 
std::vector< vnl_matrix< double > > factored_inv_covars_
 The Cholesky factored inverse covariances for each image point. More...
 
bool use_covars_
 Flag to enable covariance weighted errors. More...
 
double scale2_
 The square of the scale of the robust estimator. More...
 
int iteration_count_
 
vnl_crs_index residual_indices_
 
std::vector< unsigned int > indices_a_
 
std::vector< unsigned int > indices_b_
 
unsigned int num_params_c_
 
std::vector< unsigned int > indices_e_
 
bool use_gradient_
 
bool use_weights_
 

Detailed Description

a class for bundle adjustment with fixed intrinsic parameters.

Definition at line 18 of file vpgl_ba_fixed_k_lsqr.h.

Constructor & Destructor Documentation

◆ vpgl_ba_fixed_k_lsqr() [1/2]

vpgl_ba_fixed_k_lsqr::vpgl_ba_fixed_k_lsqr ( std::vector< vpgl_calibration_matrix< double > >  K,
const std::vector< vgl_point_2d< double > > &  image_points,
const std::vector< std::vector< bool > > &  mask 
)

Constructor.

Note
image points are not homogeneous because they require finite points to measure projection error

Definition at line 14 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ vpgl_ba_fixed_k_lsqr() [2/2]

vpgl_ba_fixed_k_lsqr::vpgl_ba_fixed_k_lsqr ( std::vector< vpgl_calibration_matrix< double > >  K,
const std::vector< vgl_point_2d< double > > &  image_points,
const std::vector< vnl_matrix< double > > &  inv_covars,
const std::vector< std::vector< bool > > &  mask 
)

Constructor.

Each image point is assigned an inverse covariance (error projector) matrix

Note
image points are not homogeneous because they require finite points to measure projection error

Definition at line 29 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ ~vpgl_ba_fixed_k_lsqr()

vpgl_ba_fixed_k_lsqr::~vpgl_ba_fixed_k_lsqr ( )
overridedefault

Member Function Documentation

◆ compute_weight_ij()

void vpgl_bundle_adjust_lsqr::compute_weight_ij ( int  i,
int  j,
vnl_vector< double > const &  ai,
vnl_vector< double > const &  bj,
vnl_vector< double > const &  c,
vnl_vector< double > const &  fij,
double &  weight 
)
overridevirtualinherited

Use an M-estimator to compute weights.

Reimplemented from vnl_sparse_lst_sqr_function.

Definition at line 199 of file vpgl_bundle_adjust_lsqr.cxx.

◆ create_param_vector() [1/2]

vnl_vector< double > vpgl_ba_fixed_k_lsqr::create_param_vector ( const std::vector< vpgl_perspective_camera< double > > &  cameras)
static

Create the parameter vector a from a vector of cameras.

Definition at line 138 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ create_param_vector() [2/2]

vnl_vector< double > vpgl_ba_fixed_k_lsqr::create_param_vector ( const std::vector< vgl_point_3d< double > > &  world_points)
static

Create the parameter vector b from a vector of 3D points.

Definition at line 160 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ f()

void vpgl_bundle_adjust_lsqr::f ( vnl_vector< double > const &  a,
vnl_vector< double > const &  b,
vnl_vector< double > const &  c,
vnl_vector< double > &  e 
)
overridevirtualinherited

Compute all the reprojection errors.

Given the parameter vectors a, b, and c, compute the vector of residuals e. e has been sized appropriately before the call. The parameters in for each camera are in a. The 3D point parameters are in b. Global parameters are in c.

Given the parameter vectors a, b, and c, compute the vector of residuals e. e has been sized appropriately before the call. The parameters in a for each camera are {wx, wy, wz, tx, ty, tz} where w is the Rodrigues vector of the rotation and t is the translation. The parameters in b for each 3D point are {px, py, pz} the non-homogeneous position.

Construct the ith camera.

Reimplemented from vnl_sparse_lst_sqr_function.

Definition at line 88 of file vpgl_bundle_adjust_lsqr.cxx.

◆ fij()

void vpgl_bundle_adjust_lsqr::fij ( int  i,
int  j,
vnl_vector< double > const &  ai,
vnl_vector< double > const &  bj,
vnl_vector< double > const &  c,
vnl_vector< double > &  fij 
)
overridevirtualinherited

Compute the residuals from the ith component of a, the jth component of b, and all of c.

Compute the residuals from the ith component of a and the jth component of b.

This function is not normally used because f() has a self-contained efficient implementation. It is used for finite-differencing if the gradient is marked as unavailable

This is not normally used because f() has a self-contained efficient implementation It is used for finite-differencing if the gradient is marked as unavailable

Construct the ith camera.

Reimplemented from vnl_sparse_lst_sqr_function.

Definition at line 129 of file vpgl_bundle_adjust_lsqr.cxx.

◆ jac_Aij() [1/2]

void vpgl_ba_fixed_k_lsqr::jac_Aij ( unsigned int  i,
unsigned int  j,
vnl_double_3x4 const &  Pi,
vnl_vector< double > const &  ai,
vnl_vector< double > const &  bj,
vnl_vector< double > const &  c,
vnl_matrix< double > &  Aij 
)
overridevirtual

compute the Jacobian Aij.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 42 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ jac_Aij() [2/2]

virtual void vnl_sparse_lst_sqr_function::jac_Aij
inherited

◆ jac_Bij() [1/2]

void vpgl_ba_fixed_k_lsqr::jac_Bij ( unsigned int  i,
unsigned int  j,
vnl_double_3x4 const &  Pi,
vnl_vector< double > const &  ai,
vnl_vector< double > const &  bj,
vnl_vector< double > const &  c,
vnl_matrix< double > &  Bij 
)
overridevirtual

compute the Jacobian Bij.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 68 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ jac_Bij() [2/2]

virtual void vnl_sparse_lst_sqr_function::jac_Bij
inherited

◆ jac_blocks()

void vpgl_bundle_adjust_lsqr::jac_blocks ( vnl_vector< double > const &  a,
vnl_vector< double > const &  b,
vnl_vector< double > const &  c,
std::vector< vnl_matrix< double > > &  A,
std::vector< vnl_matrix< double > > &  B,
std::vector< vnl_matrix< double > > &  C 
)
overridevirtualinherited

Compute the sparse Jacobian in block form.

Construct the ith camera.

Reimplemented from vnl_sparse_lst_sqr_function.

Definition at line 159 of file vpgl_bundle_adjust_lsqr.cxx.

◆ jac_camera_center()

void vpgl_bundle_adjust_lsqr::jac_camera_center ( vnl_double_3x3 const &  M,
vnl_vector< double > const &  C,
vnl_vector< double > const &  pt,
vnl_matrix< double > &  J 
)
staticinherited

compute the 2x3 Jacobian of camera projection with respect to camera center df/dC where $f(C) = [M | -M*C]*pt$.

Definition at line 250 of file vpgl_bundle_adjust_lsqr.cxx.

◆ jac_camera_rotation()

void vpgl_bundle_adjust_lsqr::jac_camera_rotation ( vnl_double_3x3 const &  K,
vnl_vector< double > const &  C,
vnl_vector< double > const &  r,
vnl_vector< double > const &  pt,
vnl_matrix< double > &  J 
)
staticinherited

compute the 2x3 Jacobian of camera projection with respect to camera rotation df/dr where $f(r) = K*rod_to_matrix(r)*[I | -C]*pt$.

Here r is a Rodrigues vector, K is an upper triangular calibration matrix

Definition at line 266 of file vpgl_bundle_adjust_lsqr.cxx.

◆ jac_Cij() [1/2]

void vpgl_ba_fixed_k_lsqr::jac_Cij ( unsigned int  i,
unsigned int  j,
vnl_double_3x4 const &  Pi,
vnl_vector< double > const &  ai,
vnl_vector< double > const &  bj,
vnl_vector< double > const &  c,
vnl_matrix< double > &  Cij 
)
overridevirtual

compute the Jacobian Cij.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 80 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ jac_Cij() [2/2]

virtual void vnl_sparse_lst_sqr_function::jac_Cij
inherited

◆ jac_inhomg_3d_point()

void vpgl_bundle_adjust_lsqr::jac_inhomg_3d_point ( vnl_double_3x4 const &  P,
vnl_vector< double > const &  pt,
vnl_matrix< double > &  J 
)
staticinherited

compute the 2x3 Jacobian of camera projection with respect to point location df/dpt where $f(pt) = P*pt$.

Definition at line 218 of file vpgl_bundle_adjust_lsqr.cxx.

◆ param_to_cam() [1/2]

vpgl_perspective_camera< double > vpgl_ba_fixed_k_lsqr::param_to_cam ( int  i,
const double *  ai,
const vnl_vector< double > &  c 
) const
overridevirtual

construct the

Parameters
i-thperspective camera from a pointer to the i-th parameters of
aand parameters
c.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 111 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ param_to_cam() [2/2]

vpgl_perspective_camera<double> vpgl_bundle_adjust_lsqr::param_to_cam ( int  i,
const vnl_vector< double > &  a,
const vnl_vector< double > &  c 
) const
inlineinherited

construct the

Parameters
i-thperspective camera from parameter vector
a.

Definition at line 162 of file vpgl_bundle_adjust_lsqr.h.

◆ param_to_cam_matrix() [1/2]

vnl_double_3x4 vpgl_ba_fixed_k_lsqr::param_to_cam_matrix ( int  i,
const double *  ai,
const vnl_vector< double > &  c 
) const
overridevirtual

compute a 3x4 camera matrix of camera

Parameters
ifrom a pointer to the i-th parameters of
aand parameters
c.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 122 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ param_to_cam_matrix() [2/2]

vnl_double_3x4 vpgl_bundle_adjust_lsqr::param_to_cam_matrix ( int  i,
const vnl_vector< double > &  a,
const vnl_vector< double > &  c 
) const
inlineinherited

construct the

Parameters
i-thperspective camera matrix from parameter vectors
aand
c.

Definition at line 176 of file vpgl_bundle_adjust_lsqr.h.

◆ param_to_point() [1/2]

vgl_homg_point_3d< double > vpgl_ba_fixed_k_lsqr::param_to_point ( int  j,
const double *  bj,
const vnl_vector< double > &  c 
) const
overridevirtual

construct the

Parameters
j-thperspective camera from a pointer to the j-th parameters of
band parameters
c.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 93 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ param_to_point() [2/2]

vgl_homg_point_3d<double> vpgl_bundle_adjust_lsqr::param_to_point ( int  j,
const vnl_vector< double > &  b,
const vnl_vector< double > &  c 
) const
inlineinherited

construct the

Parameters
j-th3D point from parameter vector
band
c.

Definition at line 132 of file vpgl_bundle_adjust_lsqr.h.

◆ param_to_pt_vector() [1/2]

vnl_vector_fixed< double, 4 > vpgl_ba_fixed_k_lsqr::param_to_pt_vector ( int  j,
const double *  bj,
const vnl_vector< double > &  c 
) const
overridevirtual

construct the

Parameters
j-thperspective camera from a pointer to the j-th parameters of
band parameters
c.

Implements vpgl_bundle_adjust_lsqr.

Definition at line 102 of file vpgl_ba_fixed_k_lsqr.cxx.

◆ param_to_pt_vector() [2/2]

vnl_vector_fixed<double,4> vpgl_bundle_adjust_lsqr::param_to_pt_vector ( int  j,
const vnl_vector< double > &  b,
const vnl_vector< double > &  c 
) const
inlineinherited

construct the

Parameters
j-th3D point from parameter vector
band
c.

Definition at line 147 of file vpgl_bundle_adjust_lsqr.h.

◆ reset()

void vpgl_bundle_adjust_lsqr::reset ( )
inlineinherited

reset the weights.

Definition at line 189 of file vpgl_bundle_adjust_lsqr.h.

◆ rod_to_matrix()

vnl_double_3x3 vpgl_bundle_adjust_lsqr::rod_to_matrix ( vnl_vector< double > const &  r)
staticinherited

Fast conversion of rotation from Rodrigues vector to matrix.

Definition at line 360 of file vpgl_bundle_adjust_lsqr.cxx.

◆ set_residual_scale()

void vpgl_bundle_adjust_lsqr::set_residual_scale ( double  scale)
inlineinherited

set the residual scale for the robust estimation.

Definition at line 127 of file vpgl_bundle_adjust_lsqr.h.

Member Data Documentation

◆ factored_inv_covars_

std::vector<vnl_matrix<double> > vpgl_bundle_adjust_lsqr::factored_inv_covars_
protectedinherited

The Cholesky factored inverse covariances for each image point.

Definition at line 225 of file vpgl_bundle_adjust_lsqr.h.

◆ image_points_

std::vector<vgl_point_2d<double> > vpgl_bundle_adjust_lsqr::image_points_
protectedinherited

The corresponding points in the image.

Definition at line 223 of file vpgl_bundle_adjust_lsqr.h.

◆ iteration_count_

int vpgl_bundle_adjust_lsqr::iteration_count_
protectedinherited

Definition at line 231 of file vpgl_bundle_adjust_lsqr.h.

◆ K_

std::vector<vpgl_calibration_matrix<double> > vpgl_ba_fixed_k_lsqr::K_
protected

The fixed internal camera calibration.

Definition at line 105 of file vpgl_ba_fixed_k_lsqr.h.

◆ Km_

std::vector<vnl_double_3x3> vpgl_ba_fixed_k_lsqr::Km_
protected

The fixed internal camera calibration in matrix form.

Definition at line 107 of file vpgl_ba_fixed_k_lsqr.h.

◆ scale2_

double vpgl_bundle_adjust_lsqr::scale2_
protectedinherited

The square of the scale of the robust estimator.

Definition at line 229 of file vpgl_bundle_adjust_lsqr.h.

◆ use_covars_

bool vpgl_bundle_adjust_lsqr::use_covars_
protectedinherited

Flag to enable covariance weighted errors.

Definition at line 227 of file vpgl_bundle_adjust_lsqr.h.


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