Ocean
AnyCamera.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_MATH_ANY_CAMERA_H
9 #define META_OCEAN_MATH_ANY_CAMERA_H
10 
11 #include "ocean/math/Math.h"
12 #include "ocean/math/Camera.h"
16 #include "ocean/math/Vector2.h"
17 #include "ocean/math/Vector3.h"
18 
19 namespace Ocean
20 {
21 
22 // Forward declaration.
23 template <typename T> class AnyCameraT;
24 
25 /**
26  * Definition of an AnyCamera object with Scalar precision.
27  * @see AnyCameraT
28  * @ingroup math
29  */
31 
32 /**
33  * Definition of an AnyCamera object with double precision.
34  * @see AnyCameraT
35  * @ingroup math
36  */
38 
39 /**
40  * Definition of an AnyCamera object with float precision.
41  * @see AnyCameraT
42  * @ingroup math
43  */
45 
46 /**
47  * Definition of a shared pointer holding an AnyCamera object with Scalar precision.
48  * @tparam T the data type of the scalar to be used either 'float' or 'double'
49  * @see AnyCameraT
50  * @ingroup math
51  */
52 template <typename T>
53 using SharedAnyCameraT = std::shared_ptr<AnyCameraT<T>>;
54 
55 /**
56  * Definition of a shared pointer holding an AnyCamera object with Scalar precision.
57  * @see AnyCameraT
58  * @ingroup math
59  */
60 using SharedAnyCamera = std::shared_ptr<AnyCamera>;
61 
62 /**
63  * Definition of a shared pointer holding an AnyCamera object with double precision.
64  * @see AnyCameraT
65  * @ingroup math
66  */
67 using SharedAnyCameraD = std::shared_ptr<AnyCameraD>;
68 
69 /**
70  * Definition of a shared pointer holding an AnyCamera object with float precision.
71  * @see AnyCameraT
72  * @ingroup math
73  */
74 using SharedAnyCameraF = std::shared_ptr<AnyCameraF>;
75 
76 /**
77  * Definition of a typename alias for vectors with shared AnyCameraT objects.
78  * @tparam T the data type of the scalar to be used either 'float' or 'double'
79  * @see VectorT2
80  * @ingroup math
81  */
82 template <typename T>
83 using SharedAnyCamerasT = std::vector<std::shared_ptr<AnyCameraT<T>>>;
84 
85 /**
86  * Definition of a vector holding AnyCamera objects.
87  * @see AnyCamera
88  * @ingroup math
89  */
91 
92 /**
93  * Definition of a vector holding AnyCameraD objects.
94  * @see AnyCameraD
95  * @ingroup math
96  */
98 
99 /**
100  * Definition of a vector holding AnyCameraF objects.
101  * @see AnyCameraF
102  * @ingroup math
103  */
105 
106 /**
107  * Definition of individual camera types.
108  * @ingroup math
109  */
110 enum class AnyCameraType : uint32_t
111 {
112  /// An invalid camera type.
113  INVALID = 0u,
114  /// A pinhole camera.
115  PINHOLE,
116  /// A fisheye camera.
117  FISHEYE
118 };
119 
120 /**
121  * This class implements the abstract base class for all AnyCamera objects.
122  * A custom camera object can be implemented by
123  * - simply deriving a new class from this base class
124  * - using the helper class AnyCameraWrappingT which helps reducing the implementation effort
125  * @tparam T The data type of a scalar, 'float' or 'double'
126  * @ingroup math
127  */
128 template <typename T>
129 class AnyCameraT : public CameraT<T>
130 {
131  public:
132 
133  /// The scalar data type of this object.
134  typedef T TScalar;
135 
136  public:
137 
138  /**
139  * Destructs the AnyCamera object.
140  */
141  virtual ~AnyCameraT() = default;
142 
143  /**
144  * Returns the type of this camera.
145  * @return The camera's type
146  */
147  virtual AnyCameraType anyCameraType() const = 0;
148 
149  /**
150  * Returns the name of this camera.
151  * @return The camera's name
152  */
153  virtual std::string name() const = 0;
154 
155  /**
156  * Returns a copy of this camera object.
157  * The image resolution of the cloned camera must have the same aspect ratio as the current image resolution.
158  * @param width The width of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
159  * @param height the height of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
160  * @return New instance of this camera object
161  */
162  virtual std::unique_ptr<AnyCameraT<T>> clone(const unsigned int width = 0u, const unsigned int height = 0u) const = 0;
163 
164  /**
165  * Returns a copy of this camera object with float precision.
166  * The image resolution of the cloned camera must have the same aspect ratio as the current image resolution.
167  * @param width The width of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
168  * @param height the height of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
169  * @return New instance of this camera object
170  */
171  virtual std::unique_ptr<AnyCameraT<float>> cloneToFloat(const unsigned int width = 0u, const unsigned int height = 0u) const = 0;
172 
173  /**
174  * Returns a copy of this camera object with double precision.
175  * The image resolution of the cloned camera must have the same aspect ratio as the current image resolution.
176  * @param width The width of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
177  * @param height the height of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
178  * @return New instance of this camera object
179  */
180  virtual std::unique_ptr<AnyCameraT<double>> cloneToDouble(const unsigned int width = 0u, const unsigned int height = 0u) const = 0;
181 
182  /**
183  * Returns the width of the camera image.
184  * @return Width of the camera image, in pixel, with range [0, infinity)
185  */
186  virtual unsigned int width() const = 0;
187 
188  /**
189  * Returns the height of the camera image.
190  * @return Height of the camera image, in pixel, with range [0, infinity)
191  */
192  virtual unsigned int height() const = 0;
193 
194  /**
195  * Returns the coordinate of the principal point of the camera image in the pixel domain.
196  * @return The 2D location of the principal point, with range (-infinity, infinity)x(-infinity, infinity)
197  */
198  virtual VectorT2<T> principalPoint() const = 0;
199 
200  /**
201  * Returns the x-value of the principal point of the camera image in the pixel domain.
202  * @return x-value of the principal point, with range (-infinity, infinity)
203  */
204  virtual T principalPointX() const = 0;
205 
206  /**
207  * Returns the y-value of the principal point of the camera image in the pixel domain.
208  * @return y-value of the principal point, with range (-infinity, infinity)
209  */
210  virtual T principalPointY() const = 0;
211 
212  /**
213  * Returns the horizontal focal length parameter.
214  * @return Horizontal focal length parameter in pixel domain, with range (0, infinity)
215  */
216  virtual T focalLengthX() const = 0;
217 
218  /**
219  * Returns the vertical focal length parameter.
220  * @return Vertical focal length parameter in pixel domain, with range (0, infinity)
221  */
222  virtual T focalLengthY() const = 0;
223 
224  /**
225  * Returns the inverse horizontal focal length parameter.
226  * @return Inverse horizontal focal length parameter in pixel domain, with range (0, infinity)
227  */
228  virtual T inverseFocalLengthX() const = 0;
229 
230  /**
231  * Returns the inverse vertical focal length parameter.
232  * @return Inverse vertical focal length parameter in pixel domain, with range (0, infinity)
233  */
234  virtual T inverseFocalLengthY() const = 0;
235 
236  /**
237  * Returns the field of view in x direction of the camera.
238  * The fov is the sum of the left and right part of the camera.
239  * @return Field of view (in radian), with range (0, 2 * PI]
240  */
241  virtual T fovX() const = 0;
242 
243  /**
244  * Returns the field of view in x direction of the camera.
245  * The fov is the sum of the top and bottom part of the camera.
246  * @return Field of view (in radian), with range (0, 2 * PI]
247  */
248  virtual T fovY() const = 0;
249 
250  /**
251  * Returns whether a given 2D image point lies inside the camera frame.
252  * Optional an explicit border can be defined to allow points slightly outside the camera image, or further inside the image.<br>
253  * Defined a negative border size to allow image points outside the camera frame, or a positive border size to prevent points within the camera frame but close to the boundary.
254  * @param imagePoint Image point to be checked, must be valid
255  * @param signedBorder The optional border increasing or decreasing the rectangle in which the image point must be located, in pixels, with range (-infinity, std::min(width() / 2, height() / 2)
256  * @return True, if the image point lies in the ranges [0, width())x[0, height())
257  */
258  virtual bool isInside(const VectorT2<T>& imagePoint, const T signedBorder = T(0)) const = 0;
259 
260  /**
261  * Projects a 3D object point into the camera frame.
262  * The projection is applied with a default camera pose, the camera is looking into the negative z-space with y-axis up.
263  * @param objectPoint The 3D object point to project, defined in world
264  * @return The projected 2D image point
265  */
266  virtual VectorT2<T> projectToImage(const VectorT3<T>& objectPoint) const = 0;
267 
268  /**
269  * Projects a 3D object point into the camera frame.
270  * @param world_T_camera The camera pose, the default camera is looking into the negative z-space with y-axis up, transforming camera to world, must be valid
271  * @param objectPoint The 3D object point to project, defined in world
272  * @return The projected 2D image point
273  */
274  virtual VectorT2<T> projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>& objectPoint) const = 0;
275 
276  /**
277  * Projects several 3D object points into the camera frame at once.
278  * The projection is applied with a default camera pose, the camera is looking into the negative z-space with y-axis up.
279  * @param objectPoints The 3D object points to project, defined in world, must be valid
280  * @param size The number of object points, with range [1, infinity)
281  * @param imagePoints The resulting 2D image points, must be valid
282  */
283  virtual void projectToImage(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const = 0;
284 
285  /**
286  * Projects several 3D object points into the camera frame at once.
287  * @param world_T_camera The camera pose, the default camera is looking into the negative z-space with y-axis up, transforming camera to world, must be valid
288  * @param objectPoints The 3D object points to project, defined in world, must be valid
289  * @param size The number of object points, with range [1, infinity)
290  * @param imagePoints The resulting 2D image points, must be valid
291  */
292  virtual void projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const = 0;
293 
294  /**
295  * Projects a 3D object point into the camera frame.
296  * The projection is applied with a default (inverted) and flipped camera pose, the camera is looking into the positive z-space with y-axis down.
297  * @param objectPoint The 3D object point to project, defined in world
298  * @return The projected 2D image point
299  */
300  virtual VectorT2<T> projectToImageIF(const VectorT3<T>& objectPoint) const = 0;
301 
302  /**
303  * Projects a 3D object point into the camera frame.
304  * @param flippedCamera_T_world The inverted and flipped camera pose, the default camera is looking into the positive z-space with y-axis down, transforming world to flipped camera, must be valid
305  * @param objectPoint The 3D object point to project, defined in world
306  * @return The projected 2D image point
307  */
308  virtual VectorT2<T> projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const = 0;
309 
310  /**
311  * Projects several 3D object points into the camera frame at once.
312  * The projection is applied with a default (inverted) and flipped camera pose, the camera is looking into the positive z-space with y-axis down.
313  * @param objectPoints The 3D object points to project, defined in world, must be valid
314  * @param size The number of object points, with range [1, infinity)
315  * @param imagePoints The resulting 2D image points, must be valid
316  */
317  virtual void projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const = 0;
318 
319  /**
320  * Projects several 3D object points into the camera frame at once.
321  * @param flippedCamera_T_world The inverted and flipped camera pose, the default camera is looking into the positive z-space with y-axis down, transforming world to flipped camera, must be valid
322  * @param objectPoints The 3D object points to project, defined in world, must be valid
323  * @param size The number of object points, with range [1, infinity)
324  * @param imagePoints The resulting 2D image points, must be valid
325  */
326  virtual void projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const = 0;
327 
328  /**
329  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
330  * The vector is determined for a default camera looking into the negative z-space with y-axis up.
331  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
332  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
333  * @return Vector pointing into the negative z-space
334  * @see vectorIF(), ray().
335  */
336  virtual VectorT3<T> vector(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector = true) const = 0;
337 
338  /**
339  * Determines vectors starting at the camera's center and intersecting given 2D points in the image.
340  * The vectors are determined for a default camera looking into the negative z-space with y-axis up.
341  * @param distortedImagePoints 2D (distorted) positions within the image, with range [0, width())x[0, height()), must be valid
342  * @param size The number of provided points, with range [1, infinity)
343  * @param vectors The resulting vectors pointing into the negative z-space, one for each image point, must be valid
344  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
345  * @see vectorIF(), ray().
346  */
347  virtual void vector(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector = true) const = 0;
348 
349  /**
350  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
351  * The vector is determined for a default camera looking into the positive z-space with y-axis down.
352  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
353  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
354  * @return Vector pointing into the positive z-space
355  */
356  virtual VectorT3<T> vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector = true) const = 0;
357 
358  /**
359  * Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
360  * The vectors are determined for a default camera looking into the positive z-space with y-axis down.
361  * @param distortedImagePoints 2D (distorted) positions within the image, with range [0, width())x[0, height()), must be valid
362  * @param size The number of provided points, with range [1, infinity)
363  * @param vectors The resulting vectors pointing into the positive z-space, one for each image point, must be valid
364  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
365  */
366  virtual void vectorIF(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector = true) const = 0;
367 
368  /**
369  * Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
370  * The ray is determined for a default camera looking into the negative z-space with y-axis up.
371  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
372  * @param world_T_camera The pose of the camera, the extrinsic camera matrix, must be valid
373  * @return The specified ray with direction pointing into the camera's negative z-space
374  * @see vector().
375  */
376  virtual LineT3<T> ray(const VectorT2<T>& distortedImagePoint, const HomogenousMatrixT4<T>& world_T_camera) const = 0;
377 
378  /**
379  * Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
380  * The ray is determined for a default camera looking into the negative z-space with y-axis up.
381  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
382  * @return The specified ray with direction pointing into the camera's negative z-space
383  * @see vector().
384  */
385  virtual LineT3<T> ray(const VectorT2<T>& distortedImagePoint) const = 0;
386 
387  /**
388  * Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
389  * The resulting jacobian matrix has the following layout:
390  * <pre>
391  * | dfu / dx, dfu / dy, dfu / dz |
392  * | dfv / dx, dfv / dy, dfv / dz |
393  * with projection function
394  * q = f(p)
395  * q_u = fu(p), q_y = fv(p)
396  * with 2D image point q = (q_u, q_v) and 3D object point p = (x, y, z)
397  * </pre>
398  * @param flippedCameraObjectPoint The 3D object point defined in relation to the inverted and flipped camera pose (camera looking into the positive z-space with y-axis pointing down).
399  * @param jx The resulting first row of the Jacobian matrix, must contain three elements, must be valid
400  * @param jy The resulting second row of the Jacobian matrix, must contain three elements, must be valid
401  * @see pointJacobian2nx3IF().
402  */
403  virtual void pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const = 0;
404 
405  /**
406  * Calculates the 2n x 3 jacobian matrix for the 3D object point projection into the camera frame.
407  * The resulting jacobian matrix has the following layout:
408  * <pre>
409  * | dfu / dx, dfu / dy, dfu / dz | <- for object point 0
410  * | dfv / dx, dfv / dy, dfv / dz |
411  * | ... |
412  * | dfu / dx, dfu / dy, dfu / dz | <- for object point n - 1
413  * | dfv / dx, dfv / dy, dfv / dz |
414  * with projection function
415  * q = f(p)
416  * q_u = fu(p), q_y = fv(p)
417  * with 2D image point q = (q_u, q_v) and 3D object point p = (x, y, z)
418  * </pre>
419  * @param flippedCameraObjectPoints The 3D object points defined in relation to the inverted and flipped camera pose (camera looking into the positive z-space with y-axis pointing down).
420  * @param numberObjectPoints The number of given 3D object points, with range [1, infinity)
421  * @param jacobians The resulting 2n x 3 Jacobian matrix, with 2 * numberObjectPoints * 3 elements, must be valid
422  * @see pointJacobian2x3IF().
423  */
424  virtual void pointJacobian2nx3IF(const VectorT3<T>* flippedCameraObjectPoints, const size_t numberObjectPoints, T* jacobians) const = 0;
425 
426  /**
427  * Returns whether two camera objects are identical up to a given epsilon.
428  * The image resolution must always be identical.
429  * @param anyCamera The second camera to be used for comparison, can be invalid
430  * @param eps The epsilon threshold to be used, with range [0, infinity)
431  * @return True, if so
432  */
433  virtual bool isEqual(const AnyCameraT<T>& anyCamera, const T eps = NumericT<T>::eps()) const = 0;
434 
435  /**
436  * Returns whether this camera is valid.
437  * @return True, if so
438  */
439  virtual bool isValid() const = 0;
440 
441  /**
442  * Converts an AnyCamera object with arbitrary scalar type to another AnyCamera object with arbitrary scalar type.
443  * In case both scalar types are identical, the object is simply returned.
444  * In case both scalar types are different, a clone is returned.
445  * @param anyCamera The AnyCamera object to be converted, can be nullptr
446  * @return The resulting AnyCamera object
447  * @tparam U The scalar data type of the given AnyCamera object
448  */
449  template <typename U>
450  static std::shared_ptr<AnyCameraT<T>> convert(const std::shared_ptr<AnyCameraT<U>>& anyCamera);
451 
452  protected:
453 
454  /**
455  * Protected default constructor.
456  */
457  AnyCameraT() = default;
458 
459  /**
460  * Protected copy constructor.
461  * @param anyCamera The object to copy
462  */
463  AnyCameraT(const AnyCameraT<T>& anyCamera) = default;
464 
465  /**
466  * Disabled move constructor.
467  */
469 
470  /**
471  * Disabled assign operator.
472  * @return Reference to this object
473  */
474  AnyCameraT& operator=(const AnyCameraT&) = delete;
475 
476  /**
477  * Disabled move operator.
478  * @return Reference to this object
479  */
481 };
482 
483 /**
484  * This class implements a specialized AnyCamera object wrapping the actual camera model.
485  * The class is a helper class to simplify the implementation of specialized AnyCamera objects.
486  * @tparam T The data type of a scalar, 'float' or 'double'
487  * @tparam TCameraWrapper The data type of the class actually wrapping the camera object
488  * @ingroup math
489  */
490 template <typename T, typename TCameraWrapper>
491 class AnyCameraWrappingT final :
492  public AnyCameraT<T>,
493  public TCameraWrapper
494 {
495  public:
496 
497  /// The scalar data type of this object.
498  typedef T TScalar;
499 
500  /// The class which is actually wrapping the camera object.
502 
503  /// The actual camera object wrapped by this class.
504  typedef typename TCameraWrapper::ActualCamera ActualCamera;
505 
506  public:
507 
508  /**
509  * Creates a new AnyCamera object wrapping the actual camera model.
510  * @param actualCamera The actual camera object to be wrapped
511  */
512  explicit AnyCameraWrappingT(ActualCamera&& actualCamera);
513 
514  /**
515  * Creates a new AnyCamera object wrapping the actual camera model.
516  * @param actualCamera The actual camera object to be wrapped
517  */
518  explicit AnyCameraWrappingT(const ActualCamera& actualCamera);
519 
520  /**
521  * Returns the type of this camera.
522  * @return The camera's type
523  */
524  AnyCameraType anyCameraType() const override;
525 
526  /**
527  * Returns the name of this camera.
528  * @return The camera's name
529  */
530  std::string name() const override;
531 
532  /**
533  * Returns a copy of this camera object.
534  * The image resolution of the cloned camera must have the same aspect ratio as the current image resolution.
535  * @param width The width of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
536  * @param height the height of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
537  * @return New instance of this camera object
538  */
539  std::unique_ptr<AnyCameraT<T>> clone(const unsigned int width = 0u, const unsigned int height = 0u) const override;
540 
541  /**
542  * Returns a copy of this camera object with float precision.
543  * The image resolution of the cloned camera must have the same aspect ratio as the current image resolution.
544  * @param width The width of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
545  * @param height the height of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
546  * @return New instance of this camera object
547  */
548  std::unique_ptr<AnyCameraT<float>> cloneToFloat(const unsigned int width = 0u, const unsigned int height = 0u) const override;
549 
550  /**
551  * Returns a copy of this camera object with double precision.
552  * The image resolution of the cloned camera must have the same aspect ratio as the current image resolution.
553  * @param width The width of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
554  * @param height the height of the cloned camera in pixel, with range [1, infinity), 0 to use the current image resolution
555  * @return New instance of this camera object
556  */
557  std::unique_ptr<AnyCameraT<double>> cloneToDouble(const unsigned int width = 0u, const unsigned int height = 0u) const override;
558 
559  /**
560  * Returns the width of the camera image.
561  * @return Width of the camera image, in pixel, with range [0, infinity)
562  */
563  unsigned int width() const override;
564 
565  /**
566  * Returns the height of the camera image.
567  * @return Height of the camera image, in pixel, with range [0, infinity)
568  */
569  unsigned int height() const override;
570 
571  /**
572  * Returns the coordinate of the principal point of the camera image in the pixel domain.
573  * @return The 2D location of the principal point, with range (-infinity, infinity)x(-infinity, infinity)
574  */
575  VectorT2<T> principalPoint() const override;
576 
577  /**
578  * Returns the x-value of the principal point of the camera image in the pixel domain.
579  * @return x-value of the principal point, with range (-infinity, infinity)
580  */
581  T principalPointX() const override;
582 
583  /**
584  * Returns the y-value of the principal point of the camera image in the pixel domain.
585  * @return y-value of the principal point, with range (-infinity, infinity)
586  */
587  T principalPointY() const override;
588 
589  /**
590  * Returns the horizontal focal length parameter.
591  * @return Horizontal focal length parameter in pixel domain, with range (0, infinity)
592  */
593  T focalLengthX() const override;
594 
595  /**
596  * Returns the vertical focal length parameter.
597  * @return Vertical focal length parameter in pixel domain, with range (0, infinity)
598  */
599  T focalLengthY() const override;
600 
601  /**
602  * Returns the inverse horizontal focal length parameter.
603  * @return Inverse horizontal focal length parameter in pixel domain, with range (0, infinity)
604  */
605  T inverseFocalLengthX() const override;
606 
607  /**
608  * Returns the inverse vertical focal length parameter.
609  * @return Inverse vertical focal length parameter in pixel domain, with range (0, infinity)
610  */
611  T inverseFocalLengthY() const override;
612 
613  /**
614  * Returns the field of view in x direction of the camera.
615  * The fov is the sum of the left and right part of the camera.
616  * @return Field of view (in radian), with range (0, 2 * PI]
617  */
618  T fovX() const override;
619 
620  /**
621  * Returns the field of view in x direction of the camera.
622  * The fov is the sum of the top and bottom part of the camera.
623  * @return Field of view (in radian), with range (0, 2 * PI]
624  */
625  T fovY() const override;
626 
627  /**
628  * Returns whether a given 2D image point lies inside the camera frame.
629  * Optional an explicit border can be defined to allow points slightly outside the camera image, or further inside the image.<br>
630  * Defined a negative border size to allow image points outside the camera frame, or a positive border size to prevent points within the camera frame but close to the boundary.
631  * @param imagePoint Image point to be checked, must be valid
632  * @param signedBorder The optional border increasing or decreasing the rectangle in which the image point must be located, in pixels, with range (-infinity, std::min(width() / 2, height() / 2)
633  * @return True, if the image point lies in the ranges [0, width())x[0, height())
634  */
635  bool isInside(const VectorT2<T>& imagePoint, const T signedBorder = T(0)) const override;
636 
637  /**
638  * Projects a 3D object point into the camera frame.
639  * The projection is applied with a default camera pose, the camera is looking into the negative z-space with y-axis up.
640  * @param objectPoint The 3D object point to project, defined in world
641  * @return The projected 2D image point
642  */
643  VectorT2<T> projectToImage(const VectorT3<T>& objectPoint) const override;
644 
645  /**
646  * Projects a 3D object point into the camera frame.
647  * @param world_T_camera The camera pose, the default camera is looking into the negative z-space with y-axis up, transforming camera to world, must be valid
648  * @param objectPoint The 3D object point to project, defined in world
649  * @return The projected 2D image point
650  */
651  VectorT2<T> projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>& objectPoint) const override;
652 
653  /**
654  * Projects several 3D object points into the camera frame at once.
655  * The projection is applied with a default camera pose, the camera is looking into the negative z-space with y-axis up.
656  * @param objectPoints The 3D object points to project, defined in world, must be valid
657  * @param size The number of object points, with range [1, infinity)
658  * @param imagePoints The resulting 2D image points, must be valid
659  */
660  void projectToImage(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const override;
661 
662  /**
663  * Projects several 3D object points into the camera frame at once.
664  * @param world_T_camera The camera pose, the default camera is looking into the negative z-space with y-axis up, transforming camera to world, must be valid
665  * @param objectPoints The 3D object points to project, defined in world, must be valid
666  * @param size The number of object points, with range [1, infinity)
667  * @param imagePoints The resulting 2D image points, must be valid
668  */
669  void projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const override;
670 
671  /**
672  * Projects a 3D object point into the camera frame.
673  * The projection is applied with a default (inverted) and flipped camera pose, the camera is looking into the positive z-space with y-axis down.
674  * @param objectPoint The 3D object point to project, defined in world
675  * @return The projected 2D image point
676  */
677  VectorT2<T> projectToImageIF(const VectorT3<T>& objectPoint) const override;
678 
679  /**
680  * Projects a 3D object point into the camera frame.
681  * @param flippedCamera_T_world The inverted and flipped camera pose, the default camera is looking into the positive z-space with y-axis down, transforming world to flipped camera, must be valid
682  * @param objectPoint The 3D object point to project, defined in world
683  * @return The projected 2D image point
684  */
685  VectorT2<T> projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const override;
686 
687  /**
688  * Projects several 3D object points into the camera frame at once.
689  * The projection is applied with a default (inverted) and flipped camera pose, the camera is looking into the positive z-space with y-axis down.
690  * @param objectPoints The 3D object points to project, defined in world, must be valid
691  * @param size The number of object points, with range [1, infinity)
692  * @param imagePoints The resulting 2D image points, must be valid
693  */
694  void projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const override;
695 
696  /**
697  * Projects several 3D object points into the camera frame at once.
698  * @param flippedCamera_T_world The inverted and flipped camera pose, the default camera is looking into the positive z-space with y-axis down, transforming world to flipped camera, must be valid
699  * @param objectPoints The 3D object points to project, defined in world, must be valid
700  * @param size The number of object points, with range [1, infinity)
701  * @param imagePoints The resulting 2D image points, must be valid
702  */
703  void projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const override;
704 
705  /**
706  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
707  * The vector is determined for the default camera looking into the negative z-space with y-axis up.
708  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
709  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
710  * @return Vector pointing into the negative z-space
711  * @see vectorIF(), ray().
712  */
713  VectorT3<T> vector(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector = true) const override;
714 
715  /**
716  * Determines vectors starting at the camera's center and intersecting given 2D points in the image.
717  * The vectors are determined for a default camera looking into the negative z-space with y-axis up.
718  * @param distortedImagePoints 2D (distorted) positions within the image, with range [0, width())x[0, height()), must be valid
719  * @param size The number of provided points, with range [1, infinity)
720  * @param vectors The resulting vectors pointing into the negative z-space, one for each image point, must be valid
721  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
722  * @see vectorIF(), ray().
723  */
724  void vector(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector = true) const override;
725 
726  /**
727  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
728  * The vector is determined for the default camera looking into the positive z-space with y-axis down.
729  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
730  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
731  * @return Vector pointing into the positive z-space
732  */
733  VectorT3<T> vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector = true) const override;
734 
735  /**
736  * Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
737  * The vectors are determined for a default camera looking into the positive z-space with y-axis down.
738  * @param distortedImagePoints 2D (distorted) positions within the image, with range [0, width())x[0, height()), must be valid
739  * @param size The number of provided points, with range [1, infinity)
740  * @param vectors The resulting vectors pointing into the positive z-space, one for each image point, must be valid
741  * @param makeUnitVector True, to return a vector with length 1; False, to return a vector with any length
742  */
743  void vectorIF(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector = true) const override;
744 
745  /**
746  * Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
747  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
748  * @param world_T_camera The pose of the camera, the extrinsic camera matrix, must be valid
749  * @return The specified ray with direction pointing into the camera's negative z-space
750  * @see vector().
751  */
752  LineT3<T> ray(const VectorT2<T>& distortedImagePoint, const HomogenousMatrixT4<T>& world_T_camera) const override;
753 
754  /**
755  * Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
756  * @param distortedImagePoint 2D (distorted) position within the image, with range [0, width())x[0, height())
757  * @return The specified ray with direction pointing into the camera's negative z-space
758  * @see vector().
759  */
760  LineT3<T> ray(const VectorT2<T>& distortedImagePoint) const override;
761 
762  /**
763  * Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
764  * The resulting jacobian matrix has the following layout:
765  * <pre>
766  * | dfu / dx, dfu / dy, dfu / dz |
767  * | dfv / dx, dfv / dy, dfv / dz |
768  * with projection function
769  * q = f(p)
770  * q_u = fu(p), q_y = fv(p)
771  * with 2D image point q = (q_u, q_v) and 3D object point p = (x, y, z)
772  * </pre>
773  * @param flippedCameraObjectPoint The 3D object point defined in relation to the inverted and flipped camera pose (camera looking into the positive z-space with y-axis pointing down).
774  * @param jx The resulting first row of the Jacobian matrix, must contain three elements, must be valid
775  * @param jy The resulting second row of the Jacobian matrix, must contain three elements, must be valid
776  */
777  void pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const override;
778 
779  /**
780  * Calculates the 2n x 3 jacobian matrix for the 3D object point projection into the camera frame.
781  * The resulting jacobian matrix has the following layout:
782  * <pre>
783  * | dfu / dx, dfu / dy, dfu / dz | <- for object point 0
784  * | dfv / dx, dfv / dy, dfv / dz |
785  * | ... |
786  * | dfu / dx, dfu / dy, dfu / dz | <- for object point n - 1
787  * | dfv / dx, dfv / dy, dfv / dz |
788  * with projection function
789  * q = f(p)
790  * q_u = fu(p), q_y = fv(p)
791  * with 2D image point q = (q_u, q_v) and 3D object point p = (x, y, z)
792  * </pre>
793  * @param flippedCameraObjectPoints The 3D object points defined in relation to the inverted and flipped camera pose (camera looking into the positive z-space with y-axis pointing down).
794  * @param numberObjectPoints The number of given 3D object points, with range [1, infinity)
795  * @param jacobians The resulting 2n x 3 Jacobian matrix, with 2 * numberObjectPoints * 3 elements, must be valid
796  */
797  void pointJacobian2nx3IF(const VectorT3<T>* flippedCameraObjectPoints, const size_t numberObjectPoints, T* jacobians) const override;
798 
799  /**
800  * Returns whether two camera objects are identical up to a given epsilon.
801  * The image resolution must always be identical.
802  * @param anyCamera The second camera to be used for comparison, can be invalid
803  * @param eps The epsilon threshold to be used, with range [0, infinity)
804  * @return True, if so
805  */
806  bool isEqual(const AnyCameraT<T>& anyCamera, const T eps = NumericT<T>::eps()) const override;
807 
808  /**
809  * Returns whether this camera is valid.
810  * @return True, if so
811  */
812  bool isValid() const override;
813 };
814 
815 /**
816  * This class implements a wrapper for an actual camera object.
817  * - TCameraWrapperBase implements the wrapper functions necessary for the individual camera models.
818  * - CameraWrapperT implements some additional functions necessary to fully implement all necessary functions for AnyCameraT.
819  * @tparam T The data type of a scalar, 'float' or 'double'
820  * @tparam TCameraWrapperBase The base class implementing all functions necessary for the wrapped camera object.
821  * @ingroup math
822  */
823 template <typename T, typename TCameraWrapperBase>
825 {
826  public:
827 
828  /**
829  * Definition of the actual camera object which is wrapped in this class.
830  */
831  using typename TCameraWrapperBase::ActualCamera;
832 
833  public:
834 
835  /**
836  * Creates a new CameraWrapperT object wrapping the actual camera model.
837  * @param actualCamera The actual camera object to be wrapped
838  */
839  explicit CameraWrapperT(ActualCamera&& actualCamera);
840 
841  /**
842  * Creates a new CameraWrapperT object wrapping the actual camera model.
843  * @param actualCamera The actual camera object to be wrapped
844  */
845  explicit CameraWrapperT(const ActualCamera& actualCamera);
846 
847  /**
848  * Returns the coordinate of the principal point of the camera image in the pixel domain.
849  * @see AnyCameraT::principalPoint().
850  */
851  inline VectorT2<T> principalPoint() const;
852 
853  /**
854  * Returns the field of view in x direction of the camera.
855  * @see AnyCameraT::fovX().
856  */
857  inline T fovX() const;
858 
859  /**
860  * Returns the field of view in x direction of the camera.
861  * @see AnyCameraT::fovY().
862  */
863  inline T fovY() const;
864 
865  /**
866  * Returns whether a given 2D image point lies inside the camera frame.
867  * @see AnyCameraT::isInside().
868  */
869  inline bool isInside(const VectorT2<T>& imagePoint, const T signedBorder = T(0)) const;
870 
871  /**
872  * Projects a 3D object point into the camera frame.
873  * @see projectToImage().
874  */
875  inline VectorT2<T> projectToImage(const VectorT3<T>& objectPoint) const;
876 
877  /**
878  * Projects a 3D object point into the camera frame.
879  * @see projectToImage().
880  */
881  inline VectorT2<T> projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>& objectPoint) const;
882 
883  /**
884  * Projects several 3D object points into the camera frame at once.
885  * @see projectToImage().
886  */
887  inline void projectToImage(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
888 
889  /**
890  * Projects several 3D object points into the camera frame at once.
891  * @see projectToImage().
892  */
893  inline void projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
894 
895  /**
896  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
897  * @see AnyCameraT::vector().
898  */
899  inline VectorT3<T> vector(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const;
900 
901  /**
902  * Determines vectors starting at the camera's center and intersecting given 2D points in the image.
903  * @see AnyCameraT::vector().
904  */
905  inline void vector(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const;
906 
907  /**
908  * Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
909  * @see ray().
910  */
911  inline LineT3<T> ray(const VectorT2<T>& distortedImagePoint, const HomogenousMatrixT4<T>& world_T_camera) const;
912 
913  /**
914  * Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
915  * @see ray().
916  */
917  inline LineT3<T> ray(const VectorT2<T>& distortedImagePoint) const;
918 
919  /**
920  * Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
921  * @see AnyCameraT::pointJacobian2nx3IF().
922  */
923  inline void pointJacobian2nx3IF(const VectorT3<T>* flippedCameraObjectPoints, const size_t numberObjectPoints, T* jacobians) const;
924 };
925 
926 /**
927  * This class implements the base wrapper around Ocean's pinhole camera profile.
928  * The class can be used as 'TCameraWrapperBase' in 'CameraWrapperT' to create a full wrapper class e.g., 'CameraWrapperT<T, CameraWrapperBasePinholeT<T>>'.
929  * @tparam T The data type of a scalar, 'float' or 'double'
930  * @ingroup math
931  */
932 template <typename T>
934 {
935  public:
936 
937  /**
938  * Definition of the actual camera object wrapped by this class.
939  */
941 
942  /**
943  * Definition of the parent WrappedCamera class using this base class.
944  */
946 
947  public:
948 
949  /**
950  * Creates a new CameraWrapperBasePinholeT object wrapping the actual camera model.
951  * @param actualCamera The actual camera object to be wrapped
952  */
954 
955  /**
956  * Creates a new CameraWrapperBasePinholeT object wrapping the actual camera model.
957  * @param actualCamera The actual camera object to be wrapped
958  */
960 
961  /**
962  * Returns the actual camera object wrapped in this class.
963  * @return The wrapped camera object
964  */
965  inline const ActualCamera& actualCamera() const;
966 
967  /**
968  * Returns the width of the camera image.
969  * @see AnyCameraT::width().
970  */
971  inline unsigned int width() const;
972 
973  /**
974  * Returns the height of the camera image.
975  * @see AnyCameraT::height().
976  */
977  inline unsigned int height() const;
978 
979  /**
980  * Returns the x-value of the principal point of the camera image in the pixel domain.
981  * @see AnyCameraT::principalPointX().
982  */
983  inline T principalPointX() const;
984 
985  /**
986  * Returns the y-value of the principal point of the camera image in the pixel domain.
987  * @see AnyCameraT::principalPointY().
988  */
989  inline T principalPointY() const;
990 
991  /**
992  * Returns the horizontal focal length parameter.
993  * @see AnyCameraT::focalLengthX().
994  */
995  inline T focalLengthX() const;
996 
997  /**
998  * Returns the vertical focal length parameter.
999  * @see AnyCameraT::focalLengthY().
1000  */
1001  inline T focalLengthY() const;
1002 
1003  /**
1004  * Returns the inverse horizontal focal length parameter.
1005  * @see AnyCameraT::inverseFocalLengthX().
1006  */
1007  inline T inverseFocalLengthX() const;
1008 
1009  /**
1010  * Returns the inverse vertical focal length parameter.
1011  * @see AnyCameraT::inverseFocalLengthY().
1012  */
1013  inline T inverseFocalLengthY() const;
1014 
1015  /**
1016  * Projects a 3D object point into the camera frame.
1017  * @see AnyCameraT::projectToImageIF().
1018  */
1019  inline VectorT2<T> projectToImageIF(const VectorT3<T>& objectPoint) const;
1020 
1021  /**
1022  * Projects a 3D object point into the camera frame.
1023  * @see AnyCameraT::projectToImageIF().
1024  */
1025  inline VectorT2<T> projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const;
1026 
1027  /**
1028  * Projects several 3D object points into the camera frame at once.
1029  * @see AnyCameraT::projectToImageIF().
1030  */
1031  inline void projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
1032 
1033  /**
1034  * Projects several 3D object points into the camera frame at once.
1035  * @see AnyCameraT::projectToImageIF().
1036  */
1037  inline void projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
1038 
1039  /**
1040  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
1041  * @see AnyCameraT::vectorIF().
1042  */
1043  inline VectorT3<T> vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const;
1044 
1045  /**
1046  * Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
1047  * @see AnyCameraT::vectorIF().
1048  */
1049  inline void vectorIF(const VectorT2<T>* distortedImagePoint, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const;
1050 
1051  /**
1052  * Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
1053  * @see AnyCameraT::pointJacobian2x3IF().
1054  */
1055  inline void pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const;
1056 
1057  /**
1058  * Returns whether two camera objects are identical up to a given epsilon.
1059  * @see AnyCameraT::isEqual().
1060  */
1061  inline bool isEqual(const CameraWrapperBasePinholeT<T>& basePinhole, const T eps = NumericT<T>::eps()) const;
1062 
1063  /**
1064  * Returns whether this camera is valid.
1065  * @see AnyCameraT::isValid().
1066  */
1067  inline bool isValid() const;
1068 
1069  /**
1070  * Returns a copy of the actual camera object.
1071  * @return New instance of the actual camera object used in this wrapper.
1072  * @tparam U The scalar data type of the resulting cloned object, either 'float' or 'double'
1073  */
1074  template <typename U>
1075  inline std::unique_ptr<AnyCameraT<U>> clone(const unsigned int width = 0u, const unsigned int height = 0u) const;
1076 
1077  /**
1078  * Returns the type of this camera.
1079  * @see AnyCameraT::anyCameraType().
1080  */
1081  static inline AnyCameraType anyCameraType();
1082 
1083  /**
1084  * Returns the name of this camera.
1085  * @see AnyCameraT::name().
1086  */
1087  static inline std::string name();
1088 
1089  protected:
1090 
1091  /// The actual pinhole camera.
1093 };
1094 
1095 /**
1096  * This class implements the base wrapper around Ocean's fisheye camera profile.
1097  * The class can be used as 'TCameraWrapperBase' in 'CameraWrapperT' to create a full wrapper class e.g., 'CameraWrapperT<T, CameraWrapperBaseFisheyeT<T>>'.
1098  * @tparam T The data type of a scalar, 'float' or 'double'
1099  * @ingroup math
1100  */
1101 template <typename T>
1103 {
1104  public:
1105 
1106  /**
1107  * Definition of the actual camera object wrapped by this class.
1108  */
1110 
1111  /**
1112  * Definition of the parent WrappedCamera class using this base class.
1113  */
1115 
1116  public:
1117 
1118  /**
1119  * Creates a new CameraWrapperBaseFisheyeT object wrapping the actual camera model.
1120  * @param actualCamera The actual camera object to be wrapped
1121  */
1123 
1124  /**
1125  * Creates a new CameraWrapperBaseFisheyeT object wrapping the actual camera model.
1126  * @param actualCamera The actual camera object to be wrapped
1127  */
1129 
1130  /**
1131  * Returns the actual camera object wrapped in this class.
1132  * @return The wrapped camera object
1133  */
1134  inline const ActualCamera& actualCamera() const;
1135 
1136  /**
1137  * Returns the width of the camera image.
1138  * @see AnyCameraT::width().
1139  */
1140  inline unsigned int width() const;
1141 
1142  /**
1143  * Returns the height of the camera image.
1144  * @see AnyCameraT::height().
1145  */
1146  inline unsigned int height() const;
1147 
1148  /**
1149  * Returns the coordinate of the principal point of the camera image in the pixel domain.
1150  * @see AnyCameraT::principalPoint().
1151  */
1152  inline VectorT2<T> principalPoint() const;
1153 
1154  /**
1155  * Returns the x-value of the principal point of the camera image in the pixel domain.
1156  * @see AnyCameraT::principalPointX().
1157  */
1158  inline T principalPointX() const;
1159 
1160  /**
1161  * Returns the y-value of the principal point of the camera image in the pixel domain.
1162  * @see AnyCameraT::principalPointY().
1163  */
1164  inline T principalPointY() const;
1165 
1166  /**
1167  * Returns the horizontal focal length parameter.
1168  * @see AnyCameraT::focalLengthX().
1169  */
1170  inline T focalLengthX() const;
1171 
1172  /**
1173  * Returns the vertical focal length parameter.
1174  * @see AnyCameraT::focalLengthY().
1175  */
1176  inline T focalLengthY() const;
1177 
1178  /**
1179  * Returns the inverse horizontal focal length parameter.
1180  * @see AnyCameraT::inverseFocalLengthX().
1181  */
1182  inline T inverseFocalLengthX() const;
1183 
1184  /**
1185  * Returns the inverse vertical focal length parameter.
1186  * @see AnyCameraT::inverseFocalLengthY().
1187  */
1188  inline T inverseFocalLengthY() const;
1189 
1190  /**
1191  * Projects a 3D object point into the camera frame.
1192  * @see AnyCameraT::projectToImageIF().
1193  */
1194  inline VectorT2<T> projectToImageIF(const VectorT3<T>& objectPoint) const;
1195 
1196  /**
1197  * Projects a 3D object point into the camera frame.
1198  * @see AnyCameraT::projectToImageIF().
1199  */
1200  inline VectorT2<T> projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const;
1201 
1202  /**
1203  * Projects several 3D object points into the camera frame at once.
1204  * @see AnyCameraT::projectToImageIF().
1205  */
1206  inline void projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
1207 
1208  /**
1209  * Projects several 3D object points into the camera frame at once.
1210  * @see AnyCameraT::projectToImageIF().
1211  */
1212  inline void projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
1213 
1214  /**
1215  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
1216  * @see AnyCameraT::vectorIF().
1217  */
1218  inline VectorT3<T> vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const;
1219 
1220  /**
1221  * Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
1222  * @see AnyCameraT::vectorIF().
1223  */
1224  inline void vectorIF(const VectorT2<T>* distortedImagePoint, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const;
1225 
1226  /**
1227  * Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
1228  * @see AnyCameraT::pointJacobian2x3IF().
1229  */
1230  inline void pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const;
1231 
1232  /**
1233  * Returns whether two camera objects are identical up to a given epsilon.
1234  * @see AnyCameraT::isEqual().
1235  */
1236  inline bool isEqual(const CameraWrapperBaseFisheyeT<T>& baseFisheye, const T eps = NumericT<T>::eps()) const;
1237 
1238  /**
1239  * Returns whether this camera is valid.
1240  * @return True, if so
1241  */
1242  inline bool isValid() const;
1243 
1244  /**
1245  * Returns a copy of the actual camera object.
1246  * @return New instance of the actual camera object used in this wrapper.
1247  */
1248  template <typename U>
1249  inline std::unique_ptr<AnyCameraT<U>> clone(const unsigned int width = 0u, const unsigned int height = 0u) const;
1250 
1251  /**
1252  * Returns the type of this camera.
1253  * @see AnyCamera::anyCameraType().
1254  */
1255  static inline AnyCameraType anyCameraType();
1256 
1257  /**
1258  * Returns the name of this camera.
1259  * @see AnyCamera::name().
1260  */
1261  static inline std::string name();
1262 
1263  protected:
1264 
1265  /// The actual fisheye camera object.
1267 };
1268 
1269 /**
1270  * This class implements invalid camera profiles, e.g. when no intrinsic information is available.
1271  * @tparam T The data type of a 'Scalar', 'float' or 'double'
1272  * @ingroup math
1273  */
1274 template <typename T>
1276 {
1277  public:
1278 
1279  /**
1280  * Creates an invalid camera
1281  * @param reason The reason why no valid camera is available, must be valid
1282  */
1283  explicit InvalidCameraT(const std::string& reason);
1284 
1285  /**
1286  * Returns the reason of this invalid camera
1287  * @return The reason
1288  */
1289  const std::string& reason() const;
1290 
1291  protected:
1292 
1293  /// The reason why no valid camera is available.
1294  std::string reason_;
1295 };
1296 
1297 /**
1298  * Definition of an invalid camera object based with element precision 'Scalar'.
1299  * @see AnyCameraT, AnyCameraInvalidT.
1300  * @ingroup math
1301  */
1303 
1304 /**
1305  * Definition of an invalid camera object based with element precision 'double'.
1306  * @see AnyCameraT, AnyCameraInvalidT.
1307  * @ingroup math
1308  */
1310 
1311 /**
1312  * Definition of an invalid camera object based with element precision 'float'.
1313  * @see AnyCameraT, AnyCameraInvalidT.
1314  * @ingroup math
1315  */
1317 
1318 /**
1319  * This class implements the base wrapper around an invalid camera profile.
1320  * The class can be used as 'TCameraWrapperBase' in 'CameraWrapperT' to create a full wrapper class e.g., 'CameraWrapperT<T, CameraWrapperBaseInvalidT<T>>'.
1321  * @tparam T The data type of a scalar, 'float' or 'double'
1322  * @ingroup math
1323  */
1324 template <typename T>
1326 {
1327  public:
1328 
1329  /**
1330  * Definition of the actual camera object wrapped by this class.
1331  */
1333 
1334  /**
1335  * Definition of the parent WrappedCamera class using this base class.
1336  */
1338 
1339  public:
1340 
1341  /**
1342  * Creates a new CameraWrapperBaseInvalidT object wrapping the actual camera model.
1343  * @param actualCamera The actual camera object to be wrapped
1344  */
1346 
1347  /**
1348  * Creates a new CameraWrapperBaseInvalidT object wrapping the actual camera model.
1349  * @param actualCamera The actual camera object to be wrapped
1350  */
1352 
1353  /**
1354  * Returns the actual camera object wrapped in this class.
1355  * @return The wrapped camera object
1356  */
1357  inline const ActualCamera& actualCamera() const;
1358 
1359  /**
1360  * Returns the width of the camera image.
1361  * @see AnyCameraT::width().
1362  */
1363  inline unsigned int width() const;
1364 
1365  /**
1366  * Returns the height of the camera image.
1367  * @see AnyCameraT::height().
1368  */
1369  inline unsigned int height() const;
1370 
1371  /**
1372  * Returns the coordinate of the principal point of the camera image in the pixel domain.
1373  * @see AnyCameraT::principalPoint().
1374  */
1375  inline VectorT2<T> principalPoint() const;
1376 
1377  /**
1378  * Returns the x-value of the principal point of the camera image in the pixel domain.
1379  * @see AnyCameraT::principalPointX().
1380  */
1381  inline T principalPointX() const;
1382 
1383  /**
1384  * Returns the y-value of the principal point of the camera image in the pixel domain.
1385  * @see AnyCameraT::principalPointY().
1386  */
1387  inline T principalPointY() const;
1388 
1389  /**
1390  * Returns the horizontal focal length parameter.
1391  * @see AnyCameraT::focalLengthX().
1392  */
1393  inline T focalLengthX() const;
1394 
1395  /**
1396  * Returns the vertical focal length parameter.
1397  * @see AnyCameraT::focalLengthY().
1398  */
1399  inline T focalLengthY() const;
1400 
1401  /**
1402  * Returns the inverse horizontal focal length parameter.
1403  * @see AnyCameraT::inverseFocalLengthX().
1404  */
1405  inline T inverseFocalLengthX() const;
1406 
1407  /**
1408  * Returns the inverse vertical focal length parameter.
1409  * @see AnyCameraT::inverseFocalLengthY().
1410  */
1411  inline T inverseFocalLengthY() const;
1412 
1413  /**
1414  * Projects a 3D object point into the camera frame.
1415  * @see AnyCameraT::projectToImageIF().
1416  */
1417  inline VectorT2<T> projectToImageIF(const VectorT3<T>& objectPoint) const;
1418 
1419  /**
1420  * Projects a 3D object point into the camera frame.
1421  * @see AnyCameraT::projectToImageIF().
1422  */
1423  inline VectorT2<T> projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const;
1424 
1425  /**
1426  * Projects several 3D object points into the camera frame at once.
1427  * @see AnyCameraT::projectToImageIF().
1428  */
1429  inline void projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
1430 
1431  /**
1432  * Projects several 3D object points into the camera frame at once.
1433  * @see AnyCameraT::projectToImageIF().
1434  */
1435  inline void projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const;
1436 
1437  /**
1438  * Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
1439  * @see AnyCameraT::vectorIF().
1440  */
1441  inline VectorT3<T> vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const;
1442 
1443  /**
1444  * Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
1445  * @see AnyCameraT::vectorIF().
1446  */
1447  inline void vectorIF(const VectorT2<T>* distortedImagePoint, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const;
1448 
1449  /**
1450  * Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
1451  * @see AnyCameraT::pointJacobian2x3IF().
1452  */
1453  inline void pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const;
1454 
1455  /**
1456  * Returns whether two camera objects are identical up to a given epsilon.
1457  * @see AnyCameraT::isEqual().
1458  */
1459  inline bool isEqual(const CameraWrapperBaseInvalidT<T>& baseInvalid, const T eps = NumericT<T>::eps()) const;
1460 
1461  /**
1462  * Returns whether this camera is valid.
1463  * @return True, if so
1464  */
1465  inline bool isValid() const;
1466 
1467  /**
1468  * Returns a copy of the actual camera object.
1469  * @return New instance of the actual camera object used in this wrapper.
1470  */
1471  template <typename U>
1472  inline std::unique_ptr<AnyCameraT<U>> clone(const unsigned int width = 0u, const unsigned int height = 0u) const;
1473 
1474  /**
1475  * Returns the type of this camera.
1476  * @see AnyCamera::anyCameraType().
1477  */
1478  static inline AnyCameraType anyCameraType();
1479 
1480  /**
1481  * Returns the name of this camera.
1482  * @see AnyCamera::name().
1483  */
1484  static inline std::string name();
1485 
1486  protected:
1487 
1488  /// The actual invalid camera.
1490 };
1491 
1492 /**
1493  * Definition of an AnyCamera object based on Ocean's pinhole camera class with template parameter to define the element precision.
1494  * @tparam T The scalar data type
1495  * @see AnyCameraT, CameraWrapperBasePinholeT, AnyCameraPinhole, AnyCameraPinholeD, AnyCameraPinholeF.
1496  * @ingroup math
1497  */
1498 template <typename T>
1500 
1501 /**
1502  * Definition of an AnyCamera object based on Ocean's pinhole camera class with element precision 'Scalar'.
1503  * @see AnyCameraT, AnyCameraPinholeT.
1504  * @ingroup math
1505  */
1507 
1508 /**
1509  * Definition of an AnyCamera object based on Ocean's pinhole camera class with element precision 'double'.
1510  * @see AnyCameraT, AnyCameraPinholeT.
1511  * @ingroup math
1512  */
1514 
1515 /**
1516  * Definition of an AnyCamera object based on Ocean's pinhole camera class with element precision 'float'.
1517  * @see AnyCameraT, AnyCameraPinholeT.
1518  * @ingroup math
1519  */
1521 
1522 /**
1523  * Definition of an AnyCamera object based on Ocean's fisheye camera class with template parameter to define the element precision.
1524  * @tparam T The scalar data type
1525  * @see AnyCameraT, CameraWrapperBaseFisheyeT, AnyCameraFisheye, AnyCameraFisheyeD, AnyCameraFisheyeF.
1526  * @ingroup math
1527  */
1528 template <typename T>
1530 
1531 /**
1532  * Definition of an AnyCamera object based on Ocean's fisheye camera class with element precision 'Scalar'.
1533  * @see AnyCameraT, AnyCameraFisheyeT.
1534  * @ingroup math
1535  */
1537 
1538 /**
1539  * Definition of an AnyCamera object based on Ocean's fisheye camera class with element precision 'double'.
1540  * @see AnyCameraT, AnyCameraFisheyeT.
1541  * @ingroup math
1542  */
1544 
1545 /**
1546  * Definition of an AnyCamera object based on Ocean's fisheye camera class with element precision 'float'.
1547  * @see AnyCameraT, AnyCameraFisheyeT.
1548  * @ingroup math
1549  */
1551 
1552 /**
1553  * Definition of an AnyCamera object based on an invalid (by design) camera with template parameter to define the element precision.
1554  * @tparam T The scalar data type
1555  * @see AnyCameraT, CameraWrapperBaseFisheyeT, AnyCameraInvalid, AnyCameraInvalidD, AnyCameraInvalidF.
1556  * @ingroup math
1557  */
1558 template <typename T>
1560 
1561 /**
1562  * Definition of an AnyCamera object based on an invalid (by design) camera with element precision 'Scalar'.
1563  * @see AnyCameraT, AnyCameraInvalidT.
1564  * @ingroup math
1565  */
1567 
1568 /**
1569  * Definition of an AnyCamera object based on an invalid (by design) camera with element precision 'double'.
1570  * @see AnyCameraT, AnyCameraInvalidT.
1571  * @ingroup math
1572  */
1574 
1575 /**
1576  * Definition of an AnyCamera object based on an invalid (by design) camera with element precision 'float'.
1577  * @see AnyCameraT, AnyCameraInvalidT.
1578  * @ingroup math
1579  */
1581 
1582 template <>
1583 template <>
1584 inline std::shared_ptr<AnyCameraT<float>> AnyCameraT<float>::convert(const std::shared_ptr<AnyCameraT<double>>& anyCamera)
1585 {
1586  if (anyCamera)
1587  {
1588  return anyCamera->cloneToFloat();
1589  }
1590 
1591  return nullptr;
1592 }
1593 
1594 template <>
1595 template <>
1596 inline std::shared_ptr<AnyCameraT<double>> AnyCameraT<double>::convert(const std::shared_ptr<AnyCameraT<float>>& anyCamera)
1597 {
1598  if (anyCamera)
1599  {
1600  return anyCamera->cloneToDouble();
1601  }
1602 
1603  return nullptr;
1604 }
1605 
1606 template <typename T>
1607 template <typename U>
1608 std::shared_ptr<AnyCameraT<T>> AnyCameraT<T>::convert(const std::shared_ptr<AnyCameraT<U>>& anyCamera)
1609 {
1610  static_assert(std::is_same<T, U>::value, "Invalid data types!");
1611 
1612  return anyCamera;
1613 }
1614 
1615 template <typename T, typename TCameraWrapper>
1617  TCameraWrapper(std::move(actualCamera))
1618 {
1619  // nothing to do here
1620 }
1621 
1622 template <typename T, typename TCameraWrapper>
1624  TCameraWrapper(actualCamera)
1625 {
1626  // nothing to do here
1627 }
1628 
1629 template <typename T, typename TCameraWrapper>
1631 {
1632  return TCameraWrapper::anyCameraType();
1633 }
1634 
1635 template <typename T, typename TCameraWrapper>
1637 {
1638  return TCameraWrapper::name();
1639 }
1640 
1641 template <typename T, typename TCameraWrapper>
1642 std::unique_ptr<AnyCameraT<T>> AnyCameraWrappingT<T, TCameraWrapper>::clone(const unsigned int width, const unsigned int height) const
1643 {
1644  return TCameraWrapper::template clone<T>(width, height);
1645 }
1646 
1647 template <typename T, typename TCameraWrapper>
1648 std::unique_ptr<AnyCameraT<float>> AnyCameraWrappingT<T, TCameraWrapper>::cloneToFloat(const unsigned int width, const unsigned int height) const
1649 {
1650  return TCameraWrapper::template clone<float>(width, height);
1651 }
1652 
1653 template <typename T, typename TCameraWrapper>
1654 std::unique_ptr<AnyCameraT<double>> AnyCameraWrappingT<T, TCameraWrapper>::cloneToDouble(const unsigned int width, const unsigned int height) const
1655 {
1656  return TCameraWrapper::template clone<double>(width, height);
1657 }
1658 
1659 template <typename T, typename TCameraWrapper>
1661 {
1662  return TCameraWrapper::width();
1663 }
1664 
1665 template <typename T, typename TCameraWrapper>
1667 {
1668  return TCameraWrapper::height();
1669 }
1670 
1671 template <typename T, typename TCameraWrapper>
1673 {
1674  return TCameraWrapper::principalPoint();
1675 }
1676 
1677 template <typename T, typename TCameraWrapper>
1679 {
1680  return TCameraWrapper::principalPointX();
1681 }
1682 
1683 template <typename T, typename TCameraWrapper>
1685 {
1686  return TCameraWrapper::principalPointY();
1687 }
1688 
1689 template <typename T, typename TCameraWrapper>
1691 {
1692  return TCameraWrapper::focalLengthX();
1693 }
1694 
1695 template <typename T, typename TCameraWrapper>
1697 {
1698  return TCameraWrapper::focalLengthY();
1699 }
1700 
1701 template <typename T, typename TCameraWrapper>
1703 {
1704  return TCameraWrapper::inverseFocalLengthX();
1705 }
1706 
1707 template <typename T, typename TCameraWrapper>
1709 {
1710  return TCameraWrapper::inverseFocalLengthY();
1711 }
1712 
1713 template <typename T, typename TCameraWrapper>
1715 {
1716  return TCameraWrapper::fovX();
1717 }
1718 
1719 template <typename T, typename TCameraWrapper>
1721 {
1722  return TCameraWrapper::fovY();
1723 }
1724 
1725 template <typename T, typename TCameraWrapper>
1726 bool AnyCameraWrappingT<T, TCameraWrapper>::isInside(const VectorT2<T>& imagePoint, const T signedBorder) const
1727 {
1728  return TCameraWrapper::isInside(imagePoint, signedBorder);
1729 }
1730 
1731 template <typename T, typename TCameraWrapper>
1733 {
1734  return TCameraWrapper::projectToImage(objectPoint);
1735 }
1736 
1737 template <typename T, typename TCameraWrapper>
1739 {
1740  return TCameraWrapper::projectToImage(world_T_camera, objectPoint);
1741 }
1742 
1743 template <typename T, typename TCameraWrapper>
1745 {
1746  return TCameraWrapper::projectToImageIF(objectPoint);
1747 }
1748 
1749 template <typename T, typename TCameraWrapper>
1751 {
1752  return TCameraWrapper::projectToImageIF(flippedCamera_T_world, objectPoint);
1753 }
1754 
1755 template <typename T, typename TCameraWrapper>
1756 void AnyCameraWrappingT<T, TCameraWrapper>::projectToImage(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
1757 {
1758  return TCameraWrapper::projectToImage(objectPoints, size, imagePoints);
1759 }
1760 
1761 template <typename T, typename TCameraWrapper>
1762 void AnyCameraWrappingT<T, TCameraWrapper>::projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
1763 {
1764  return TCameraWrapper::projectToImage(world_T_camera, objectPoints, size, imagePoints);
1765 }
1766 
1767 template <typename T, typename TCameraWrapper>
1768 void AnyCameraWrappingT<T, TCameraWrapper>::projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
1769 {
1770  return TCameraWrapper::projectToImageIF(objectPoints, size, imagePoints);
1771 }
1772 
1773 template <typename T, typename TCameraWrapper>
1774 void AnyCameraWrappingT<T, TCameraWrapper>::projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
1775 {
1776  return TCameraWrapper::projectToImageIF(flippedCamera_T_world, objectPoints, size, imagePoints);
1777 }
1778 
1779 template <typename T, typename TCameraWrapper>
1780 VectorT3<T> AnyCameraWrappingT<T, TCameraWrapper>::vector(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const
1781 {
1782  return TCameraWrapper::vector(distortedImagePoint, makeUnitVector);
1783 }
1784 
1785 template <typename T, typename TCameraWrapper>
1786 void AnyCameraWrappingT<T, TCameraWrapper>::vector(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const
1787 {
1788  return TCameraWrapper::vector(distortedImagePoints, size, vectors, makeUnitVector);
1789 }
1790 
1791 template <typename T, typename TCameraWrapper>
1792 VectorT3<T> AnyCameraWrappingT<T, TCameraWrapper>::vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const
1793 {
1794  return TCameraWrapper::vectorIF(distortedImagePoint, makeUnitVector);
1795 }
1796 
1797 template <typename T, typename TCameraWrapper>
1798 void AnyCameraWrappingT<T, TCameraWrapper>::vectorIF(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const
1799 {
1800  return TCameraWrapper::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
1801 }
1802 
1803 template <typename T, typename TCameraWrapper>
1804 LineT3<T> AnyCameraWrappingT<T, TCameraWrapper>::ray(const VectorT2<T>& distortedImagePoint, const HomogenousMatrixT4<T>& world_T_camera) const
1805 {
1806  return TCameraWrapper::ray(distortedImagePoint, world_T_camera);
1807 }
1808 
1809 template <typename T, typename TCameraWrapper>
1811 {
1812  return TCameraWrapper::ray(distortedImagePoint);
1813 }
1814 
1815 template <typename T, typename TCameraWrapper>
1816 void AnyCameraWrappingT<T, TCameraWrapper>::pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const
1817 {
1818  return TCameraWrapper::pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
1819 }
1820 
1821 template <typename T, typename TCameraWrapper>
1822 void AnyCameraWrappingT<T, TCameraWrapper>::pointJacobian2nx3IF(const VectorT3<T>* flippedCameraObjectPoints, const size_t numberObjectPoints, T* jacobians) const
1823 {
1824  return TCameraWrapper::pointJacobian2nx3IF(flippedCameraObjectPoints, numberObjectPoints, jacobians);
1825 }
1826 
1827 template <typename T, typename TCameraWrapper>
1828 bool AnyCameraWrappingT<T, TCameraWrapper>::isEqual(const AnyCameraT<T>& anyCamera, const T eps) const
1829 {
1830  ocean_assert(eps >= T(0));
1831 
1832  if (isValid() != anyCamera.isValid())
1833  {
1834  // one camera is value, one is not valid
1835  return false;
1836  }
1837 
1838  if (!isValid())
1839  {
1840  // both cameras are invalid
1841  return true;
1842  }
1843 
1844  if (name() != anyCamera.name())
1845  {
1846  return false;
1847  }
1848 
1849  return TCameraWrapper::isEqual((const AnyCameraWrappingT<T, TCameraWrapper>&)(anyCamera), eps);
1850 }
1851 
1852 template <typename T, typename TCameraWrapper>
1854 {
1855  return TCameraWrapper::isValid();
1856 }
1857 
1858 template <typename T, typename TCameraWrapperBase>
1860  TCameraWrapperBase(std::move(actualCamera))
1861 {
1862  // nothing to do here
1863 }
1864 
1865 template <typename T, typename TCameraWrapperBase>
1867  TCameraWrapperBase(actualCamera)
1868 {
1869  // nothing to do here
1870 }
1871 
1872 template <typename T, typename TCameraWrapperBase>
1874 {
1875  return VectorT2<T>(TCameraWrapperBase::principalPointX(), TCameraWrapperBase::principalPointY());
1876 }
1877 
1878 template <typename T, typename TCameraWrapperBase>
1880 {
1881  ocean_assert(TCameraWrapperBase::isValid());
1882 
1883  /**
1884  * x = Fx * X / Z + mx
1885  *
1886  * (x - mx) / Fx = X / Z
1887  */
1888 
1889  if (NumericT<T>::isEqualEps(TCameraWrapperBase::focalLengthX()))
1890  {
1891  return T(0);
1892  }
1893 
1894  const T leftAngle = NumericT<T>::abs(NumericT<T>::atan(-TCameraWrapperBase::principalPointX() * TCameraWrapperBase::inverseFocalLengthX()));
1895 
1896  if (T(TCameraWrapperBase::width()) <= TCameraWrapperBase::principalPointX())
1897  {
1898  ocean_assert(false && "Invalid principal point");
1899  return T(2) * leftAngle;
1900  }
1901 
1902  const T rightAngle = NumericT<T>::atan((T(TCameraWrapperBase::width()) - TCameraWrapperBase::principalPointX()) * TCameraWrapperBase::inverseFocalLengthX());
1903 
1904  return leftAngle + rightAngle;
1905 }
1906 
1907 template <typename T, typename TCameraWrapperBase>
1909 {
1910  ocean_assert(TCameraWrapperBase::isValid());
1911 
1912  /**
1913  * y = Fy * Y / Z + my
1914  *
1915  * (y - my) / Fy = Y / Z
1916  */
1917 
1918  if (NumericT<T>::isEqualEps(TCameraWrapperBase::focalLengthY()))
1919  {
1920  return T(0);
1921  }
1922 
1923  const T topAngle = NumericT<T>::abs(NumericT<T>::atan(-TCameraWrapperBase::principalPointY() * TCameraWrapperBase::inverseFocalLengthY()));
1924 
1925  if (T(TCameraWrapperBase::height()) <= TCameraWrapperBase::principalPointY())
1926  {
1927  ocean_assert(false && "Invalid principal point");
1928  return T(2) * topAngle;
1929  }
1930 
1931  const T bottomAngle = NumericT<T>::atan((T(TCameraWrapperBase::height()) - TCameraWrapperBase::principalPointY()) * TCameraWrapperBase::inverseFocalLengthY());
1932 
1933  return topAngle + bottomAngle;
1934 }
1935 
1936 template <typename T, typename TCameraWrapperBase>
1937 inline bool CameraWrapperT<T, TCameraWrapperBase>::isInside(const VectorT2<T>& imagePoint, const T signedBorder) const
1938 {
1939  ocean_assert(TCameraWrapperBase::isValid());
1940 
1941  const unsigned int cameraWidth = TCameraWrapperBase::width();
1942  const unsigned int cameraHeight = TCameraWrapperBase::height();
1943 
1944  ocean_assert(signedBorder < T(std::min(cameraWidth / 2u, cameraHeight / 2u)));
1945 
1946  return imagePoint.x() >= signedBorder && imagePoint.y() >= signedBorder
1947  && imagePoint.x() < T(cameraWidth) - signedBorder && imagePoint.y() < T(cameraHeight) - signedBorder;
1948 }
1949 
1950 template <typename T, typename TCameraWrapperBase>
1952 {
1953  return TCameraWrapperBase::projectToImageIF(VectorT3<T>(objectPoint.x(), -objectPoint.y(), -objectPoint.z()));
1954 }
1955 
1956 template <typename T, typename TCameraWrapperBase>
1958 {
1959  return TCameraWrapperBase::projectToImageIF(CameraT<T>::standard2InvertedFlipped(world_T_camera), objectPoint);
1960 }
1961 
1962 template <typename T, typename TCameraWrapperBase>
1963 inline void CameraWrapperT<T, TCameraWrapperBase>::projectToImage(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
1964 {
1965  ocean_assert(size == 0 || objectPoints != nullptr);
1966  ocean_assert(size == 0 || imagePoints != nullptr);
1967 
1968  for (size_t n = 0; n < size; ++n)
1969  {
1970  const VectorT3<T>& objectPoint = objectPoints[n];
1971  imagePoints[n] = TCameraWrapperBase::projectToImageIF(VectorT3<T>(objectPoint.x(), -objectPoint.y(), -objectPoint.z()));
1972  }
1973 }
1974 
1975 template <typename T, typename TCameraWrapperBase>
1976 inline void CameraWrapperT<T, TCameraWrapperBase>::projectToImage(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
1977 {
1978  return TCameraWrapperBase::projectToImageIF(CameraT<T>::standard2InvertedFlipped(world_T_camera), objectPoints, size, imagePoints);
1979 }
1980 
1981 template <typename T, typename TCameraWrapperBase>
1982 inline VectorT3<T> CameraWrapperT<T, TCameraWrapperBase>::vector(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const
1983 {
1984  const VectorT3<T> localVectorIF(TCameraWrapperBase::vectorIF(distortedImagePoint, makeUnitVector));
1985 
1986  return VectorT3<T>(localVectorIF.x(), -localVectorIF.y(), -localVectorIF.z());
1987 }
1988 
1989 template <typename T, typename TCameraWrapperBase>
1990 inline void CameraWrapperT<T, TCameraWrapperBase>::vector(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const
1991 {
1992  TCameraWrapperBase::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
1993 
1994  for (size_t n = 0; n < size; ++n)
1995  {
1996  const VectorT3<T>& localVectorIF = vectors[n];
1997 
1998  vectors[n] = VectorT3<T>(localVectorIF.x(), -localVectorIF.y(), -localVectorIF.z());
1999  }
2000 }
2001 
2002 template <typename T, typename TCameraWrapperBase>
2003 inline LineT3<T> CameraWrapperT<T, TCameraWrapperBase>::ray(const VectorT2<T>& distortedImagePoint, const HomogenousMatrixT4<T>& world_T_camera) const
2004 {
2005  ocean_assert(TCameraWrapperBase::isValid() && world_T_camera.isValid());
2006 
2007  return LineT3<T>(world_T_camera.translation(), world_T_camera.rotationMatrix(vector(distortedImagePoint, true /*makeUnitVector*/)));
2008 }
2009 
2010 template <typename T, typename TCameraWrapperBase>
2011 inline LineT3<T> CameraWrapperT<T, TCameraWrapperBase>::ray(const VectorT2<T>& distortedImagePoint) const
2012 {
2013  ocean_assert(TCameraWrapperBase::isValid());
2014 
2015  return LineT3<T>(VectorT3<T>(0, 0, 0), vector(distortedImagePoint, true /*makeUnitVector*/));
2016 }
2017 
2018 template <typename T, typename TCameraWrapperBase>
2019 inline void CameraWrapperT<T, TCameraWrapperBase>::pointJacobian2nx3IF(const VectorT3<T>* flippedCameraObjectPoints, const size_t numberObjectPoints, T* jacobians) const
2020 {
2021  ocean_assert(flippedCameraObjectPoints != nullptr);
2022  ocean_assert(numberObjectPoints >= 1);
2023  ocean_assert(jacobians != nullptr);
2024 
2025  for (size_t n = 0; n < numberObjectPoints; ++n)
2026  {
2027  TCameraWrapperBase::pointJacobian2x3IF(flippedCameraObjectPoints[n], jacobians + 0, jacobians + 3);
2028  jacobians += 6;
2029  }
2030 }
2031 
2032 template <typename T>
2034  actualCamera_(std::move(actualCamera))
2035 {
2036  // nothing to do here
2037 }
2038 
2039 template <typename T>
2041  actualCamera_(actualCamera)
2042 {
2043  // nothing to do here
2044 }
2045 
2046 template <typename T>
2048 {
2049  return actualCamera_;
2050 }
2051 
2052 template <typename T>
2053 inline unsigned int CameraWrapperBasePinholeT<T>::width() const
2054 {
2055  return actualCamera_.width();
2056 }
2057 
2058 template <typename T>
2059 inline unsigned int CameraWrapperBasePinholeT<T>::height() const
2060 {
2061  return actualCamera_.height();
2062 }
2063 
2064 template <typename T>
2066 {
2067  return T(actualCamera_.principalPointX());
2068 }
2069 
2070 template <typename T>
2072 {
2073  return T(actualCamera_.principalPointY());
2074 }
2075 
2076 template <typename T>
2078 {
2079  return T(actualCamera_.focalLengthX());
2080 }
2081 
2082 template <typename T>
2084 {
2085  return T(actualCamera_.focalLengthY());
2086 }
2087 
2088 template <typename T>
2090 {
2091  return T(actualCamera_.inverseFocalLengthX());
2092 }
2093 
2094 template <typename T>
2096 {
2097  return T(actualCamera_.inverseFocalLengthY());
2098 }
2099 
2100 template <typename T>
2102 {
2103  return VectorT2<T>(actualCamera_.template projectToImageIF<true>(HomogenousMatrixT4<T>(true), objectPoint, true));
2104 }
2105 
2106 template <typename T>
2107 inline VectorT2<T> CameraWrapperBasePinholeT<T>::projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const
2108 {
2109  return VectorT2<T>(actualCamera_.template projectToImageIF<true>(flippedCamera_T_world, objectPoint, true));
2110 }
2111 
2112 template <typename T>
2113 inline void CameraWrapperBasePinholeT<T>::projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
2114 {
2115  ocean_assert(size == 0 || objectPoints != nullptr);
2116  ocean_assert(size == 0 || imagePoints != nullptr);
2117 
2118  for (size_t n = 0; n < size; ++n)
2119  {
2120  imagePoints[n] = projectToImageIF(objectPoints[n]);
2121  }
2122 }
2123 
2124 template <typename T>
2125 inline void CameraWrapperBasePinholeT<T>::projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
2126 {
2127  ocean_assert(size == 0 || objectPoints != nullptr);
2128  ocean_assert(size == 0 || imagePoints != nullptr);
2129 
2130  for (size_t n = 0; n < size; ++n)
2131  {
2132  imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2133  }
2134 }
2135 
2136 template <typename T>
2137 inline VectorT3<T> CameraWrapperBasePinholeT<T>::vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const
2138 {
2139  const VectorT2<T> undistortedImagePoint(actualCamera_.template undistort<true>(distortedImagePoint));
2140 
2141  return VectorT3<T>(actualCamera_.vectorIF(undistortedImagePoint, makeUnitVector));
2142 }
2143 
2144 template <typename T>
2145 inline void CameraWrapperBasePinholeT<T>::vectorIF(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const
2146 {
2147  ocean_assert(distortedImagePoints != nullptr && size > 0);
2148  ocean_assert(vectors != nullptr);
2149 
2150  for (size_t n = 0; n < size; ++n)
2151  {
2152  vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2153  }
2154 }
2155 
2156 template <typename T>
2157 inline void CameraWrapperBasePinholeT<T>::pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const
2158 {
2159  ocean_assert(jx != nullptr && jy != nullptr);
2160  actualCamera_.template pointJacobian2x3IF<T, true>(flippedCameraObjectPoint, jx, jy);
2161 }
2162 
2163 template <typename T>
2164 inline bool CameraWrapperBasePinholeT<T>::isEqual(const CameraWrapperBasePinholeT<T>& basePinhole, const T eps) const
2165 {
2166  ocean_assert(eps >= T(0));
2167 
2168  return actualCamera_.isEqual(basePinhole.actualCamera_, eps);
2169 }
2170 
2171 template <typename T>
2173 {
2174  return actualCamera_.isValid();
2175 }
2176 
2177 template <typename T>
2178 template <typename U>
2179 inline std::unique_ptr<AnyCameraT<U>> CameraWrapperBasePinholeT<T>::clone(const unsigned int width, const unsigned int height) const
2180 {
2181  ocean_assert(actualCamera_.isValid());
2182 
2183  if constexpr (std::is_same<T, U>::value)
2184  {
2185  if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2186  {
2187  return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(actualCamera_);
2188  }
2189 
2190  const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2191  const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2192 
2193  if (!NumericT<unsigned int>::isEqual(width, validWidth, 1u) && !NumericT<unsigned int>::isEqual(height, validHeight, 1u)) // either of the valid width/height needs to be close by 1 pixel
2194  {
2195  ocean_assert(false && "Wrong aspect ratio!");
2196  return nullptr;
2197  }
2198 
2199  return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(PinholeCameraT<U>(width, height, actualCamera_));
2200  }
2201  else
2202  {
2203  const PinholeCameraT<U> convertedPinholeCamera(actualCamera_);
2204 
2205  if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2206  {
2207  return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(convertedPinholeCamera);
2208  }
2209 
2210  const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2211  const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2212 
2213  if (!NumericT<unsigned int>::isEqual(width, validWidth, 1u) && !NumericT<unsigned int>::isEqual(height, validHeight, 1u)) // either of the valid width/height needs to be close by 1 pixel
2214  {
2215  ocean_assert(false && "Wrong aspect ratio!");
2216  return nullptr;
2217  }
2218 
2219  return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(PinholeCameraT<U>(width, height, convertedPinholeCamera));
2220  }
2221 }
2222 
2223 template <typename T>
2225 {
2226  return AnyCameraType::PINHOLE;
2227 }
2228 
2229 template <typename T>
2231 {
2232  return std::string("Ocean Pinhole");
2233 }
2234 
2235 template <typename T>
2237  actualCamera_(std::move(camera))
2238 {
2239  // nothing to do here
2240 }
2241 
2242 template <typename T>
2244  actualCamera_(camera)
2245 {
2246  // nothing to do here
2247 }
2248 
2249 template <typename T>
2251 {
2252  return actualCamera_;
2253 }
2254 
2255 template <typename T>
2256 inline unsigned int CameraWrapperBaseFisheyeT<T>::width() const
2257 {
2258  return actualCamera_.width();
2259 }
2260 
2261 template <typename T>
2262 inline unsigned int CameraWrapperBaseFisheyeT<T>::height() const
2263 {
2264  return actualCamera_.height();
2265 }
2266 
2267 template <typename T>
2269 {
2270  return actualCamera_.principalPoint();
2271 }
2272 
2273 template <typename T>
2275 {
2276  return actualCamera_.principalPointX();
2277 }
2278 
2279 template <typename T>
2281 {
2282  return actualCamera_.principalPointY();
2283 }
2284 
2285 template <typename T>
2287 {
2288  return actualCamera_.focalLengthX();
2289 }
2290 
2291 template <typename T>
2293 {
2294  return actualCamera_.focalLengthY();
2295 }
2296 
2297 template <typename T>
2299 {
2300  return actualCamera_.inverseFocalLengthX();
2301 }
2302 
2303 template <typename T>
2305 {
2306  return actualCamera_.inverseFocalLengthY();
2307 }
2308 
2309 template <typename T>
2311 {
2312  return actualCamera_.projectToImageIF(objectPoint);
2313 }
2314 
2315 template <typename T>
2316 inline VectorT2<T> CameraWrapperBaseFisheyeT<T>::projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>& objectPoint) const
2317 {
2318  return actualCamera_.projectToImageIF(flippedCamera_T_world, objectPoint);
2319 }
2320 
2321 template <typename T>
2322 inline void CameraWrapperBaseFisheyeT<T>::projectToImageIF(const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
2323 {
2324  ocean_assert(size == 0 || objectPoints != nullptr);
2325  ocean_assert(size == 0 || imagePoints != nullptr);
2326 
2327  for (size_t n = 0; n < size; ++n)
2328  {
2329  imagePoints[n] = projectToImageIF(objectPoints[n]);
2330  }
2331 }
2332 
2333 template <typename T>
2334 inline void CameraWrapperBaseFisheyeT<T>::projectToImageIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const VectorT3<T>* objectPoints, const size_t size, VectorT2<T>* imagePoints) const
2335 {
2336  ocean_assert(size == 0 || objectPoints != nullptr);
2337  ocean_assert(size == 0 || imagePoints != nullptr);
2338 
2339  for (size_t n = 0; n < size; ++n)
2340  {
2341  imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2342  }
2343 }
2344 
2345 template <typename T>
2346 inline VectorT3<T> CameraWrapperBaseFisheyeT<T>::vectorIF(const VectorT2<T>& distortedImagePoint, const bool makeUnitVector) const
2347 {
2348  return actualCamera_.vectorIF(distortedImagePoint, makeUnitVector);
2349 }
2350 
2351 template <typename T>
2352 inline void CameraWrapperBaseFisheyeT<T>::vectorIF(const VectorT2<T>* distortedImagePoints, const size_t size, VectorT3<T>* vectors, const bool makeUnitVector) const
2353 {
2354  ocean_assert(distortedImagePoints != nullptr && size > 0);
2355  ocean_assert(vectors != nullptr);
2356 
2357  for (size_t n = 0; n < size; ++n)
2358  {
2359  vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2360  }
2361 }
2362 
2363 template <typename T>
2364 inline void CameraWrapperBaseFisheyeT<T>::pointJacobian2x3IF(const VectorT3<T>& flippedCameraObjectPoint, T* jx, T* jy) const
2365 {
2366  actualCamera_.pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
2367 }
2368 
2369 template <typename T>
2370 inline bool CameraWrapperBaseFisheyeT<T>::isEqual(const CameraWrapperBaseFisheyeT& baseFisheye, const T eps) const
2371 {
2372  ocean_assert(eps >= T(0));
2373 
2374  return actualCamera_.isEqual(baseFisheye.actualCamera_, eps);
2375 }
2376 
2377 template <typename T>
2379 {
2380  return actualCamera_.isValid();
2381 }
2382 
2383 template <typename T>
2384 template <typename U>
2385 inline std::unique_ptr<AnyCameraT<U>> CameraWrapperBaseFisheyeT<T>::clone(const unsigned int width, const unsigned int height) const
2386 {
2387  ocean_assert(actualCamera_.isValid());
2388 
2389  if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2390  {
2391  return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(FisheyeCameraT<U>(actualCamera_));
2392  }
2393 
2394  const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2395 
2396  if (!NumericT<unsigned int>::isEqual(width, validWidth, 1u))
2397  {
2398  ocean_assert(false && "Wrong aspect ratio!");
2399  return nullptr;
2400  }
2401 
2402  const T xFactor = T(width) / T(actualCamera_.width());
2403  const T yFactor = T(height) / T(actualCamera_.height());
2404 
2405  const U newPrincipalX = U(actualCamera_.principalPointX() * xFactor);
2406  const U newPrincipalY = U(actualCamera_.principalPointY() * yFactor);
2407 
2408  const U newFocalLengthX = U(actualCamera_.focalLengthX() * xFactor);
2409  const U newFocalLengthY = U(actualCamera_.focalLengthY() * yFactor);
2410 
2411  U radialDistortion[6];
2412  for (unsigned int n = 0u; n < 6u; ++n)
2413  {
2414  radialDistortion[n] = U(actualCamera_.radialDistortion()[n]);
2415  }
2416 
2417  const U tangentialDistortion[2] =
2418  {
2419  U(actualCamera_.tangentialDistortion()[0]),
2420  U(actualCamera_.tangentialDistortion()[1])
2421  };
2422 
2423  return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(FisheyeCameraT<U>(width, height, newFocalLengthX, newFocalLengthY, newPrincipalX, newPrincipalY, radialDistortion, tangentialDistortion));
2424 }
2425 
2426 template <typename T>
2428 {
2429  return AnyCameraType::FISHEYE;
2430 }
2431 
2432 template <typename T>
2434 {
2435  return std::string("Ocean Fisheye");
2436 }
2437 
2438 template <typename T>
2440  actualCamera_(std::move(camera))
2441 {
2442  // nothing to do here
2443 }
2444 
2445 template <typename T>
2447  actualCamera_(camera)
2448 {
2449  // nothing to do here
2450 }
2451 
2452 template <typename T>
2454 {
2455  Log::error() << "Invalid camera: " << actualCamera_.reason();
2456 
2457  ocean_assert(false && "This function must never be called.");
2458 
2459  return actualCamera_;
2460 }
2461 
2462 template <typename T>
2463 inline unsigned int CameraWrapperBaseInvalidT<T>::width() const
2464 {
2465  Log::error() << "Invalid camera: " << actualCamera_.reason();
2466 
2467  ocean_assert(false && "This function must never be called.");
2468 
2469  return (unsigned int)(-1);
2470 }
2471 
2472 template <typename T>
2473 inline unsigned int CameraWrapperBaseInvalidT<T>::height() const
2474 {
2475  Log::error() << "Invalid camera: " << actualCamera_.reason();
2476 
2477  ocean_assert(false && "This function must never be called.");
2478 
2479  return (unsigned int)(-1);
2480 }
2481 
2482 template <typename T>
2484 {
2485  Log::error() << "Invalid camera: " << actualCamera_.reason();
2486 
2487  ocean_assert(false && "This function must never be called.");
2488 
2490 }
2491 
2492 template <typename T>
2494 {
2495  Log::error() << "Invalid camera: " << actualCamera_.reason();
2496 
2497  ocean_assert(false && "This function must never be called.");
2498 
2499  return NumericT<T>::minValue();
2500 }
2501 
2502 template <typename T>
2504 {
2505  Log::error() << "Invalid camera: " << actualCamera_.reason();
2506 
2507  ocean_assert(false && "This function must never be called.");
2508 
2509  return NumericT<T>::minValue();
2510 }
2511 
2512 template <typename T>
2514 {
2515  Log::error() << "Invalid camera: " << actualCamera_.reason();
2516 
2517  ocean_assert(false && "This function must never be called.");
2518 
2519  return NumericT<T>::minValue();
2520 }
2521 
2522 template <typename T>
2524 {
2525  Log::error() << "Invalid camera: " << actualCamera_.reason();
2526 
2527  ocean_assert(false && "This function must never be called.");
2528 
2529  return NumericT<T>::minValue();
2530 }
2531 
2532 template <typename T>
2534 {
2535  Log::error() << "Invalid camera: " << actualCamera_.reason();
2536 
2537  ocean_assert(false && "This function must never be called.");
2538 
2539  return NumericT<T>::minValue();
2540 }
2541 
2542 template <typename T>
2544 {
2545  Log::error() << "Invalid camera: " << actualCamera_.reason();
2546 
2547  ocean_assert(false && "This function must never be called.");
2548 
2549  return NumericT<T>::minValue();
2550 }
2551 
2552 template <typename T>
2554 {
2555  Log::error() << "Invalid camera: " << actualCamera_.reason();
2556 
2557  ocean_assert(false && "This function must never be called.");
2558 
2560 }
2561 
2562 template <typename T>
2563 inline VectorT2<T> CameraWrapperBaseInvalidT<T>::projectToImageIF(const HomogenousMatrixT4<T>& /*flippedCamera_T_world*/, const VectorT3<T>& /*objectPoint*/) const
2564 {
2565  Log::error() << "Invalid camera: " << actualCamera_.reason();
2566 
2567  ocean_assert(false && "This function must never be called.");
2568 
2570 }
2571 
2572 template <typename T>
2573 inline void CameraWrapperBaseInvalidT<T>::projectToImageIF(const VectorT3<T>* /*objectPoints*/, const size_t /*size*/, VectorT2<T>* /*imagePoints*/) const
2574 {
2575  Log::error() << "Invalid camera: " << actualCamera_.reason();
2576 
2577  ocean_assert(false && "This function must never be called.");
2578 
2579 }
2580 
2581 template <typename T>
2582 inline void CameraWrapperBaseInvalidT<T>::projectToImageIF(const HomogenousMatrixT4<T>& /*flippedCamera_T_world*/, const VectorT3<T>* /*objectPoints*/, const size_t /*size*/, VectorT2<T>* /*imagePoints*/) const
2583 {
2584  Log::error() << "Invalid camera: " << actualCamera_.reason();
2585 
2586  ocean_assert(false && "This function must never be called.");
2587 }
2588 
2589 template <typename T>
2590 inline VectorT3<T> CameraWrapperBaseInvalidT<T>::vectorIF(const VectorT2<T>& /*distortedImagePoint*/, const bool /*makeUnitVector*/) const
2591 {
2592  Log::error() << "Invalid camera: " << actualCamera_.reason();
2593 
2594  ocean_assert(false && "This function must never be called.");
2595 
2597 }
2598 
2599 template <typename T>
2600 inline void CameraWrapperBaseInvalidT<T>::vectorIF(const VectorT2<T>* /*distortedImagePoints*/, const size_t /*size*/, VectorT3<T>* /*vectors*/, const bool /*makeUnitVector*/) const
2601 {
2602  Log::error() << "Invalid camera: " << actualCamera_.reason();
2603 
2604  ocean_assert(false && "This function must never be called.");
2605 }
2606 
2607 template <typename T>
2608 inline void CameraWrapperBaseInvalidT<T>::pointJacobian2x3IF(const VectorT3<T>& /*flippedCameraObjectPoint*/, T* /*jx*/, T* /*jy*/) const
2609 {
2610  Log::error() << "Invalid camera: " << actualCamera_.reason();
2611 
2612  ocean_assert(false && "This function must never be called.");
2613 }
2614 
2615 template <typename T>
2616 inline bool CameraWrapperBaseInvalidT<T>::isEqual(const CameraWrapperBaseInvalidT& /*baseFisheye*/, const T /*eps*/) const
2617 {
2618  Log::error() << "Invalid camera: " << actualCamera_.reason();
2619 
2620  ocean_assert(false && "This function must never be called.");
2621 
2622  return false;
2623 }
2624 
2625 template <typename T>
2627 {
2628  return false;
2629 }
2630 
2631 template <typename T>
2632 template <typename U>
2633 inline std::unique_ptr<AnyCameraT<U>> CameraWrapperBaseInvalidT<T>::clone(const unsigned int /*width*/, const unsigned int /*height*/) const
2634 {
2635  Log::error() << "Invalid camera: " << actualCamera_.reason();
2636 
2637  ocean_assert(false && "This function must never be called.");
2638 
2639  return nullptr;
2640 }
2641 
2642 template <typename T>
2644 {
2645  return AnyCameraType::INVALID;
2646 }
2647 
2648 template <typename T>
2650 {
2651  return std::string("Invalid camera");
2652 }
2653 
2654 template <typename T>
2655 InvalidCameraT<T>::InvalidCameraT(const std::string& reason) :
2656  reason_(reason)
2657 {
2658  // nothing to do here
2659 }
2660 
2661 template <typename T>
2662 const std::string& InvalidCameraT<T>::reason() const
2663 {
2664  return reason_;
2665 }
2666 
2667 }
2668 
2669 #endif // META_OCEAN_MATH_ANY_CAMERA_H
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
virtual ~AnyCameraT()=default
Destructs the AnyCamera object.
AnyCameraT(AnyCameraT< T > &&)=delete
Disabled move constructor.
virtual VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const =0
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual T focalLengthX() const =0
Returns the horizontal focal length parameter.
virtual std::unique_ptr< AnyCameraT< double > > cloneToDouble(const unsigned int width=0u, const unsigned int height=0u) const =0
Returns a copy of this camera object with double precision.
virtual VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual void vectorIF(const VectorT2< T > *distortedImagePoints, const size_t size, VectorT3< T > *vectors, const bool makeUnitVector=true) const =0
Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
virtual void projectToImage(const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
AnyCameraT & operator=(const AnyCameraT &)=delete
Disabled assign operator.
virtual T inverseFocalLengthY() const =0
Returns the inverse vertical focal length parameter.
virtual LineT3< T > ray(const VectorT2< T > &distortedImagePoint) const =0
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
virtual void projectToImageIF(const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual T fovX() const =0
Returns the field of view in x direction of the camera.
static std::shared_ptr< AnyCameraT< T > > convert(const std::shared_ptr< AnyCameraT< U >> &anyCamera)
Converts an AnyCamera object with arbitrary scalar type to another AnyCamera object with arbitrary sc...
Definition: AnyCamera.h:1608
virtual T inverseFocalLengthX() const =0
Returns the inverse horizontal focal length parameter.
virtual std::unique_ptr< AnyCameraT< T > > clone(const unsigned int width=0u, const unsigned int height=0u) const =0
Returns a copy of this camera object.
virtual T focalLengthY() const =0
Returns the vertical focal length parameter.
virtual void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const =0
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
virtual VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual unsigned int height() const =0
Returns the height of the camera image.
virtual VectorT2< T > projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual T fovY() const =0
Returns the field of view in x direction of the camera.
virtual T principalPointY() const =0
Returns the y-value of the principal point of the camera image in the pixel domain.
virtual void projectToImage(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual bool isEqual(const AnyCameraT< T > &anyCamera, const T eps=NumericT< T >::eps()) const =0
Returns whether two camera objects are identical up to a given epsilon.
virtual bool isValid() const =0
Returns whether this camera is valid.
virtual VectorT2< T > principalPoint() const =0
Returns the coordinate of the principal point of the camera image in the pixel domain.
virtual AnyCameraType anyCameraType() const =0
Returns the type of this camera.
AnyCameraT()=default
Protected default constructor.
virtual LineT3< T > ray(const VectorT2< T > &distortedImagePoint, const HomogenousMatrixT4< T > &world_T_camera) const =0
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
virtual void vector(const VectorT2< T > *distortedImagePoints, const size_t size, VectorT3< T > *vectors, const bool makeUnitVector=true) const =0
Determines vectors starting at the camera's center and intersecting given 2D points in the image.
T TScalar
The scalar data type of this object.
Definition: AnyCamera.h:134
virtual std::unique_ptr< AnyCameraT< float > > cloneToFloat(const unsigned int width=0u, const unsigned int height=0u) const =0
Returns a copy of this camera object with float precision.
virtual void pointJacobian2nx3IF(const VectorT3< T > *flippedCameraObjectPoints, const size_t numberObjectPoints, T *jacobians) const =0
Calculates the 2n x 3 jacobian matrix for the 3D object point projection into the camera frame.
virtual std::string name() const =0
Returns the name of this camera.
AnyCameraT(const AnyCameraT< T > &anyCamera)=default
Protected copy constructor.
virtual void projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const =0
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
virtual bool isInside(const VectorT2< T > &imagePoint, const T signedBorder=T(0)) const =0
Returns whether a given 2D image point lies inside the camera frame.
AnyCameraT & operator=(AnyCameraT &&)=delete
Disabled move operator.
virtual VectorT2< T > projectToImage(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual T principalPointX() const =0
Returns the x-value of the principal point of the camera image in the pixel domain.
This class implements a specialized AnyCamera object wrapping the actual camera model.
Definition: AnyCamera.h:494
VectorT2< T > principalPoint() const override
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:1672
void pointJacobian2nx3IF(const VectorT3< T > *flippedCameraObjectPoints, const size_t numberObjectPoints, T *jacobians) const override
Calculates the 2n x 3 jacobian matrix for the 3D object point projection into the camera frame.
Definition: AnyCamera.h:1822
VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const override
Projects a 3D object point into the camera frame.
Definition: AnyCamera.h:1732
bool isEqual(const AnyCameraT< T > &anyCamera, const T eps=NumericT< T >::eps()) const override
Returns whether two camera objects are identical up to a given epsilon.
Definition: AnyCamera.h:1828
unsigned int width() const override
Returns the width of the camera image.
Definition: AnyCamera.h:1660
TCameraWrapper CameraWrapper
The class which is actually wrapping the camera object.
Definition: AnyCamera.h:501
unsigned int height() const override
Returns the height of the camera image.
Definition: AnyCamera.h:1666
std::unique_ptr< AnyCameraT< float > > cloneToFloat(const unsigned int width=0u, const unsigned int height=0u) const override
Returns a copy of this camera object with float precision.
Definition: AnyCamera.h:1648
std::unique_ptr< AnyCameraT< T > > clone(const unsigned int width=0u, const unsigned int height=0u) const override
Returns a copy of this camera object.
Definition: AnyCamera.h:1642
T focalLengthY() const override
Returns the vertical focal length parameter.
Definition: AnyCamera.h:1696
bool isValid() const override
Returns whether this camera is valid.
Definition: AnyCamera.h:1853
AnyCameraType anyCameraType() const override
Returns the type of this camera.
Definition: AnyCamera.h:1630
T inverseFocalLengthX() const override
Returns the inverse horizontal focal length parameter.
Definition: AnyCamera.h:1702
T principalPointY() const override
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:1684
AnyCameraWrappingT(ActualCamera &&actualCamera)
Creates a new AnyCamera object wrapping the actual camera model.
Definition: AnyCamera.h:1616
VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const override
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:1780
TCameraWrapper::ActualCamera ActualCamera
The actual camera object wrapped by this class.
Definition: AnyCamera.h:504
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const override
Projects a 3D object point into the camera frame.
Definition: AnyCamera.h:1744
T focalLengthX() const override
Returns the horizontal focal length parameter.
Definition: AnyCamera.h:1690
T fovX() const override
Returns the field of view in x direction of the camera.
Definition: AnyCamera.h:1714
bool isInside(const VectorT2< T > &imagePoint, const T signedBorder=T(0)) const override
Returns whether a given 2D image point lies inside the camera frame.
Definition: AnyCamera.h:1726
std::string name() const override
Returns the name of this camera.
Definition: AnyCamera.h:1636
LineT3< T > ray(const VectorT2< T > &distortedImagePoint, const HomogenousMatrixT4< T > &world_T_camera) const override
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:1804
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const override
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:1792
T TScalar
The scalar data type of this object.
Definition: AnyCamera.h:498
T principalPointX() const override
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:1678
std::unique_ptr< AnyCameraT< double > > cloneToDouble(const unsigned int width=0u, const unsigned int height=0u) const override
Returns a copy of this camera object with double precision.
Definition: AnyCamera.h:1654
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const override
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition: AnyCamera.h:1816
T fovY() const override
Returns the field of view in x direction of the camera.
Definition: AnyCamera.h:1720
T inverseFocalLengthY() const override
Returns the inverse vertical focal length parameter.
Definition: AnyCamera.h:1708
This class implements the base class for all cameras.
Definition: Camera.h:54
This class implements the base wrapper around Ocean's fisheye camera profile.
Definition: AnyCamera.h:1103
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2274
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition: AnyCamera.h:2298
ActualCamera actualCamera_
The actual fisheye camera object.
Definition: AnyCamera.h:1266
unsigned int height() const
Returns the height of the camera image.
Definition: AnyCamera.h:2262
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition: AnyCamera.h:2364
unsigned int width() const
Returns the width of the camera image.
Definition: AnyCamera.h:2256
bool isValid() const
Returns whether this camera is valid.
Definition: AnyCamera.h:2378
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition: AnyCamera.h:2304
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition: AnyCamera.h:2427
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:2346
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition: AnyCamera.h:2250
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2268
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2280
static std::string name()
Returns the name of this camera.
Definition: AnyCamera.h:2433
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition: AnyCamera.h:2286
T focalLengthY() const
Returns the vertical focal length parameter.
Definition: AnyCamera.h:2292
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition: AnyCamera.h:2310
CameraWrapperBaseFisheyeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseFisheyeT object wrapping the actual camera model.
Definition: AnyCamera.h:2236
std::unique_ptr< AnyCameraT< U > > clone(const unsigned int width=0u, const unsigned int height=0u) const
Returns a copy of the actual camera object.
Definition: AnyCamera.h:2385
bool isEqual(const CameraWrapperBaseFisheyeT< T > &baseFisheye, const T eps=NumericT< T >::eps()) const
Returns whether two camera objects are identical up to a given epsilon.
Definition: AnyCamera.h:2370
FisheyeCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition: AnyCamera.h:1109
This class implements the base wrapper around an invalid camera profile.
Definition: AnyCamera.h:1326
bool isEqual(const CameraWrapperBaseInvalidT< T > &baseInvalid, const T eps=NumericT< T >::eps()) const
Returns whether two camera objects are identical up to a given epsilon.
Definition: AnyCamera.h:2616
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition: AnyCamera.h:2553
CameraWrapperBaseInvalidT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseInvalidT object wrapping the actual camera model.
Definition: AnyCamera.h:2439
unsigned int height() const
Returns the height of the camera image.
Definition: AnyCamera.h:2473
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition: AnyCamera.h:2453
static std::string name()
Returns the name of this camera.
Definition: AnyCamera.h:2649
ActualCamera actualCamera_
The actual invalid camera.
Definition: AnyCamera.h:1489
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2493
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2483
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition: AnyCamera.h:2533
bool isValid() const
Returns whether this camera is valid.
Definition: AnyCamera.h:2626
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition: AnyCamera.h:2643
std::unique_ptr< AnyCameraT< U > > clone(const unsigned int width=0u, const unsigned int height=0u) const
Returns a copy of the actual camera object.
Definition: AnyCamera.h:2633
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition: AnyCamera.h:2543
InvalidCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition: AnyCamera.h:1332
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition: AnyCamera.h:2608
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:2590
T focalLengthY() const
Returns the vertical focal length parameter.
Definition: AnyCamera.h:2523
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2503
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition: AnyCamera.h:2513
unsigned int width() const
Returns the width of the camera image.
Definition: AnyCamera.h:2463
This class implements the base wrapper around Ocean's pinhole camera profile.
Definition: AnyCamera.h:934
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition: AnyCamera.h:2089
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition: AnyCamera.h:2157
unsigned int height() const
Returns the height of the camera image.
Definition: AnyCamera.h:2059
bool isValid() const
Returns whether this camera is valid.
Definition: AnyCamera.h:2172
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2071
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition: AnyCamera.h:2095
static std::string name()
Returns the name of this camera.
Definition: AnyCamera.h:2230
ActualCamera actualCamera_
The actual pinhole camera.
Definition: AnyCamera.h:1092
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition: AnyCamera.h:2047
unsigned int width() const
Returns the width of the camera image.
Definition: AnyCamera.h:2053
CameraWrapperBasePinholeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBasePinholeT object wrapping the actual camera model.
Definition: AnyCamera.h:2033
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:2137
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition: AnyCamera.h:2101
PinholeCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition: AnyCamera.h:940
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition: AnyCamera.h:2224
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:2065
bool isEqual(const CameraWrapperBasePinholeT< T > &basePinhole, const T eps=NumericT< T >::eps()) const
Returns whether two camera objects are identical up to a given epsilon.
Definition: AnyCamera.h:2164
std::unique_ptr< AnyCameraT< U > > clone(const unsigned int width=0u, const unsigned int height=0u) const
Returns a copy of the actual camera object.
Definition: AnyCamera.h:2179
T focalLengthY() const
Returns the vertical focal length parameter.
Definition: AnyCamera.h:2083
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition: AnyCamera.h:2077
This class implements a wrapper for an actual camera object.
Definition: AnyCamera.h:825
LineT3< T > ray(const VectorT2< T > &distortedImagePoint, const HomogenousMatrixT4< T > &world_T_camera) const
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:2003
T fovY() const
Returns the field of view in x direction of the camera.
Definition: AnyCamera.h:1908
T fovX() const
Returns the field of view in x direction of the camera.
Definition: AnyCamera.h:1879
CameraWrapperT(ActualCamera &&actualCamera)
Creates a new CameraWrapperT object wrapping the actual camera model.
Definition: AnyCamera.h:1859
VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition: AnyCamera.h:1982
void pointJacobian2nx3IF(const VectorT3< T > *flippedCameraObjectPoints, const size_t numberObjectPoints, T *jacobians) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition: AnyCamera.h:2019
bool isInside(const VectorT2< T > &imagePoint, const T signedBorder=T(0)) const
Returns whether a given 2D image point lies inside the camera frame.
Definition: AnyCamera.h:1937
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition: AnyCamera.h:1873
VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition: AnyCamera.h:1951
Class representing a fisheye camera.
Definition: FisheyeCamera.h:106
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition: HomogenousMatrix4.h:110
SquareMatrixT3< T > rotationMatrix() const
Returns the rotation matrix of the transformation.
Definition: HomogenousMatrix4.h:1493
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition: HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
This class implements invalid camera profiles, e.g.
Definition: AnyCamera.h:1276
const std::string & reason() const
Returns the reason of this invalid camera.
Definition: AnyCamera.h:2662
std::string reason_
The reason why no valid camera is available.
Definition: AnyCamera.h:1294
InvalidCameraT(const std::string &reason)
Creates an invalid camera.
Definition: AnyCamera.h:2655
This class implements an infinite line in 3D space.
Definition: Line3.h:70
static MessageObject error()
Returns the message for error messages.
Definition: Messenger.h:1074
This class provides basic numeric functionalities.
Definition: Numeric.h:57
static constexpr T minValue()
Returns the min scalar value.
Definition: Numeric.h:3250
static T atan(const T value)
Returns the arctangent of a given value.
Definition: Numeric.h:1616
static T abs(const T value)
Returns the absolute value of a given value.
Definition: Numeric.h:1220
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
Definition of a pinhole camera model.
Definition: PinholeCamera.h:114
This class implements a vector with two elements.
Definition: Vector2.h:96
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
This class implements a vector with three elements.
Definition: Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
AnyCameraPinholeT< float > AnyCameraPinholeF
Definition of an AnyCamera object based on Ocean's pinhole camera class with element precision 'float...
Definition: AnyCamera.h:1520
std::shared_ptr< AnyCameraD > SharedAnyCameraD
Definition of a shared pointer holding an AnyCamera object with double precision.
Definition: AnyCamera.h:67
AnyCameraFisheyeT< double > AnyCameraFisheyeD
Definition of an AnyCamera object based on Ocean's fisheye camera class with element precision 'doubl...
Definition: AnyCamera.h:1543
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:60
AnyCameraFisheyeT< float > AnyCameraFisheyeF
Definition of an AnyCamera object based on Ocean's fisheye camera class with element precision 'float...
Definition: AnyCamera.h:1550
AnyCameraInvalidT< Scalar > AnyCameraInvalid
Definition of an AnyCamera object based on an invalid (by design) camera with element precision 'Scal...
Definition: AnyCamera.h:1566
AnyCameraInvalidT< double > AnyCameraInvalidD
Definition of an AnyCamera object based on an invalid (by design) camera with element precision 'doub...
Definition: AnyCamera.h:1573
AnyCameraInvalidT< float > AnyCameraInvalidF
Definition of an AnyCamera object based on an invalid (by design) camera with element precision 'floa...
Definition: AnyCamera.h:1580
SharedAnyCamerasT< float > SharedAnyCamerasF
Definition of a vector holding AnyCameraF objects.
Definition: AnyCamera.h:104
SharedAnyCamerasT< double > SharedAnyCamerasD
Definition of a vector holding AnyCameraD objects.
Definition: AnyCamera.h:97
InvalidCameraT< float > InvalidCameraF
Definition of an invalid camera object based with element precision 'float'.
Definition: AnyCamera.h:1316
AnyCameraType
Definition of individual camera types.
Definition: AnyCamera.h:111
std::shared_ptr< AnyCameraF > SharedAnyCameraF
Definition of a shared pointer holding an AnyCamera object with float precision.
Definition: AnyCamera.h:74
std::vector< std::shared_ptr< AnyCameraT< T > >> SharedAnyCamerasT
Definition of a typename alias for vectors with shared AnyCameraT objects.
Definition: AnyCamera.h:83
AnyCameraFisheyeT< Scalar > AnyCameraFisheye
Definition of an AnyCamera object based on Ocean's fisheye camera class with element precision 'Scala...
Definition: AnyCamera.h:1536
AnyCameraPinholeT< double > AnyCameraPinholeD
Definition of an AnyCamera object based on Ocean's pinhole camera class with element precision 'doubl...
Definition: AnyCamera.h:1513
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition: AnyCamera.h:90
InvalidCameraT< Scalar > InvalidCamera
Definition of an invalid camera object based with element precision 'Scalar'.
Definition: AnyCamera.h:1302
InvalidCameraT< double > InvalidCameraD
Definition of an invalid camera object based with element precision 'double'.
Definition: AnyCamera.h:1309
AnyCameraPinholeT< Scalar > AnyCameraPinhole
Definition of an AnyCamera object based on Ocean's pinhole camera class with element precision 'Scala...
Definition: AnyCamera.h:1506
std::shared_ptr< AnyCameraT< T > > SharedAnyCameraT
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:53
@ FISHEYE
A fisheye camera.
@ PINHOLE
A pinhole camera.
@ INVALID
An invalid camera type.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15