Isis 3 Developer Reference
BundleAdjust.h
Go to the documentation of this file.
1 #ifndef BundleAdjust_h
2 #define BundleAdjust_h
3 
26 // Qt lib
27 #include <QObject> // parent class
28 
29 // std lib
30 #include <vector>
31 #include <fstream>
32 
33 // cholmod lib
34 #include <cholmod.h>
35 
36 // Isis lib
37 #include "BundleControlPoint.h"
40 #include "BundleResults.h"
41 #include "BundleSettings.h"
42 #include "BundleSolutionInfo.h"
43 #include "BundleTargetBody.h"
44 #include "Camera.h"
45 #include "CameraGroundMap.h"
46 #include "ControlMeasure.h"
47 #include "ControlNet.h"
48 #include "LinearAlgebra.h"
49 #include "MaximumLikelihoodWFunctions.h" // why not just forward declare???
50 #include "ObservationNumberList.h"
51 #include "Progress.h"
52 #include "SerialNumberList.h"
53 #include "SparseBlockMatrix.h"
54 #include "Statistics.h"
55 
56 template< typename T > class QList;
57 template< typename A, typename B > class QMap;
58 
59 namespace Isis {
60  class Control;
61  class ImageList;
62 
333  class BundleAdjust : public QObject {
334  Q_OBJECT
335  public:
336  BundleAdjust(BundleSettingsQsp bundleSettings,
337  const QString &cnetFile,
338  const QString &cubeList,
339  bool printSummary = true);
340  BundleAdjust(BundleSettingsQsp bundleSettings,
341  QString &cnet,
342  SerialNumberList &snlist,
343  bool printSummary = true);
344  BundleAdjust(BundleSettingsQsp bundleSettings,
345  Control &cnet,
346  SerialNumberList &snlist,
347  bool bPrintSummary);
348  BundleAdjust(BundleSettingsQsp bundleSettings,
349  ControlNet &cnet,
350  SerialNumberList &snlist,
351  bool printSummary = true);
352  BundleAdjust(BundleSettingsQsp bundleSettings,
353  ControlNetQsp cnet,
354  const QString &cubeList,
355  bool printSummary = true);
356  BundleAdjust(BundleSettingsQsp bundleSettings,
357  Control &control,
358  QList<ImageList *> imgList,
359  bool printSummary);
360  ~BundleAdjust();
362 
364  bool isAborted();
365 
366  public slots:
367  bool solveCholesky();
368  void abortBundle();
369  void outputBundleStatus(QString status);
370 
371  // accessors
372 
375  QString fileName(int index);
376  QString iterationSummaryGroup() const;
377  bool isConverged();
378  Table cMatrix(int index);
379  Table spVector(int index);
380  int numberOfImages() const;
381  double iteration() const;
382 
383  signals:
384  void statusUpdate(QString);
385  void error(QString);
386  void iterationUpdate(int);
387  void pointUpdate(int);
388  void statusBarUpdate(QString);
389  void resultsReady(BundleSolutionInfo *bundleSolveInformation);
390  void finished();
391 
392  private:
393  //TODO Should there be a resetBundle(BundleSettings bundleSettings) method
394  // that allows for rerunning with new settings? JWB
395  void init(Progress *progress = 0);
396  bool initializeNormalEquationsMatrix();
397  bool validateNetwork();
398  bool solveSystem();
399  void iterationSummary();
400  BundleSolutionInfo* bundleSolveInformation();
401  bool computeBundleStatistics();
402  void applyParameterCorrections();
403  bool errorPropagation();
404  double computeResiduals();
405  bool computeRejectionLimit();
406  bool flagOutliers();
407 
408  // normal equation matrices methods
409 
410  bool formNormalEquations();
411  bool computePartials(LinearAlgebra::Matrix &coeffTarget,
412  LinearAlgebra::Matrix &coeffImage,
413  LinearAlgebra::Matrix &coeffPoint3D,
414  LinearAlgebra::Vector &coeffRHS,
415  BundleMeasure &measure,
416  BundleControlPoint &point);
417  bool formMeasureNormals(boost::numeric::ublas::symmetric_matrix<
418  double, boost::numeric::ublas::upper > &N22,
420  boost::numeric::ublas::compressed_vector< double > &n1,
422  LinearAlgebra::Matrix &coeffTarget,
423  LinearAlgebra::Matrix &coeffImage,
424  LinearAlgebra::Matrix &coeffPoint3D,
425  LinearAlgebra::Vector &coeffRHS,
426  int observationIndex);
427  bool formPointNormals(boost::numeric::ublas::symmetric_matrix<
428  double, boost::numeric::ublas::upper > &N22,
432  BundleControlPointQsp &point);
433  bool formWeightedNormals(boost::numeric::ublas::compressed_vector< double > &n1,
435 
436  // dedicated matrix functions
437 
438  void productAB(SparseBlockColumnMatrix &A,
440  void accumProductAlphaAB(double alpha,
444  bool invert3x3(boost::numeric::ublas::symmetric_matrix<
445  double, boost::numeric::ublas::upper > &m);
446  bool productATransB(boost::numeric::ublas::symmetric_matrix<
447  double, boost::numeric::ublas::upper > &N22,
450  void productAlphaAV(double alpha,
451  boost::numeric::ublas::bounded_vector< double, 3 > &v2,
454 
455  // CHOLMOD library methods
456 
457  bool initializeCHOLMODLibraryVariables();
458  bool freeCHOLMODLibraryVariables();
459  bool cholmodInverse();
460  bool loadCholmodTriplet();
461  bool wrapUp();
462 
463  // member variables
464 
465  BundleSettingsQsp m_bundleSettings;
466  BundleResults m_bundleResults;
467  Statistics m_xResiduals;
469  Statistics m_yResiduals;
470  Statistics m_xyResiduals;
471  ControlNetQsp m_controlNet;
472  QString m_cnetFileName;
473  QVector <BundleControlPointQsp> m_bundleControlPoints;
477  BundleObservationVector m_bundleObservations;
480  SerialNumberList *m_serialNumberList;
481  BundleTargetBodyQsp m_bundleTargetBody;
483  bool m_abort;
484  QString m_iterationSummary;
486  bool m_printSummary;
489  bool m_cleanUp;
492  int m_rank;
493  int m_iteration;
494  int m_numberOfImagePartials;
495  QList<ImageList *> m_imageLists;
498  // ==========================================================================================
499  // === BEYOND THIS PLACE (THERE BE DRAGONS) all refers to the folded bundle solution. ===
500  // === Currently, everything uses the CHOLMOD library, ===
501  // === there is no dependence on the least-squares class. ===
502  // ==========================================================================================
503 
505  boost::numeric::ublas::symmetric_matrix<
506  double,
507  boost::numeric::ublas::upper,
508  boost::numeric::ublas::column_major > m_normalInverse;
509  cholmod_common m_cholmodCommon;
512  LinearAlgebra::Vector m_RHS;
514  SparseBlockMatrix m_sparseNormals;
518  cholmod_triplet *m_cholmodTriplet;
524  cholmod_sparse *m_cholmodNormal;
529  cholmod_factor *m_L;
533  LinearAlgebra::Vector m_imageSolution;
536  int m_previousNumberImagePartials;
539  };
540 }
541 
542 #endif
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:79
This class is a container class for BundleObservations.
Definition: BundleObservationVector.h:65
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
SparseBlockMatrix.
Definition: SparseBlockMatrix.h:198
QString fileName(int index)
Return the ith filename in the cube list file given to constructor.
Definition: BundleAdjust.cpp:2964
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
SparseBlockColumnMatrix.
Definition: SparseBlockMatrix.h:69
bool isConverged()
Returns if the BundleAdjust converged.
Definition: BundleAdjust.cpp:3076
Container class for BundleAdjustment results.
Definition: BundleSolutionInfo.h:171
SerialNumberList * serialNumberList()
Returns a pointer to the serial number list.
Definition: BundleAdjust.cpp:2941
Table spVector(int index)
Return a table spacecraft vector for the ith cube in the cube list given to the constructor.
Definition: BundleAdjust.cpp:2998
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
A container class for a ControlMeasure.
Definition: BundleMeasure.h:69
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
Definition: LinearAlgebra.h:115
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void abortBundle()
Flag to abort when bundle is threaded.
Definition: BundleAdjust.cpp:675
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:107
bool solveCholesky()
Compute the least squares bundle adjustment solution using Cholesky decomposition.
Definition: BundleAdjust.cpp:694
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
Definition: LinearAlgebra.h:135
Program progress reporter.
Definition: Progress.h:58
~BundleAdjust()
Destroys BundleAdjust object, deallocates pointers (if we have ownership), and frees variables from c...
Definition: BundleAdjust.cpp:320
a control network
Definition: ControlNet.h:271
Table cMatrix(int index)
Return a table cmatrix for the ith cube in the cube list given to the constructor.
Definition: BundleAdjust.cpp:2986
BundleAdjust(BundleSettingsQsp bundleSettings, const QString &cnetFile, const QString &cubeList, bool printSummary=true)
Construct a BundleAdjust object from the given settings, control network file, and cube list...
Definition: BundleAdjust.cpp:94
ControlNetQsp controlNet()
Returns a pointer to the output control network.
Definition: BundleAdjust.cpp:2931
void pointUpdate(int)
This class holds information about a control point that BundleAdjust needs to run correctly...
Definition: BundleControlPoint.h:105
BundleSolutionInfo * solveCholeskyBR()
Compute the least squares bundle adjustment solution using Cholesky decomposition.
Definition: BundleAdjust.cpp:665
void resultsReady(BundleSolutionInfo *bundleSolveInformation)
bool isAborted()
Returns if the BundleAdjust has been aborted.
Definition: BundleAdjust.cpp:3086
void statusBarUpdate(QString)
void outputBundleStatus(QString status)
Slot for deltack and jigsaw to output the bundle status.
Definition: BundleAdjust.cpp:3112
QList< ImageList * > imageLists()
This method returns the image list used in the bundle adjust.
Definition: BundleAdjust.cpp:2534
Definition: Calculator.h:33
int numberOfImages() const
Returns the number of images.
Definition: BundleAdjust.cpp:2951
void error(QString)
Class for storing Table blobs information.
Definition: Table.h:77
Definition: BoxcarCachingAlgorithm.h:29
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
A container class for statistical results from a BundleAdjust solution.
Definition: BundleResults.h:96
QString iterationSummaryGroup() const
Returns the iteration summary string.
Definition: BundleAdjust.cpp:3098
double iteration() const
Returns what iteration the BundleAdjust is currently on.
Definition: BundleAdjust.cpp:2974
An image bundle adjustment object.
Definition: BundleAdjust.h:333
Serial Number list generator.
Definition: SerialNumberList.h:80
void iterationUpdate(int)
void statusUpdate(QString)
SparseBlockRowMatrix.
Definition: SparseBlockMatrix.h:136
Definition: CubeIoHandler.h:38