Isis Developer Reference
BundleAdjust.h
Go to the documentation of this file.
1 #ifndef BundleAdjust_h
2 #define BundleAdjust_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <QObject> // parent class
13 
14 // std lib
15 #include <vector>
16 #include <fstream>
17 
18 // cholmod lib
19 #include <cholmod.h>
20 
21 // Isis lib
22 #include "BundleControlPoint.h"
25 #include "BundleResults.h"
26 #include "BundleSettings.h"
27 #include "BundleSolutionInfo.h"
28 #include "BundleTargetBody.h"
29 #include "Camera.h"
30 #include "CameraGroundMap.h"
31 #include "ControlMeasure.h"
32 #include "ControlNet.h"
33 #include "LinearAlgebra.h"
34 #include "MaximumLikelihoodWFunctions.h" // why not just forward declare???
35 #include "ObservationNumberList.h"
36 #include "Progress.h"
37 #include "SerialNumberList.h"
38 #include "SparseBlockMatrix.h"
39 #include "Statistics.h"
40 
41 template< typename T > class QList;
42 template< typename A, typename B > class QMap;
43 
44 namespace Isis {
45  class Control;
46  class ImageList;
47 
318  class BundleAdjust : public QObject {
319  Q_OBJECT
320  public:
321  BundleAdjust(BundleSettingsQsp bundleSettings,
322  const QString &cnetFile,
323  const QString &cubeList,
324  bool printSummary = true);
325  BundleAdjust(BundleSettingsQsp bundleSettings,
326  QString &cnet,
327  SerialNumberList &snlist,
328  bool printSummary = true);
329  BundleAdjust(BundleSettingsQsp bundleSettings,
330  Control &cnet,
331  SerialNumberList &snlist,
332  bool bPrintSummary);
333  BundleAdjust(BundleSettingsQsp bundleSettings,
334  ControlNet &cnet,
335  SerialNumberList &snlist,
336  bool printSummary = true);
337  BundleAdjust(BundleSettingsQsp bundleSettings,
338  ControlNetQsp cnet,
339  const QString &cubeList,
340  bool printSummary = true);
341  BundleAdjust(BundleSettingsQsp bundleSettings,
342  Control &control,
343  QList<ImageList *> imgList,
344  bool printSummary);
345  ~BundleAdjust();
347 
349  bool isAborted();
350 
351  public slots:
352  bool solveCholesky();
353  void abortBundle();
354  void outputBundleStatus(QString status);
355 
356  // accessors
357 
360  QString fileName(int index);
361  QString iterationSummaryGroup() const;
362  bool isConverged();
363  Table cMatrix(int index);
364  Table spVector(int index);
365  QString modelState(int index);
366  int numberOfImages() const;
367  double iteration() const;
368 
369  signals:
370  void statusUpdate(QString);
371  void error(QString);
372  void iterationUpdate(int);
373  void pointUpdate(int);
374  void statusBarUpdate(QString);
375  void resultsReady(BundleSolutionInfo *bundleSolveInformation);
376  void finished();
377 
378  private:
379  //TODO Should there be a resetBundle(BundleSettings bundleSettings) method
380  // that allows for rerunning with new settings? JWB
381  void init(Progress *progress = 0);
382  bool initializeNormalEquationsMatrix();
383  bool validateNetwork();
384  bool solveSystem();
385  void iterationSummary();
386  BundleSolutionInfo* bundleSolveInformation();
387  bool computeBundleStatistics();
388  void applyParameterCorrections();
389  bool errorPropagation();
390  double computeResiduals();
391  bool computeRejectionLimit();
392  bool flagOutliers();
393 
394  // normal equation matrices methods
395 
396  bool formNormalEquations();
397  bool computePartials(LinearAlgebra::Matrix &coeffTarget,
398  LinearAlgebra::Matrix &coeffImage,
399  LinearAlgebra::Matrix &coeffPoint3D,
400  LinearAlgebra::Vector &coeffRHS,
401  BundleMeasure &measure,
402  BundleControlPoint &point);
403  bool formMeasureNormals(boost::numeric::ublas::symmetric_matrix<
404  double, boost::numeric::ublas::upper > &N22,
406  boost::numeric::ublas::compressed_vector< double > &n1,
408  LinearAlgebra::Matrix &coeffTarget,
409  LinearAlgebra::Matrix &coeffImage,
410  LinearAlgebra::Matrix &coeffPoint3D,
411  LinearAlgebra::Vector &coeffRHS,
412  int observationIndex);
413  bool formPointNormals(boost::numeric::ublas::symmetric_matrix<
414  double, boost::numeric::ublas::upper > &N22,
418  BundleControlPointQsp &point);
419  bool formWeightedNormals(boost::numeric::ublas::compressed_vector< double > &n1,
421 
422  // dedicated matrix functions
423 
424  void productAB(SparseBlockColumnMatrix &A,
426  void accumProductAlphaAB(double alpha,
430  bool invert3x3(boost::numeric::ublas::symmetric_matrix<
431  double, boost::numeric::ublas::upper > &m);
432  bool productATransB(boost::numeric::ublas::symmetric_matrix<
433  double, boost::numeric::ublas::upper > &N22,
436  void productAlphaAV(double alpha,
437  boost::numeric::ublas::bounded_vector< double, 3 > &v2,
440 
441  // CHOLMOD library methods
442 
443  bool initializeCHOLMODLibraryVariables();
444  bool freeCHOLMODLibraryVariables();
445  bool cholmodInverse();
446  bool loadCholmodTriplet();
447  bool wrapUp();
448 
449  // member variables
450 
451  BundleSettingsQsp m_bundleSettings;
452  BundleResults m_bundleResults;
453  Statistics m_xResiduals;
455  Statistics m_yResiduals;
456  Statistics m_xyResiduals;
457  ControlNetQsp m_controlNet;
458  QString m_cnetFileName;
459  QVector <BundleControlPointQsp> m_bundleControlPoints;
463  BundleObservationVector m_bundleObservations;
466  SerialNumberList *m_serialNumberList;
467  BundleTargetBodyQsp m_bundleTargetBody;
469  bool m_abort;
470  QString m_iterationSummary;
472  bool m_printSummary;
475  bool m_cleanUp;
478  int m_rank;
479  int m_iteration;
480  int m_numberOfImagePartials;
481  QList<ImageList *> m_imageLists;
484  // ==========================================================================================
485  // === BEYOND THIS PLACE (THERE BE DRAGONS) all refers to the folded bundle solution. ===
486  // === Currently, everything uses the CHOLMOD library, ===
487  // === there is no dependence on the least-squares class. ===
488  // ==========================================================================================
489 
491  boost::numeric::ublas::symmetric_matrix<
492  double,
493  boost::numeric::ublas::upper,
494  boost::numeric::ublas::column_major > m_normalInverse;
495  cholmod_common m_cholmodCommon;
498  LinearAlgebra::Vector m_RHS;
500  SparseBlockMatrix m_sparseNormals;
504  cholmod_triplet *m_cholmodTriplet;
510  cholmod_sparse *m_cholmodNormal;
515  cholmod_factor *m_L;
519  LinearAlgebra::Vector m_imageSolution;
522  int m_previousNumberImagePartials;
525  };
526 }
527 
528 #endif
Isis::BundleAdjust::finished
void finished()
Isis::BundleAdjust::fileName
QString fileName(int index)
Return the ith filename in the cube list file given to constructor.
Definition: BundleAdjust.cpp:2806
Isis::BundleAdjust::iteration
double iteration() const
Returns what iteration the BundleAdjust is currently on.
Definition: BundleAdjust.cpp:2816
BundleObservationSolveSettings.h
Isis::BundleAdjust::serialNumberList
SerialNumberList * serialNumberList()
Returns a pointer to the serial number list.
Definition: BundleAdjust.cpp:2783
Isis::BundleAdjust
An image bundle adjustment object.
Definition: BundleAdjust.h:318
Isis::iApp
Application * iApp
Definition: Application.cpp:51
Isis::Statistics
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:94
Isis::Statistics::AddData
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Definition: Statistics.cpp:141
BundleResults.h
Isis::BundleMeasure::cubeSerialNumber
QString cubeSerialNumber() const
Accesses the serial number of the cube containing this control measure.
Definition: BundleMeasure.cpp:251
Isis::BundleControlPoint::adjustedSurfacePoint
SurfacePoint adjustedSurfacePoint() const
Accesses the adjusted SurfacePoint associated with this BundleControlPoint.
Definition: BundleControlPoint.cpp:479
Isis::SurfacePoint::GetSphericalMatrix
boost::numeric::ublas::symmetric_matrix< double, boost::numeric::ublas::upper > GetSphericalMatrix(SurfacePoint::CoordUnits units=SurfacePoint::Meters) const
Definition: SurfacePoint.cpp:1785
MaximumLikelihoodWFunctions.h
Isis::SparseBlockColumnMatrix
SparseBlockColumnMatrix.
Definition: SparseBlockMatrix.h:58
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::CameraGroundMap::GetXY
virtual bool GetXY(const SurfacePoint &spoint, double *cudx, double *cudy, bool test=true)
Compute undistorted focal plane coordinate from ground position using current Spice from SetImage cal...
Definition: CameraGroundMap.cpp:152
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::SerialNumberList::size
int size() const
How many serial number / filename combos are in the list.
Definition: SerialNumberList.cpp:384
Isis::Camera::SetImage
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition: Camera.cpp:154
SpecialPixel.h
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::BundleAdjust::isConverged
bool isConverged()
Returns if the BundleAdjust converged.
Definition: BundleAdjust.cpp:2949
Isis::Camera::GetCameraType
virtual CameraType GetCameraType() const =0
Returns the type of camera that was created.
CorrelationMatrix.h
Isis::SparseBlockRowMatrix::zeroBlocks
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
Definition: SparseBlockMatrix.cpp:611
Target.h
Longitude.h
Isis::ImageList::append
void append(Image *const &value)
Appends an image to the image list.
Definition: ImageList.cpp:153
Isis::BundleAdjust::abortBundle
void abortBundle()
Flag to abort when bundle is threaded.
Definition: BundleAdjust.cpp:707
BundleSettings.h
Isis::BundleMeasure::camera
Camera * camera() const
Accesses the associated camera for this bundle measure.
Definition: BundleMeasure.cpp:128
Isis::BundleAdjust::spVector
Table spVector(int index)
Return the updated instrument position table for the ith cube in the cube list given to the construct...
Definition: BundleAdjust.cpp:2846
Isis::iTime::CurrentLocalTime
static QString CurrentLocalTime()
Returns the current local time This time is taken directly from the system clock, so if the system cl...
Definition: iTime.cpp:513
CameraDetectorMap.h
Isis::Image::fileName
QString fileName() const
Get the file name of the cube that this image represents.
Definition: Image.cpp:340
SparseBlockMatrix.h
Isis::SurfacePoint::GetLatitude
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
Definition: SurfacePoint.cpp:1665
Isis::Camera::Camera
Camera(Cube &cube)
Constructs the Camera object.
Definition: Camera.cpp:54
Isis::BundleControlPoint
This class holds information about a control point that BundleAdjust needs to run correctly.
Definition: BundleControlPoint.h:91
Isis::Control
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:66
BundleTargetBody.h
QSharedPointer< BundleSettings >
Isis::SurfacePoint::ResetLocalRadius
void ResetLocalRadius(const Distance &radius)
This method resets the local radius of a SurfacePoint.
Definition: SurfacePoint.cpp:914
Isis::SparseBlockColumnMatrix::numberOfRows
int numberOfRows()
Returns total number of rows in map (this needs to be clarified and maybe rewritten).
Definition: SparseBlockMatrix.cpp:215
Isis::Camera
Definition: Camera.h:236
Isis::BundleAdjust::modelState
QString modelState(int index)
Return the updated model state for the ith cube in the cube list given to the constructor.
Definition: BundleAdjust.cpp:2859
Isis::LinearAlgebra::Matrix
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
Definition: LinearAlgebra.h:100
Isis::SurfacePoint::GetRectangularMatrix
boost::numeric::ublas::symmetric_matrix< double, boost::numeric::ublas::upper > GetRectangularMatrix(SurfacePoint::CoordUnits units=SurfacePoint::Meters) const
Definition: SurfacePoint.cpp:1603
Isis::BundleControlPoint::id
QString id() const
Accesses the Point ID associated with this BundleControlPoint.
Definition: BundleControlPoint.cpp:489
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::SerialNumberList
Serial Number list generator.
Definition: SerialNumberList.h:64
Isis::BundleAdjust::controlNet
ControlNetQsp controlNet()
Returns a pointer to the output control network.
Definition: BundleAdjust.cpp:2773
Isis::BundleAdjust::solveCholesky
bool solveCholesky()
Compute the least squares bundle adjustment solution using Cholesky decomposition.
Definition: BundleAdjust.cpp:726
Isis::BundleAdjust::pointUpdate
void pointUpdate(int)
Isis::SparseBlockColumnMatrix::startColumn
int startColumn() const
Sets starting column for block in full matrix.
Definition: SparseBlockMatrix.cpp:157
Isis::Distance
Distance measurement, usually in meters.
Definition: Distance.h:34
Isis::SparseBlockColumnMatrix::insertMatrixBlock
bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols)
Inserts a "newed" LinearAlgebra::Matrix pointer of size (nRows, nCols) into the map with the block co...
Definition: SparseBlockMatrix.cpp:121
Isis::ImageList
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
BundleObservation.h
Isis::ControlPoint
A single control point.
Definition: ControlPoint.h:354
Isis::SurfacePoint::SetMatrix
void SetMatrix(CoordinateType type, const boost::numeric::ublas::symmetric_matrix< double, boost::numeric::ublas::upper > &covar)
Set the covariance matrix.
Definition: SurfacePoint.cpp:749
Isis::BundleAdjust::isAborted
bool isAborted()
Returns if the BundleAdjust has been aborted.
Definition: BundleAdjust.cpp:2959
ControlNet.h
Latitude.h
Isis::LinearAlgebra::Vector
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
Definition: LinearAlgebra.h:120
Isis::Statistics::Rms
double Rms() const
Computes and returns the rms.
Definition: Statistics.cpp:365
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::SurfacePoint::CoordinateType
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
Definition: SurfacePoint.h:139
CameraGroundMap.h
IsisBundleObservation.h
StatCumProbDistDynCalc.h
BundleObservationVector.h
SerialNumberList.h
SurfacePoint.h
Isis::BundleAdjust::cMatrix
Table cMatrix(int index)
Return the updated instrument pointing table for the ith cube in the cube list given to the construct...
Definition: BundleAdjust.cpp:2831
Application.h
Isis::BundleAdjust::BundleAdjust
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:104
Isis::BundleAdjust::statusBarUpdate
void statusBarUpdate(QString)
Isis::BundleSolutionInfo
Container class for BundleAdjustment results.
Definition: BundleSolutionInfo.h:159
CameraDistortionMap.h
Isis::BundleMeasure::sample
double sample() const
Accesses the current sample measurement for this control measure.
Definition: BundleMeasure.cpp:191
Isis::Table
Class for storing Table blobs information.
Definition: Table.h:61
BundleControlPoint.h
Isis::SerialNumberList::add
void add(const QString &filename, bool def2filename=false)
Adds a new filename / serial number pair to the SerialNumberList.
Definition: SerialNumberList.cpp:121
Isis::BundleSolutionInfo::setRunTime
void setRunTime(QString runTime)
Sets the run time, and the name if a name is not already set.
Definition: BundleSolutionInfo.cpp:242
Isis::Image::closeCube
void closeCube()
Cleans up the Cube pointer.
Definition: Image.cpp:307
ControlPoint.h
CameraFocalPlaneMap.h
Isis::BundleAdjust::~BundleAdjust
~BundleAdjust()
Destroys BundleAdjust object, deallocates pointers (if we have ownership), and frees variables from c...
Definition: BundleAdjust.cpp:330
Isis::ControlNet
a control network
Definition: ControlNet.h:257
ImageList.h
Isis::BundleMeasure
A container class for a ControlMeasure.
Definition: BundleMeasure.h:55
ObservationNumberList.h
Isis::Image
This represents a cube in a project-based GUI interface.
Definition: Image.h:107
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::BundleAdjust::resultsReady
void resultsReady(BundleSolutionInfo *bundleSolveInformation)
Isis::Progress
Program progress reporter.
Definition: Progress.h:42
Isis::BundleAdjust::numberOfImages
int numberOfImages() const
Returns the number of images.
Definition: BundleAdjust.cpp:2793
Isis::IException::errorType
ErrorType errorType() const
Returns the source of the error for this exception.
Definition: IException.cpp:430
Isis::SurfacePoint::GetLongitude
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
Definition: SurfacePoint.cpp:1685
Camera.h
Isis::CSMCamera::getModelState
QString getModelState() const
Get the CSM Model state string to re-create the CSM Model.
Definition: CSMCamera.cpp:969
Isis::SparseBlockRowMatrix::insertMatrixBlock
bool insertMatrixBlock(int nRowBlock, int nRows, int nCols)
Inserts a "newed" LinearAlgebra::Matrix pointer of size (nRows, nCols) into the map with the block ro...
Definition: SparseBlockMatrix.cpp:507
Isis::BundleAdjust::solveCholeskyBR
BundleSolutionInfo * solveCholeskyBR()
Compute the least squares bundle adjustment solution using Cholesky decomposition.
Definition: BundleAdjust.cpp:697
Statistics.h
Isis::SurfacePoint::GetLocalRadius
Distance GetLocalRadius() const
Return the radius of the surface point.
Definition: SurfacePoint.cpp:1732
BundleAdjust.h
Isis::BundleAdjust::statusUpdate
void statusUpdate(QString)
CSMCamera.h
Isis::Camera::GroundMap
CameraGroundMap * GroundMap()
Returns a pointer to the CameraGroundMap object.
Definition: Camera.cpp:2856
Isis::BundleAdjust::iterationSummaryGroup
QString iterationSummaryGroup() const
Returns the iteration summary string.
Definition: BundleAdjust.cpp:2971
LinearAlgebra.h
Isis::Distance::meters
double meters() const
Get the distance in meters.
Definition: Distance.cpp:85
Isis::BundleImage
This class hold image information that BundleAdjust needs to run correctly.Definition for a BundleIma...
Definition: BundleImage.h:36
Isis::BundleMeasure::parentBundleObservation
QSharedPointer< BundleObservation > parentBundleObservation()
Accesses the parent BundleObservation for this bundle measure.
Definition: BundleMeasure.cpp:158
QMap
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:22
Isis::SparseBlockColumnMatrix::numberOfColumns
int numberOfColumns()
Returns total number of columns in map (NOTE: NOT the number of matrix blocks).
Definition: SparseBlockMatrix.cpp:190
Isis::BundleAdjust::outputBundleStatus
void outputBundleStatus(QString status)
Slot for deltack and jigsaw to output the bundle status.
Definition: BundleAdjust.cpp:2985
Isis::ControlPoint::IsIgnored
bool IsIgnored() const
Definition: ControlPoint.cpp:1311
Control.h
Isis::BundleAdjust::imageLists
QList< ImageList * > imageLists()
This method returns the image list used in the bundle adjust.
Definition: BundleAdjust.cpp:2376
Isis::CSMCamera
Definition: CSMCamera.h:25
iTime.h
Isis::SparseBlockRowMatrix
SparseBlockRowMatrix.
Definition: SparseBlockMatrix.h:125
Isis::BundleResults
A container class for statistical results from a BundleAdjust solution.
Definition: BundleResults.h:82
QObject
Distance.h
QVector
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:18
Isis::BundleAdjust::error
void error(QString)
Isis::ControlNetQsp
QSharedPointer< ControlNet > ControlNetQsp
This typedef is for future implementation of target body.
Definition: ControlNet.h:482
BundleSolutionInfo.h
Isis::SparseBlockMatrix
SparseBlockMatrix.
Definition: SparseBlockMatrix.h:186
Isis::BundleImageQsp
QSharedPointer< BundleImage > BundleImageQsp
Definition: BundleImage.h:67
Isis::cholmodErrorHandler
static void cholmodErrorHandler(int nStatus, const char *file, int nLineNo, const char *message)
Custom error handler for CHOLMOD.
Definition: BundleAdjust.cpp:72
Progress.h
Isis::SparseBlockColumnMatrix::wipe
void wipe()
Deletes all pointer elements and removes them from the map.
Definition: SparseBlockMatrix.cpp:52
Isis::BundleMeasure::line
double line() const
Accesses the current line measurement for this control measure.
Definition: BundleMeasure.cpp:215
Isis::BundleAdjust::iterationUpdate
void iterationUpdate(int)
Isis::SurfacePoint
This class defines a body-fixed surface point.
Definition: SurfacePoint.h:132
ControlMeasure.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::BundleObservationVector
This class is a container class for BundleObservations.
Definition: BundleObservationVector.h:55
Isis::Control::fileName
QString fileName() const
Access the name of the control network file associated with this Control.
Definition: Control.cpp:272