opennurbs_photogrammetry.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2013 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_PHOTOGRAMMETRY_INC_)
18 #define OPENNURBS_PHOTOGRAMMETRY_INC_
19 
21 {
22 public:
24 
25  bool IsSet() const;
26 
27  bool HeightIsSet() const;
28  bool CornersAreSet() const;
29  bool UnitSystemIsSet() const;
30 
31  void Unset();
32 
33  // The frustum unit system must be set. It is common
34  // for the frustum unit system to be millimeters.
36 
37  // The frustum's apex height must be positive.
38  // It is common for the image frustum height
39  // to be a camera's focal length.
40  double m_height;
41 
42  // The corners must be the vertices of a 3 or 4 sided
43  // convex region and must have counter-clockwise order
44  // in the 2d plane. It is common for the corners to be
45  // a rectangle (lower left, lower right, upper right,
46  // upper left) and for the rectangle to be symmetric
47  // about (0,0). However, when the image has been cropped,
48  // the frustum can be skew. The frustum's apex point is
49  // always directly above (0,0).
50  ON_2dPoint m_corners[4];
51 };
52 
54 {
55 public:
57 
58  /*
59  Returns:
60  True if both the location and orientation are set.
61  */
62  bool IsSet() const;
63 
64  void Unset();
65 
66  /////////////////////////////////////////////////////////
67  //
68  // Camera position unit system
69  //
70  bool UnitSystemIsSet() const;
71  bool SetUnitSystem( ON::LengthUnitSystem unit_system );
72  bool SetUnitSystem ( ON_UnitSystem unit_system );
73  ON_UnitSystem UnitSystem() const;
74  bool GetUnitSystem( ON_UnitSystem& unit_system ) const;
75  void UnsetUnitSystem();
76 
77 
78  /////////////////////////////////////////////////////////
79  //
80  // Location interface
81  //
82  bool LocationIsSet() const;
83 
84  bool SetLocation(
85  ON_3dPoint camera_location
86  );
87 
88  bool GetLocation(
89  ON_3dPoint& camera_location
90  ) const;
91 
92  ON_3dPoint Location() const;
93 
94  void UnsetLocation();
95 
96  /////////////////////////////////////////////////////////
97  //
98  // Orientation interface
99  //
100  bool OrientationIsSet() const;
101 
102  bool GetOrientationAnglesDegrees(
103  double* omega_degrees,
104  double* phi_degrees,
105  double* kappa_degrees
106  ) const;
107 
108  bool GetOrientationAnglesRadians(
109  double* omega_radians,
110  double* phi_radians,
111  double* kappa_radians
112  ) const;
113 
114  /*
115  Description:
116  Get a right handed ortho normal camera frame.
117  Parameters:
118  camera_X - [out]
119  world coordinate unit vector pointing to the right in the camera image
120  camera_Y - [out]
121  world coordinate unit vector in the camera up direction.
122  camera_Z - [out]
123  world coordinate unit vector pointing into the cameara (from the
124  image toward the camera).
125  */
126  bool GetOrientationFrame(
127  ON_3dVector& camera_X,
128  ON_3dVector& camera_Y,
129  ON_3dVector& camera_Z
130  ) const;
131 
132  bool GetOrientationUp(
133  ON_3dVector& camera_up
134  ) const;
135 
136  bool GetOrientationRight(
137  ON_3dVector& camera_right
138  ) const;
139 
140  bool GetOrientationDirection(
141  ON_3dVector& camera_direction
142  ) const;
143 
144 
145  /*
146  Returns:
147  A rotation transformation "R" such that
148  camera right = R*ON_3dVector::XAxis
149  camera up = R*ON_3dVector::YAxis
150  camera direction = -R*ON_3dVector::ZAxis
151  */
152  bool GetOrientationRotation(
153  ON_Xform& camera_rotaion
154  ) const;
155 
156  ON_Xform OrientationRotation() const;
157 
158  /*
159  Description:
160  Set camera orientation information from rotation angles
161  in radians.
162 
163  Remarks:
164  There are four ways to specify the camera's orientation.
165  1) Use SetOrientationAnglesRadians() to set
166  camera orientation information from rotation angles
167  in radians.
168  2) Use SetOrientationAnglesDegrees() to set
169  camera orientation information from rotation angles
170  in degrees.
171  3) Use SetOrientationVectors() to set
172  camera orientation information from vectors
173  that report the camera's up, right and direction.
174  3) Use SetOrientationRotation() to set
175  camera orientation information from a rotation
176  matrix.
177  Use the method for which you have the most accurate input
178  and the other values will be calculated as accurately as
179  possible.
180  */
181  bool SetOrientationAnglesRadians(
182  double omega_radians,
183  double phi_radians,
184  double kappa_radians
185  );
186 
187  /*
188  Description:
189  Set camera orientation information from rotation angles
190  in degrees.
191 
192  Remarks:
193  There are four ways to specify the camera's orientation.
194  1) Use SetCameraOrientationAnglesRadians() to set
195  camera orientation information from rotation angles
196  in radians.
197  2) Use SetCameraOrientationAnglesDegrees() to set
198  camera orientation information from rotation angles
199  in degrees.
200  3) Use SetCameraOrientationVectors() to set
201  camera orientation information from vectors
202  that report the camera's up, right and direction.
203  3) Use SetCameraOrientationRotation() to set
204  camera orientation information from a rotation
205  matrix.
206  Use the method for which you have the most accurate input
207  and the other values will be calculated as accurately as
208  possible.
209  */
210  bool SetOrientationAnglesDegrees(
211  double omega_degrees,
212  double phi_degrees,
213  double kappa_degrees
214  );
215 
216  /*
217  Description:
218  Set camera orientation information from up, right
219  and direction vectors.
220 
221  Remarks:
222  There are four ways to specify the camera's orientation.
223  1) Use SetCameraOrientationAnglesRadians() to set
224  camera orientation information from rotation angles
225  in radians.
226  2) Use SetCameraOrientationAnglesDegrees() to set
227  camera orientation information from rotation angles
228  in degrees.
229  3) Use SetCameraOrientationVectors() to set
230  camera orientation information from vectors
231  that report the camera's up, right and direction.
232  3) Use SetCameraOrientationRotation() to set
233  camera orientation information from a rotation
234  matrix.
235  Use the method for which you have the most accurate input
236  and the other values will be calculated as accurately as
237  possible.
238  */
239  bool SetOrientationVectors(
240  ON_3dVector camera_up,
241  ON_3dVector camera_right,
242  ON_3dVector camera_direction
243  );
244 
245  /*
246  Description:
247  Set camera orientation information from a rotation matrix.
248 
249  Remarks:
250  There are four ways to specify the camera's orientation.
251  1) Use SetCameraOrientationAnglesRadians() to set
252  camera orientation information from rotation angles
253  in radians.
254  2) Use SetCameraOrientationAnglesDegrees() to set
255  camera orientation information from rotation angles
256  in degrees.
257  3) Use SetCameraOrientationVectors() to set
258  camera orientation information from vectors
259  that report the camera's up, right and direction.
260  3) Use SetCameraOrientationRotation() to set
261  camera orientation information from a rotation
262  matrix.
263  Use the method for which you have the most accurate input
264  and the other values will be calculated as accurately as
265  possible.
266  */
267  bool SetOrientationRotation(
268  ON_Xform camera_rotation
269  );
270 
271  void UnsetOrientation();
272 
273 private:
274  unsigned char m_status;
275  unsigned char m_reserved1[3];
276  unsigned int m_reserved2;
277 
278  ON_UnitSystem m_unit_system;
279 
280  ON_3dPoint m_location;
281 
282  ON_3dVector m_orientation_angles_degrees;
283  ON_3dVector m_orientation_angles_radians;
284 
285  ON_3dVector m_orientation_direction;
286  ON_3dVector m_orientation_up;
287  ON_3dVector m_orientation_right;
288 
289  ON_Xform m_orientation_rotation;
290 };
292 
293 
294 
295 class ON_CLASS ON_AerialPhotoImage
296 {
297 public:
299 
300  void Unset();
301 
302  bool NameIsSet() const;
303 
304  void SetName(
305  const wchar_t* name
306  );
307 
308  void GetName(
309  ON_wString& name
310  ) const;
311 
312  void UnsetName();
313 
314  void SetId( ON_UUID image_id );
315 
316  ON_UUID Id() const;
317 
318  /////////////////////////////////////////////////////////
319  //
320  // Camera position interface
321  //
322  bool CameraPositionIsSet() const;
323  bool CameraLocationIsSet() const;
324  bool CameraOrientationIsSet() const;
325 
326  void SetCameraPosition(
327  ON_AerialPhotoCameraPosition camera_position
328  );
329 
330  void GetCameraPosition(
331  ON_AerialPhotoCameraPosition& camera_position
332  ) const;
333 
334  void UnsetCameraPosition();
335 
336  /////////////////////////////////////////////////////////
337  //
338  // Image frustum interface
339  //
340  bool ImageFrustumIsSet() const;
341 
342  void SetImageFrustum(
343  ON_AerialPhotoImageFrustum image_frustum
344  );
345 
346  void GetImageFrustum(
347  ON_AerialPhotoImageFrustum& image_frustum
348  ) const;
349 
350  void UnsetImageFrustum();
351 
352  /////////////////////////////////////////////////////////
353  //
354  // Image frustum interface
355  //
356  bool ImageFileNameIsSet() const;
357 
358  void SetImageFileName(
359  const wchar_t* image_file_name
360  );
361 
362  void GetImageFileName(
363  ON_wString& image_file_name
364  ) const;
365 
366  void UnsetImageFileName();
367 
368  bool ImageSizeIsSet() const;
369 
370  bool SetImageSize(
371  int width_pixels,
372  int height_pixels
373  );
374 
375  bool GetImageSize(
376  int* width_pixels,
377  int* height_pixels
378  ) const;
379 
380  void UnsetImageSize();
381 
382  /////////////////////////////////////////////////////////
383  //
384  // General tools
385  //
386  bool GetViewProjection(
387  ON_BoundingBox target_bbox,
388  ON_Viewport& viewport
389  ) const;
390 
391 private:
392  ON_wString m_name;
393 
394  ON_UUID m_id;
395 
396  ON_AerialPhotoCameraPosition m_camera_position;
397 
398  ON_AerialPhotoImageFrustum m_image_frustum;
399 
400  ON_wString m_image_file_name;
401 
402  int m_image_width_pixels;
403  int m_image_height_pixels;
404 };
405 
406 #endif
Definition: opennurbs_photogrammetry.h:53
ON_UUID is a 16 byte universally unique identifier.
Definition: opennurbs_uuid.h:32
Definition: opennurbs_photogrammetry.h:20
Definition: opennurbs_string.h:2020
Definition: opennurbs_point.h:277
double m_height
Definition: opennurbs_photogrammetry.h:40
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_xform.h:28
ON_UnitSystem m_unit_system
Definition: opennurbs_photogrammetry.h:35
Definition: opennurbs_string.h:3739
Definition: opennurbs_viewport.h:31
Definition: opennurbs_point.h:460
Definition: opennurbs_photogrammetry.h:291
Definition: opennurbs_point.h:1152