Isis 3.0
Back | Home
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 
271  class BundleAdjust : public QObject {
272  Q_OBJECT
273  public:
274  BundleAdjust(BundleSettingsQsp bundleSettings,
275  const QString &cnetFile,
276  const QString &cubeList,
277  bool printSummary = true);
278  BundleAdjust(BundleSettingsQsp bundleSettings,
279  QString &cnet,
280  SerialNumberList &snlist,
281  bool printSummary = true);
282  BundleAdjust(BundleSettingsQsp bundleSettings,
283  Control &cnet,
284  SerialNumberList &snlist,
285  bool bPrintSummary);
286  BundleAdjust(BundleSettingsQsp bundleSettings,
287  ControlNet &cnet,
288  SerialNumberList &snlist,
289  bool printSummary = true);
290  BundleAdjust(BundleSettingsQsp bundleSettings,
291  ControlNetQsp cnet,
292  const QString &cubeList,
293  bool printSummary = true);
294  BundleAdjust(BundleSettingsQsp bundleSettings,
295  Control &control,
296  QList<ImageList *> imgList,
297  bool printSummary);
298  ~BundleAdjust();
300 
301  public slots:
302  bool solveCholesky();
303  void abortBundle();
304  void outputBundleStatus(QString status);
305 
306  // accessors
307 
310  QString fileName(int index);
311  QString iterationSummaryGroup() const;
312  bool isConverged();
313  Table cMatrix(int index);
314  Table spVector(int index);
315  int numberOfImages() const;
316  double iteration() const;
317 
318  signals:
319  void statusUpdate(QString);
320  void error(QString);
321  void iterationUpdate(int, double);
322  void resultsReady(BundleSolutionInfo *bundleSolveInformation);
323  void finished();
324 
325  private:
326  //TODO Should there be a resetBundle(BundleSettings bundleSettings) method
327  // that allows for rerunning with new settings? JWB
328  void init(Progress *progress = 0);
329  bool validateNetwork();
330  bool solveSystem();
331  void iterationSummary();
332  BundleSolutionInfo bundleSolveInformation();
333  bool computeBundleStatistics();
334  void applyParameterCorrections();
335  bool errorPropagation();
336  double computeResiduals();
337  bool computeRejectionLimit();
338  bool flagOutliers();
339 
340  // normal equation matrices methods
341 
342  bool formNormalEquations();
343  bool computePartials(LinearAlgebra::Matrix &coeffTarget,
344  LinearAlgebra::Matrix &coeffImage,
345  LinearAlgebra::Matrix &coeffPoint3D,
346  LinearAlgebra::Vector &coeffRHS,
347  BundleMeasure &measure,
348  BundleControlPoint &point);
349  bool formMeasureNormals(boost::numeric::ublas::symmetric_matrix<
350  double, boost::numeric::ublas::upper > &N22,
352  boost::numeric::ublas::compressed_vector< double > &n1,
354  LinearAlgebra::Matrix &coeffTarget,
355  LinearAlgebra::Matrix &coeffImage,
356  LinearAlgebra::Matrix &coeffPoint3D,
357  LinearAlgebra::Vector &coeffRHS,
358  int observationIndex);
359  bool formPointNormals(boost::numeric::ublas::symmetric_matrix<
360  double, boost::numeric::ublas::upper > &N22,
364  BundleControlPointQsp &point);
365  bool formWeightedNormals(boost::numeric::ublas::compressed_vector< double > &n1,
367 
368  // dedicated matrix functions
369 
370  void productAB(SparseBlockColumnMatrix &A,
372  void accumProductAlphaAB(double alpha,
376  bool invert3x3(boost::numeric::ublas::symmetric_matrix<
377  double, boost::numeric::ublas::upper > &m);
378  bool productATransB(boost::numeric::ublas::symmetric_matrix<
379  double, boost::numeric::ublas::upper > &N22,
382  void productAlphaAV(double alpha,
383  boost::numeric::ublas::bounded_vector< double, 3 > &v2,
386 
387  // CHOLMOD library methods
388 
389  bool initializeCHOLMODLibraryVariables();
390  bool freeCHOLMODLibraryVariables();
391  bool cholmodInverse();
392  bool loadCholmodTriplet();
393  bool wrapUp();
394 
395  // member variables
396 
397  BundleSettingsQsp m_bundleSettings;
398  BundleResults m_bundleResults;
399  Statistics m_xResiduals;
401  Statistics m_yResiduals;
402  Statistics m_xyResiduals;
403  ControlNetQsp m_controlNet;
404  QString m_cnetFileName;
405  QVector <BundleControlPointQsp> m_bundleControlPoints;
409  BundleObservationVector m_bundleObservations;
412  SerialNumberList *m_serialNumberList;
413  BundleTargetBodyQsp m_bundleTargetBody;
415  Distance m_bodyRadii[3];
416  bool m_abort;
417  QString m_iterationSummary;
419  bool m_printSummary;
422  bool m_cleanUp;
425  int m_rank;
426  int m_iteration;
427  int m_numberOfImagePartials;
428  double m_radiansToMeters;
430  double m_metersToRadians;
433  // ==========================================================================================
434  // === BEYOND THIS PLACE (THERE BE DRAGONS) all refers to the folded bundle solution. ===
435  // === Currently, everything uses the CHOLMOD library, ===
436  // === there is no dependence on the least-squares class. ===
437  // ==========================================================================================
438 
440  boost::numeric::ublas::symmetric_matrix<
441  double,
442  boost::numeric::ublas::upper,
443  boost::numeric::ublas::column_major > m_normalInverse;
444  cholmod_common m_cholmodCommon;
447  LinearAlgebra::Vector m_RHS;
449  SparseBlockMatrix m_sparseNormals;
453  cholmod_triplet *m_cholmodTriplet;
459  cholmod_sparse *m_cholmodNormal;
464  cholmod_factor *m_L;
468  LinearAlgebra::Vector m_imageSolution;
470  };
471 }
472 
473 #endif
474 
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:57
This class is a container class for BundleObservations.
Definition: BundleObservationVector.h:65
SparseBlockMatrix.
Definition: SparseBlockMatrix.h:187
QString fileName(int index)
Return the ith filename in the cube list file given to constructor.
Definition: BundleAdjust.cpp:2879
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:44
QSharedPointer< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.
Definition: BundleSettings.h:404
SparseBlockColumnMatrix.
Definition: SparseBlockMatrix.h:66
QSharedPointer< ControlNet > ControlNetQsp
This typedef is for future implementation of target body.
Definition: ControlNet.h:446
bool isConverged()
Returns if the BundleAdjust converged.
Definition: BundleAdjust.cpp:2991
Container class for BundleAdjustment results.
Definition: BundleSolutionInfo.h:98
void finished()
Definition: moc_BundleAdjust.cpp:272
SerialNumberList * serialNumberList()
Returns a pointer to the serial number list.
Definition: BundleAdjust.cpp:2856
Table spVector(int index)
Return a table spacecraft vector for the ith cube in the cube list given to the constructor.
Definition: BundleAdjust.cpp:2913
QString iterationSummaryGroup() const
Returns the iteration summary string.
Definition: BundleAdjust.cpp:3003
QSharedPointer< BundleTargetBody > BundleTargetBodyQsp
Definition for BundleTargetBodyQsp, a QSharedPointer to a BundleTargetBody.
Definition: BundleTargetBody.h:198
double iteration() const
Returns what iteration the BundleAdjust is currently on.
Definition: BundleAdjust.cpp:2889
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:114
void iterationUpdate(int, double)
Definition: moc_BundleAdjust.cpp:258
Distance measurement, usually in meters.
Definition: Distance.h:47
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:621
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:109
bool solveCholesky()
Compute the least squares bundle adjustment solution using Cholesky decomposition.
Definition: BundleAdjust.cpp:640
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
Definition: LinearAlgebra.h:124
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:287
a control network
Definition: ControlNet.h:207
Table cMatrix(int index)
Return a table cmatrix for the ith cube in the cube list given to the constructor.
Definition: BundleAdjust.cpp:2901
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:2846
This class holds information about a control point that BundleAdjust needs to run corretly...
Definition: BundleControlPoint.h:71
void resultsReady(BundleSolutionInfo *bundleSolveInformation)
Definition: moc_BundleAdjust.cpp:265
int numberOfImages() const
Returns the number of images.
Definition: BundleAdjust.cpp:2866
void outputBundleStatus(QString status)
Slot for deltack and jigsaw to output the bundle status.
Definition: BundleAdjust.cpp:3017
BundleSolutionInfo solveCholeskyBR()
Compute the least squares bundle adjustment solution using Cholesky decomposition.
Definition: BundleAdjust.cpp:611
void error(QString)
Definition: moc_BundleAdjust.cpp:251
Class for storing Table blobs information.
Definition: Table.h:74
Definition: BoxcarCachingAlgorithm.h:29
A container class for statistical results from a BundleAdjust solution.
Definition: BundleResults.h:90
An image bundle adjustment object.
Definition: BundleAdjust.h:271
QSharedPointer< BundleControlPoint > BundleControlPointQsp
Definition for BundleControlPointQSP, a shared pointer to a BundleControlPoint.
Definition: BundleControlPoint.h:144
Serial Number list generator.
Definition: SerialNumberList.h:78
void statusUpdate(QString)
Definition: moc_BundleAdjust.cpp:244
SparseBlockRowMatrix.
Definition: SparseBlockMatrix.h:125
Definition: CubeIoHandler.h:38

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:15:03