Ocean
Loading...
Searching...
No Matches
test/testgeometry/Utilities.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_TEST_TESTGEOMETRY_UTILITIES_H
9#define META_OCEAN_TEST_TESTGEOMETRY_UTILITIES_H
10
12
14
16
18#include "ocean/math/Box3.h"
22#include "ocean/math/Sphere3.h"
23#include "ocean/math/Vector3.h"
24
25namespace Ocean
26{
27
28namespace Test
29{
30
31namespace TestGeometry
32{
33
34/**
35 * This class implements utility functions for the geometry test library.
36 * @ingroup testgeometry
37 */
38class OCEAN_TEST_GEOMETRY_EXPORT Utilities
39{
40 public:
41
42 /**
43 * Creates a set of image points that are located inside a camera frame.
44 * @param pinholeCamera The pinhole camera profile that is applied
45 * @param number The number of the resulting image points, with range [1, infinity)
46 * @param randomGenerator Optional random generator
47 * @return Resulting 2D image points
48 */
49 static Vectors2 imagePoints(const PinholeCamera& pinholeCamera, const size_t number, RandomGenerator* randomGenerator = nullptr);
50
51 /**
52 * Creates a set of object points that are located inside a specified bounding box.
53 * @param boundingBox 3D bounding box
54 * @param number The number of the resulting object points, with range [1, infinity)
55 * @param randomGenerator Optional random generator
56 * @return Resulting 3D object points
57 */
58 static Vectors3 objectPoints(const Box3& boundingBox, const size_t number, RandomGenerator* randomGenerator = nullptr);
59
60 /**
61 * Deprecated.
62 *
63 * Determines a viewing position for a given camera for a set of 3D object points so that all point project into the camera frame.
64 * @param pinholeCamera The pinhole camera profile defining the projection, must be valid
65 * @param boundingSphere Bounding sphere that has to be visible in the final view, can have radius 0, must be valid
66 * @param viewingDirection Viewing direction of the resulting camera with unit length
67 * @return Resulting camera pose, transforming camera to world (world_T_camera)
68 */
69 static HomogenousMatrix4 viewPosition(const PinholeCamera& pinholeCamera, const Sphere3& boundingSphere, const Vector3& viewingDirection);
70
71 /**
72 * Determines a viewing position for a given camera for a set of 3D object points so that all point project into the camera frame.
73 * @param anyCamera The camera profile defining the projection, must be valid
74 * @param boundingSphere Bounding sphere that has to be visible in the final view, can have radius 0, must be valid
75 * @param viewingDirection Viewing direction of the resulting camera with unit length
76 * @return Resulting camera pose, transforming camera to world (world_T_camera)
77 * @tparam T The data type of the scalar to use, either 'float' or 'double'
78 */
79 template <typename T>
80 static HomogenousMatrixT4<T> viewPosition(const AnyCameraT<T>& anyCamera, const SphereT3<T>& boundingSphere, const VectorT3<T>& viewingDirection);
81
82 /**
83 * Deprecated.
84 *
85 * Determines a viewing position for a given camera for a set of 3D object points so that all point project into the camera frame.
86 * @param pinholeCamera The pinhole camera profile defining the projection, must be valid
87 * @param objectPoints Object points for that the camera position will be determined
88 * @param viewingDirection Viewing direction of the resulting camera with unit length
89 * @param circumcircle True, to ensure that all object points will project into the frame, otherwise some sole points will project outside the image frame
90 * @return Resulting camera pose, transforming camera to world (world_T_camera)
91 */
92 static HomogenousMatrix4 viewPosition(const PinholeCamera& pinholeCamera, const Vectors3& objectPoints, const Vector3& viewingDirection, const bool circumcircle = true);
93
94 /**
95 * Determines a viewing position for a given camera for a set of 3D object points so that all point project into the camera frame.
96 * @param anyCamera The camera profile defining the projection, must be valid
97 * @param objectPoints Object points for that the camera position will be determined
98 * @param viewingDirection Viewing direction of the resulting camera with unit length
99 * @param circumcircle True, to ensure that all object points will project into the frame, otherwise some sole points will project outside the image frame
100 * @return Resulting camera pose, transforming camera to world (world_T_camera)
101 * @tparam T The data type of the scalar to use, either 'float' or 'double'
102 */
103 template <typename T>
104 static HomogenousMatrixT4<T> viewPosition(const AnyCameraT<T>& anyCamera, const VectorsT3<T>& objectPoints, const VectorT3<T>& viewingDirection, const bool circumcircle = true);
105
106 /**
107 * Deprecated.
108 *
109 * Determines a viewing position for a given camera for a set of 3D object points so that all point project into the camera frame.
110 * @param pinholeCamera The pinhole camera profile defining the projection, must be valid
111 * @param objectPoints Object points for that the camera position will be determined
112 * @param circumcircle True, to ensure that all object points will project into the frame, otherwise some sole points will project outside the image frame
113 * @param randomGenerator Optional random generator
114 * @return Resulting camera pose, transforming camera to world (world_T_camera)
115 */
116 static HomogenousMatrix4 viewPosition(const PinholeCamera& pinholeCamera, const Vectors3& objectPoints, const bool circumcircle = true, RandomGenerator* randomGenerator = nullptr);
117
118 /**
119 * Determines a viewing position for a given camera for a set of 3D object points so that all point project into the camera frame.
120 * @param anyCamera The camera profile defining the projection, must be valid
121 * @param objectPoints Object points for that the camera position will be determined
122 * @param circumcircle True, to ensure that all object points will project into the frame, otherwise some sole points will project outside the image frame
123 * @param randomGenerator Optional random generator
124 * @return Resulting camera pose, transforming camera to world (world_T_camera)
125 * @tparam T The data type of the scalar to use, either 'float' or 'double'
126 */
127 template <typename T>
128 static HomogenousMatrixT4<T> viewPosition(const AnyCameraT<T>& anyCamera, const VectorsT3<T>& objectPoints, const bool circumcircle = true, RandomGenerator* randomGenerator = nullptr);
129
130 /**
131 * Modifies a provided camera and adds random radial and tangential distortion.
132 * @param pinholeCamera The pinhole camera object that will be modified
133 * @param principalPointDistortion True, to modify the principal point
134 * @param radialDistortion True, to modify the radial distortion
135 * @param tangentialDistortion True, to modify the tangential distortion
136 * @param randomGenerator Optional random generator, nullptr to use a default random generator
137 * @param maximalPrincipalPointOffset Maximal offset of the principal point, with range [0, infinity)
138 * @param maximalRadialDistortion Maximal radial distortion, with range [0, infinity)
139 * @param maximalTangentialDistortion Maximal tangential distortion, with range [0, infinity)
140 * @return Resulting modified camera
141 */
142 static PinholeCamera distortedCamera(const PinholeCamera& pinholeCamera, const bool principalPointDistortion = true, const bool radialDistortion = true, const bool tangentialDistortion = true, RandomGenerator* randomGenerator = nullptr, const Scalar maximalPrincipalPointOffset = Scalar(20), const Scalar maximalRadialDistortion = Scalar(0.1), const Scalar maximalTangentialDistortion = Scalar(0.01));
143
144 /**
145 * Returns one of two realistic pinhole camera profiles.
146 * @param index The index of the camera profile to be returned, with range [0, 1]
147 * @return The realistic camera profile
148 * @tparam T The data type of the scalar to be used, either 'float' or 'double'
149 */
150 template <typename T = Scalar>
151 static PinholeCameraT<T> realisticPinholeCamera(const unsigned int index = 0u);
152
153 /**
154 * Returns one of two realistic fisheye camera profiles.
155 * @param index The index of the camera profile to be returned, with range [0, 1]
156 * @tparam T The data type of the scalar to be used, either 'float' or 'double'
157 * @return The realistic camera profile
158 */
159 template <typename T = Scalar>
160 static FisheyeCameraT<T> realisticFisheyeCamera(const unsigned int index = 0u);
161
162 /**
163 * Returns one of two realistic camera profiles provided as an AnyCamera object.
164 * @param anyCameraType The type of the camera to be created, must be valid
165 * @param index The index of the camera profile to be returned, with range [0, 1]
166 * @return The realistic camera profile
167 * @tparam T The data type of the scalar to be used, either 'float' or 'double'
168 */
169 template <typename T = Scalar>
170 static SharedAnyCameraT<T> realisticAnyCamera(const AnyCameraType anyCameraType, const unsigned int index = 0u);
171
172 /**
173 * Returns all camera types for which a realistic camera object can be accessed.
174 * @return The available camera types
175 */
176 static std::vector<AnyCameraType> realisticCameraTypes();
177
178 /**
179 * Creates a set of random indices.
180 * @param size The size of the entire element, with range [1, infinity)
181 * @param randomIndices Number of random indices, with range [1, size]
182 * @param randomGenerator Optional random generator
183 */
184 static IndexSet32 randomIndices(const size_t size, const size_t randomIndices, RandomGenerator* randomGenerator = nullptr);
185};
186
187}
188
189}
190
191}
192
193#endif // META_OCEAN_TEST_TESTGEOMETRY_UTILITIES_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
Class representing a fisheye camera.
Definition FisheyeCamera.h:106
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
This class implements utility functions for the geometry test library.
Definition test/testgeometry/Utilities.h:39
static FisheyeCameraT< T > realisticFisheyeCamera(const unsigned int index=0u)
Returns one of two realistic fisheye camera profiles.
static HomogenousMatrix4 viewPosition(const PinholeCamera &pinholeCamera, const Vectors3 &objectPoints, const Vector3 &viewingDirection, const bool circumcircle=true)
Deprecated.
static SharedAnyCameraT< T > realisticAnyCamera(const AnyCameraType anyCameraType, const unsigned int index=0u)
Returns one of two realistic camera profiles provided as an AnyCamera object.
static HomogenousMatrixT4< T > viewPosition(const AnyCameraT< T > &anyCamera, const VectorsT3< T > &objectPoints, const VectorT3< T > &viewingDirection, const bool circumcircle=true)
Determines a viewing position for a given camera for a set of 3D object points so that all point proj...
static IndexSet32 randomIndices(const size_t size, const size_t randomIndices, RandomGenerator *randomGenerator=nullptr)
Creates a set of random indices.
static PinholeCamera distortedCamera(const PinholeCamera &pinholeCamera, const bool principalPointDistortion=true, const bool radialDistortion=true, const bool tangentialDistortion=true, RandomGenerator *randomGenerator=nullptr, const Scalar maximalPrincipalPointOffset=Scalar(20), const Scalar maximalRadialDistortion=Scalar(0.1), const Scalar maximalTangentialDistortion=Scalar(0.01))
Modifies a provided camera and adds random radial and tangential distortion.
static HomogenousMatrixT4< T > viewPosition(const AnyCameraT< T > &anyCamera, const SphereT3< T > &boundingSphere, const VectorT3< T > &viewingDirection)
Determines a viewing position for a given camera for a set of 3D object points so that all point proj...
static HomogenousMatrix4 viewPosition(const PinholeCamera &pinholeCamera, const Sphere3 &boundingSphere, const Vector3 &viewingDirection)
Deprecated.
static Vectors3 objectPoints(const Box3 &boundingBox, const size_t number, RandomGenerator *randomGenerator=nullptr)
Creates a set of object points that are located inside a specified bounding box.
static std::vector< AnyCameraType > realisticCameraTypes()
Returns all camera types for which a realistic camera object can be accessed.
static Vectors2 imagePoints(const PinholeCamera &pinholeCamera, const size_t number, RandomGenerator *randomGenerator=nullptr)
Creates a set of image points that are located inside a camera frame.
static PinholeCameraT< T > realisticPinholeCamera(const unsigned int index=0u)
Returns one of two realistic pinhole camera profiles.
static HomogenousMatrixT4< T > viewPosition(const AnyCameraT< T > &anyCamera, const VectorsT3< T > &objectPoints, const bool circumcircle=true, RandomGenerator *randomGenerator=nullptr)
Determines a viewing position for a given camera for a set of 3D object points so that all point proj...
static HomogenousMatrix4 viewPosition(const PinholeCamera &pinholeCamera, const Vectors3 &objectPoints, const bool circumcircle=true, RandomGenerator *randomGenerator=nullptr)
Deprecated.
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition Base.h:114
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
AnyCameraType
Definition of individual camera types.
Definition AnyCamera.h:111
std::vector< VectorT3< T > > VectorsT3
Definition of a typename alias for vectors with VectorT3 objects.
Definition Vector3.h:58
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
std::shared_ptr< AnyCameraT< T > > SharedAnyCameraT
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:53
The namespace covering the entire Ocean framework.
Definition Accessor.h:15