/usr/include/ossim/projection/ossimSensorModel.h is in libossim-dev 2.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | //*****************************************************************************
// FILE: ossimSensorModel.h
//
// License: See top level LICENSE.txt file.
//
// AUTHOR: Oscar Kramer
//
// DESCRIPTION:
// Contains declaration of class ossimSensorModel. This is the base class to
// all sensor model-related projections including replacement models such as
// coarse grids and polynomial models. This base class supports adjustable
// parameters for registration adjustment.
//
// Important note to sensor model implementors: In order to avoid a separate
// set of "initial adjustable parameters," this design assumes ALL initial
// values are 0. When designing the derived-class model, insure that the
// adjustable parameters are 0-based. This applies to theAdjustableParams
// array declared in this base class only. The derived classes can declare
// their own adjstable params that are more descriptive and that can be
// assigned an initial value that is non-zero, but that are linearly related
// to the adjustable params of this class. In that case, the updateModel()
// method will compute the derived-class's parameters based on
// theAdjustableParams array, after an adjustment is made.
//
// LIMITATIONS: None.
//
//*****************************************************************************
// $Id: ossimSensorModel.h 23297 2015-05-05 20:32:16Z dburken $
#ifndef ossimSensorModel_HEADER
#define ossimSensorModel_HEADER 1
#include <ossim/projection/ossimProjection.h>
#include <ossim/projection/ossimBilinearProjection.h>
#include <ossim/projection/ossimOptimizableProjection.h>
#include <ossim/base/ossimEcefRay.h>
#include <ossim/base/ossimString.h>
#include <ossim/base/ossimPolygon.h>
#include <ossim/base/ossimDrect.h>
#include <ossim/base/ossimCommon.h> /* for ossim::nan() */
#include <ossim/elevation/ossimElevSource.h>
#include <ossim/base/ossimAdjustableParameterInterface.h>
#include <ossim/matrix/newmat.h>
#include <ossim/matrix/newmatap.h>
#include <ossim/base/ossimException.h>
class ossimKeywordlist;
class ossimTieGptSet;
/*!****************************************************************************
*
* CLASS: ossimSensorModel
*
*****************************************************************************/
class OSSIMDLLEXPORT ossimSensorModel : public ossimProjection,
public ossimOptimizableProjection,
public ossimAdjustableParameterInterface
{
public:
enum CovMatStatus
{
COV_INVALID = 0,
COV_PARTIAL = 1,
COV_FULL = 2
};
enum DeriveMode
{
OBS_INIT =-99,
EVALUATE =-98,
P_WRT_X = -1,
P_WRT_Y = -2,
P_WRT_Z = -3
};
/*!
* CONSTRUCTORS:
*/
ossimSensorModel();
ossimSensorModel(const ossimSensorModel& copy_this);
ossimSensorModel(const ossimKeywordlist& geom_kwl);
/** @brief assignment operator */
const ossimSensorModel& operator=( const ossimSensorModel& rhs );
virtual ossimObject* getBaseObject();
virtual const ossimObject* getBaseObject()const;
/*!
* ACCESS METHODS:
*/
virtual ossimGpt origin() const {return theRefGndPt; }
virtual ossimDpt getMetersPerPixel() const {return ossimDpt(fabs(theGSD.x),
fabs(theGSD.y));}
//! Returns the estimated Absolute horizontal position error (CE90) of the sensor model.
virtual const double& getNominalPosError() const { return theNominalPosError; }
//! Returns the estimated RELATIVE horizontal position error (CE90) of the sensor model.
virtual const double& getRelativePosError() const { return theRelPosError; }
//! Assigns the absolute image position error uncertainty (abs CE90)
virtual void setNominalPosError(const double& ce90) { theNominalPosError = ce90; }
//! Assigns the relative image position error uncertainty (rel CE90)
virtual void setRelativePosError(const double& ce90) { theRelPosError = ce90; }
/*!
* Implementation of base-class pure virtual projection methods. These
* methods may be overriden by derived classes if those have more efficient
* schemes. The implementations here are iterative (relatively slow). Both
* depend on calls to the pure virtual lineSampleHeightToWorld() method.
*/
virtual void lineSampleToWorld(const ossimDpt& image_point,
ossimGpt& world_point) const;
virtual void worldToLineSample(const ossimGpt& world_point,
ossimDpt& image_point) const;
/*!
* METHOD: lineSampleHeightToWorld
* This is the pure virtual that performs the actual work of projecting
* the image point to the given elevation above Ellipsoid.
*/
virtual void lineSampleHeightToWorld(const ossimDpt& lineSampPt,
const double& heightEllipsoid,
ossimGpt& worldPt) const = 0;
/*!
* METHOD: imagingRay(image_point, &ossimEcefRay)
* Given an image point, returns a ray originating at some arbitrarily high
* point (ideally at the sensor position) and pointing towards the target.
* Implemented here but should be overriden for more efficient solution.
*/
virtual void imagingRay(const ossimDpt& image_point,
ossimEcefRay& image_ray) const;
/*!
* METHOD: print()
* Fulfills base-class pure virtual. Dumps contents of object to ostream.
*/
virtual std::ostream& print(std::ostream& out) const;
/**
* @brief Sets the center line sampe of the image.
*
* @param pt Image center point (x = sample, y = line).
*/
void setRefImgPt(const ossimDpt& pt);
/**
* @brief Sets the center latitude, longitude, height of the image.
*
* @param pt Image center point.
*/
void setRefGndPt(const ossimGpt& pt);
void setImageRect(const ossimDrect& imageRect);
void setGroundRect(const ossimGpt& ul,
const ossimGpt& ur,
const ossimGpt& lr,
const ossimGpt& ll);
/*!
* METHOD: imageSize()
* Returns the maximum line/sample rigorously defined by this model.
*/
ossimDpt imageSize() const { return theImageSize; }
void setImageSize(const ossimDpt& size){theImageSize = size;}
/*!
* This is from the adjustable parameter interface. It is
* called when a paraemter adjustment is made.
*/
virtual void adjustableParametersChanged()
{
updateModel();
}
/*!
* VIRTUAL METHOD: updateModel()
* Following a change to the adjustable parameter set, this virtual
* is called to permit instances to compute derived quantities after
* parameter change.
*/
virtual void updateModel() {}
/*!
* METHODS: saveState, loadState
* Fulfills ossimObject base-class pure virtuals. Loads and saves geometry
* KWL files.
*/
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0) const;
virtual bool loadState(const ossimKeywordlist& kwl,
const char* prefix=0);
/*!
* METHOD: insideImage(image_point)
* Returns true if the image_point lies inside the image rectangle.
*/
virtual bool insideImage(const ossimDpt& p) const
{
/* return( (p.u>=(0.0-FLT_EPSILON)) && */
/* (p.u<=(double)(theImageSize.u-(1-FLT_EPSILON))) && */
/* (p.v>=(0.0-FLT_EPSILON)) && */
/* (p.v<=(double)(theImageSize.v-(1-FLT_EPSILON))) ); */
// if it's close to the edge we will consider it inside the image
//
return theImageClipRect.pointWithin(p, 2.0);
}
/*!
* STATIC METHOD: writeGeomTemplate(ostream)
* Writes a template of keywords processed by loadState and saveState to
* output stream.
*/
static void writeGeomTemplate(ostream& os);
/*!
* OPERATORS:
*/
virtual bool operator==(const ossimProjection& proj) const; //inline below
//! Access methods:
const ossimString& getImageID() const { return theImageID; }
const ossimDrect& getImageClipRect() const { return theImageClipRect; }
/*!
* optimizableProjection implementation
*/
virtual ossim_uint32 degreesOfFreedom()const;
inline virtual bool needsInitialState()const {return true;}
virtual double optimizeFit(const ossimTieGptSet& tieSet,
double* targetVariance=0);
/*!
* METHOD: getForwardDeriv()
* gives forward() partial derivative regarding parameter parmIdx (>=0)
* default implementation is centered finite difference
* -should be reimplemented with formal derivative in child class
*/
virtual ossimDpt getForwardDeriv(int parmIdx, const ossimGpt& gpos, double hdelta=1e-11);
/*!
* METHOD: getInverseDeriv()
* gives inverse() partial derivative regarding parameter parmIdx (>=0)
* default implementation is centered finite difference
* -should be reimplemented with formal derivative in child class
*/
virtual ossimGpt getInverseDeriv(int parmIdx, const ossimDpt& ipos, double hdelta=1e-11);
/*!
* METHOD: getObsCovMat()
* @brief Gives 2X2 covariance matrix of observations
*/
virtual ossimSensorModel::CovMatStatus getObsCovMat(
const ossimDpt& ipos, NEWMAT::SymmetricMatrix& Cov,
const ossim_float64 defPointingSigma = 0.5) const;
/**
* @brief Implementation of pure virtual
* ossimProjection::isAffectedByElevation method.
* @return true.
*/
virtual bool isAffectedByElevation() const { return true; }
/**
* This method computes the ground sample distance(gsd) and sets class
* attributes theGSD and theMeanGSD by doing a lineSampleHeightToWorld on
* four points and calculating the distance from them.
*
* @return Nothing but throws ossimException on error.
*/
void computeGsd();
/**
* @brief Extracts geometry info from a non-ossim key,value pair
* to an ossim keyword list.
*
* @param key non-ossim-based input ossimString
* @param value non-ossim-based input ossimString
* @param geomKwl The keyword list to fill in.
*/
virtual bool getImageGeometry(
const ossimString& /* key */, const ossimString& /* value */,
ossimKeywordlist& /* geomKwl */ ) const { return false; }
protected:
virtual ~ossimSensorModel();
/*!
* METHOD: extrapolate()
* Extrapolates solutions for points outside of the image. The second
* version accepts a height value -- if left at the default, the elevation
* will be looked up via theElevation object.
*/
virtual ossimDpt extrapolate (const ossimGpt& gp) const;
virtual ossimGpt extrapolate (const ossimDpt& ip,
const double& height=ossim::nan()) const;
/*!
* METHOD: buildNormalEquation
* builds linearized system (LMS equivalent)
* A*dp = projResidue
*
* A: symetric matrix = tJ*J
* dp: system parameter shift that we want to estimate
* projResidue = tJ * residue
*
* t: transposition operator
* J = jacobian of transform relative to parameters p, transform can be forward() or inverse()
* jacobian is obtained via finite differences
* residue can be image (2D) or ground residue(3D)
*
* TODO: use image/ground points covariance matrices
*/
void buildNormalEquation(const ossimTieGptSet& tieSet,
NEWMAT::SymmetricMatrix& A,
NEWMAT::ColumnVector& residue,
NEWMAT::ColumnVector& projResidue,
double pstep_scale);
/*!
* METHOD: getResidue()
* returns ground opr image residue
*/
NEWMAT::ColumnVector getResidue(const ossimTieGptSet& tieSet);
NEWMAT::ColumnVector solveLeastSquares(NEWMAT::SymmetricMatrix& A, NEWMAT::ColumnVector& r)const;
/*!
* stable invert stolen from ossimRpcSolver
*/
NEWMAT::Matrix invert(const NEWMAT::Matrix& m)const;
ossimIpt theImageSize; // pixels
/*!
* Support sub-image of larger full image by maintaining offset to UL corner
*/
ossimDpt theSubImageOffset; // pixels
ossimString theImageID;
ossimString theSensorID;
ossimDpt theGSD; // meters
ossim_float64 theMeanGSD; // meters
ossimGpt theRefGndPt; // should be image center
ossimDpt theRefImgPt; // should be image center
ossimPolygon theBoundGndPolygon;
ossimDrect theImageClipRect;
ossim_float64 theRelPosError; // meters, relative to other models in the set
ossim_float64 theNominalPosError; // meters
/** Partials for current point */
ossimDpt theParWRTx;
ossimDpt theParWRTy;
ossimDpt theParWRTz;
/** Observations & residuals for current point */
ossimDpt theObs;
ossimDpt theResid;
/**
* Used as an initial guess for iterative solutions and a guess for points outside the support
* bounds.
*/
ossimRefPtr<ossimProjection> theSeedFunction;
mutable bool theExtrapolateImageFlag;
mutable bool theExtrapolateGroundFlag;
TYPE_DATA
};
//================= BEGIN INLINE DEFINITIONS =================================
//*****************************************************************************
// OPERATOR ==
//*****************************************************************************
inline bool ossimSensorModel::operator==(const ossimProjection& proj) const
{
// const ossimSensorModel* model
// = PTR_CAST(ossimSensorModel, (const ossimProjection*) &proj);
const ossimSensorModel* model = dynamic_cast<const ossimSensorModel*>( &proj );
if ( (!model) ||
(theSensorID != model->theSensorID) ||
(theImageID != model->theImageID) ||
(theSubImageOffset != model->theSubImageOffset) )
return false;
return true;
}
#endif
|