OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimSonomaSensor.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts
6 //
7 // Description:
8 //
9 // Sonoma
10 //*******************************************************************
11 // $Id$
12 #ifndef ossimSonomaSensor_HEADER
13 #define ossimSonomaSensor_HEADER
14 #include "ossimSensorModel.h"
15 #include "ossimUtmProjection.h"
16 #include <ossim/base/ossimDpt3d.h>
17 /*******************************************************************************************
18  *
19  * The Sonoma system uses an LN200 IMU. The orientation are euler angles of the form
20  * RzRxRz (roll*pitch*heading) where roll and heading are defined about the Rz. The sonoma
21  * software does their own camera callibration and appears to be a mtrix that goes from IMU
22  * to boresite allignment and for the ossim intersections we need to invert
23  * camera mount allignment matrix so we go from camer to IMU boresite allignment.
24  *
25  * Also talking with some contacts it appears that the intersections are done to a affine hyper plane
26  * and the coordinates for the initial ray origin and direction are UTM where the zone and hemishpere
27  * is initialized based on the platfrom position. Their height values are MSL and so I use
28  * the geoid grid to shift to the ellipsoid. We have our own intersectRay that intersects a plane
29  * plane equation.
30  *
31  *
32  * The load state keywords are:
33  * mount:
34  * pitch:
35  * heading:
36  * platform_position: (0,0, 0,WGE)
37  * pixel_size: (1,1)
38  * focal_length: .02
39  * principal_point: (0,0)
40  * rect: 0 0 4007 2671
41  * mount: 1.034918 -0.003693 0.309045 0.000000 -0.112617 1.064566 0.362789 0.000000 -0.269597 -0.391096 1.002515 0.000000
42  * sensor: Sonoma
43  * type: ossimSonomaSensor
44  *
45  *
46  * the mount is a orientation that we invert to go from camera to imu allignment. The roll pitch and heading are euler
47  * angles in degrees. The pixel size and focal lengths were defined as meters and we kept the units here to be meter
48  * units. The platform position is of the form (Lat, Lon, Height). We were not given any lens distortion measurments
49  * and the mount orientation was calculated by the sonoma product and was not part of the IMU information.
50  *
51  *******************************************************************************************/
53 {
54 public:
57  :ossimSensorModel(src),
58  m_compositeMatrix(src.m_compositeMatrix),
59  m_compositeMatrixInverse(src.m_compositeMatrixInverse),
60  m_pixelToCamera(src.m_pixelToCamera),
61  m_mount(src.m_mount),
62  m_roll(src.m_roll),
63  m_pitch(src.m_pitch),
64  m_heading(src.m_heading),
65  m_principalPoint(src.m_principalPoint), // in millimeters
66  m_pixelSize(src.m_pixelSize), // in millimeters
67  m_focalLength(src.m_focalLength), // in millimeters
68  m_ecefPlatformPosition(src.m_ecefPlatformPosition),
69  m_platformPosition(src.m_platformPosition),
70  m_platformPositionEllipsoid(src.m_platformPositionEllipsoid)
71  {
72  }
73  virtual ossimObject* dup()const
74  {
75  return new ossimSonomaSensor(*this);
76  }
77 
78  virtual void imagingRay(const ossimDpt& image_point,
79  ossimEcefRay& image_ray) const;
80 
81  virtual void lineSampleHeightToWorld(const ossimDpt& image_point,
82  const double& heightEllipsoid,
83  ossimGpt& worldPoint) const;
84  void lineSampleToWorld(const ossimDpt& image_point,
85  ossimGpt& gpt) const;
86 
87  // virtual void worldToLineSample(const ossimGpt& world_point,
88  // ossimDpt& image_point) const;
89  virtual void updateModel();
90 
91  void setRollPitchHeading(double r, double p, double y)
92  {
93  m_roll = r;
94  m_pitch = p;
95  m_heading = y;
96  }
97  void setFocalLength(double value)
98  {
99  m_focalLength = value;
100  }
101  void setPlatformPosition(const ossimGpt& value)
102  {
103  m_platformPosition = value;
104  m_ecefPlatformPosition = value;
105  }
106 
107  void setPrincipalPoint(const ossimDpt& value)
108  {
109  m_principalPoint = value;
110  }
111  void setPixelSize(const ossimDpt& value)
112  {
113  m_pixelSize = value;
114  }
115  inline virtual bool useForward()const {return true;}
116 
117  virtual void initAdjustableParameters();
118  virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
119  virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
120 
121 protected:
123  {
124  public:
125  ossimPlane(double nx=0, double ny=0, double nz=1.0,
126  double offset=1.0)
127  :m_nx(nx),
128  m_ny(ny),
129  m_nz(nz),
130  m_offset(offset)
131  {
132  }
133  bool intersect(ossimDpt3d& result, ossimDpt3d& origin, ossimDpt3d& ray)
134  {
135  // P*N + D = 0;
136  // solve for parametric t:
137  // P = P0+t*ray
138  //
139  // (P0 + t*ray)*N + D = 0
140  // (P0*N + P0*ray*t + D = 0;
141  // t = -(D + P0*N)/(N*ray)
142  // if(t >= 0.0 then intersection
143 
144  double numerator = m_offset + origin.x*m_nx+origin.y*m_ny + origin.z*m_nz;
145  double denominator = ray.z*m_nx + ray.y*m_ny + ray.z*m_nz;
146  if(ossim::almostEqual(denominator, 0.0))
147  {
148  return false;
149  }
150 
151  double t = -numerator/denominator;
152  result.x = origin.x + t*ray.x;
153  result.y = origin.y + t*ray.y;
154  result.z = origin.z + t*ray.z;
155 
156  return true;
157  }
158 
159  void setOffset(double offset)
160  {
161  m_offset = offset;
162  }
163  protected:
164  double m_nx,m_ny,m_nz;
165  double m_offset;
166  };
167  bool intersectRay(const ossimMapProjection& proj, ossimDpt3d& result, ossimDpt3d& origin, ossimDpt3d& dir)const;
168  bool intersectRayWithHeight(const ossimMapProjection& proj, ossimDpt3d& result, ossimDpt3d& origin, ossimDpt3d& dir, double h)const;
170  NEWMAT::Matrix m_compositeMatrix;
171  NEWMAT::Matrix m_compositeMatrixInverse;
172  NEWMAT::Matrix m_pixelToCamera;
173  NEWMAT::Matrix m_mount;
174  NEWMAT::Matrix m_mountInverse;
175  double m_roll;
176  double m_pitch;
177  double m_heading;
179  ossimDpt m_pixelSize; // in meters
180  double m_focalLength; // in meters
184 
185 
186  TYPE_DATA
187 };
188 
189 #endif
190 
void setRollPitchHeading(double r, double p, double y)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Represents serializable keyword/value map.
ossim_uint32 y
NEWMAT::Matrix m_pixelToCamera
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
Definition: ossimCommon.h:53
ossimEcefPoint m_ecefPlatformPosition
virtual void lineSampleToWorld(const ossimDpt &image_point, ossimGpt &world_point) const
void setPlatformPosition(const ossimGpt &value)
NEWMAT::Matrix m_mount
bool intersect(ossimDpt3d &result, ossimDpt3d &origin, ossimDpt3d &ray)
NEWMAT::Matrix m_compositeMatrix
double z
Definition: ossimDpt3d.h:145
#define TYPE_DATA
Definition: ossimRtti.h:339
NEWMAT::Matrix m_compositeMatrixInverse
ossimGpt m_platformPositionEllipsoid
void setPrincipalPoint(const ossimDpt &value)
void setFocalLength(double value)
virtual void lineSampleHeightToWorld(const ossimDpt &lineSampPt, const double &heightEllipsoid, ossimGpt &worldPt) const =0
virtual void imagingRay(const ossimDpt &image_point, ossimEcefRay &image_ray) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual void updateModel()
ossimRefPtr< ossimUtmProjection > m_utmProjection
void setPixelSize(const ossimDpt &value)
NEWMAT::Matrix m_mountInverse
#define OSSIM_DLL
double x
Definition: ossimDpt3d.h:143
double y
Definition: ossimDpt3d.h:144
virtual bool useForward() const
ossimPlane(double nx=0, double ny=0, double nz=1.0, double offset=1.0)
ossimSonomaSensor(const ossimSonomaSensor &src)
virtual ossimObject * dup() const