Ocean
Loading...
Searching...
No Matches
EpipolarGeometry.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_GEOMETRY_EPIPOLAR_GEOMETRY_H
9#define META_OCEAN_GEOMETRY_EPIPOLAR_GEOMETRY_H
10
12
13#include "ocean/base/Accessor.h"
14
16#include "ocean/math/Line2.h"
20#include "ocean/math/Vector3.h"
21
22namespace Ocean
23{
24
25namespace Geometry
26{
27
28/**
29 * This class implements epipolar geometry functions.
30 * @ingroup geometry
31 */
32class OCEAN_GEOMETRY_EXPORT EpipolarGeometry
33{
34 public:
35
36 /**
37 * Calculates the fundamental matrix based on corresponding image points in a 'left' and in a 'right' camera image.
38 * The resulting fundamental matrix is defined by the following equation:
39 * <pre>
40 * rightPoint^T * right_F_left * leftPoint = 0
41 * </pre>
42 * @param leftPoints The left image points, must be valid
43 * @param rightPoints The right image points, must be valid
44 * @param correspondences The number of point correspondences, with range [8, infinity)
45 * @param right_F_left The resulting fundamental matrix
46 * @return True, if succeeded
47 */
48 static bool fundamentalMatrix(const Vector2* leftPoints, const Vector2* rightPoints, const size_t correspondences, SquareMatrix3& right_F_left);
49
50 /**
51 * Returns the reverted fundamental matrix.
52 * Actually the matrix will be transposed only, because the fundamental matrix is singular.
53 * @param right_F_left The fundamental matrix satisfying the equation rightPoint^T * right_F_left * leftPoint = 0
54 * @return The resulting reverted fundamental matrix 'left_F_right'
55 */
56 static inline SquareMatrix3 reverseFundamentalMatrix(const SquareMatrix3& right_F_left);
57
58 /**
59 * Calculates the essential matrix based on corresponding viewing rays from the 'left' and 'right' camera.
60 * This function implements the 8-point algorithm based on corresponding viewing rays.
61 * The resulting essential matrix is defined by the following equation:
62 * <pre>
63 * rightViewingRay^T * normalizedRight_E_normalizedLeft * leftViewingRay = 0
64 * </pre>
65 * The normalized image points are defined in the flipped camera, with default flipped camera pointing towards the positive z-space with y-axis upwards.
66 * @param leftImageRays Three 3D rays with unit length, defined in the coordinate system of the left camera, starting at the camera's center of projection (equal to the origin) and hitting the image plane at a known image points
67 * @param rightImageRays The 3D rays with unit length, defined in the coordinate system of the right camera, starting at the camera's center of projection (equal to the origin) and hitting the image plane at a known image points, one for each left image ray
68 * @param correspondences The number of bearing vector correspondences, with range [8, infinity)
69 * @param normalizedRight_E_normalizedLeft The resulting essential matrix
70 * @return True, if succeeded
71 */
72 static bool essentialMatrix(const Vector3* leftImageRays, const Vector3* rightImageRays, const size_t correspondences, SquareMatrix3& normalizedRight_E_normalizedLeft);
73
74 /**
75 * Calculates the essential matrix based on corresponding viewing rays from the 'left' and 'right' camera.
76 * This function implements the 8-point algorithm based on corresponding viewing rays.
77 * The resulting essential matrix is defined by the following equation:
78 * <pre>
79 * rightViewingRay^T * normalizedRight_E_normalizedLeft * leftViewingRay = 0
80 * </pre>
81 * The normalized image points are defined in the flipped camera, with default flipped camera pointing towards the positive z-space with y-axis upwards.
82 * @param flippedLeftImageRays Three flipped 3D rays with unit length, defined in the flipped coordinate system of the left camera, starting at the camera's center of projection (equal to the origin) and hitting the image plane at a known image points
83 * @param flippedRightImageRays The flipped 3D rays with unit length, defined in the flipped coordinate system of the right camera, starting at the camera's center of projection (equal to the origin) and hitting the image plane at a known image points, one for each left image ray
84 * @param correspondences The number of bearing vector correspondences, with range [8, infinity)
85 * @param normalizedRight_E_normalizedLeft The resulting essential matrix
86 * @return True, if succeeded
87 */
88 static bool essentialMatrixF(const Vector3* flippedLeftImageRays, const Vector3* flippedRightImageRays, const size_t correspondences, SquareMatrix3& normalizedRight_E_normalizedLeft);
89
90 /**
91 * Calculates the essential matrix based on 6-DOF camera pose between two cameras.
92 * The resulting essential matrix is defined by the following equation:
93 * <pre>
94 * normalizedRightPoint^T * normalizedRight_E_normalizedLeft * normalizedLeftPoint = 0
95 * with normalizedRightPoint = [flippedObjectPoint.x() / flippedObjectPoint.z(), flippedObjectPoint.y() / flippedObjectPoint.z(), 1]^T
96 * </pre>
97 * The flipped object points and the normalized image points are defined in the flipped camera, with default flipped camera pointing towards the positive z-space with y-axis upwards.
98 * @param rightCamera_T_leftCamera The transformation transforming the left camera to the right camera, with default camera pointing towards the negative z-space with y-axis upwards, must be valid
99 * @return The resulting essential matrix 'normalizedRight_E_normalizedLeft'
100 */
101 static SquareMatrix3 essentialMatrix(const HomogenousMatrix4& rightCamera_T_leftCamera);
102
103 /**
104 * Calculates the fundamental matrix from a given essential matrix and the two intrinsic camera matrices.
105 * @param normalizedRight_E_normalizedLeft The essential matrix to convert, must be valid
106 * @param leftIntrinsic The left intrinsic camera matrix, must be valid
107 * @param rightIntrinsic The right intrinsic camera matrix, must be valid
108 * @param fundamental The resulting fundamental matrix 'right_F_left'
109 */
110 static SquareMatrix3 essential2fundamental(const SquareMatrix3& normalizedRight_E_normalizedLeft, const SquareMatrix3& leftIntrinsic, const SquareMatrix3& rightIntrinsic);
111
112 /**
113 * Calculates the fundamental matrix from a given essential matrix and the two intrinsic camera matrices.
114 * @param normalizedRight_E_normalizedLeft The essential matrix to convert, must be valid
115 * @param leftCamera The left camera profile defining the projection, must be a pure pinhole model without any distortion parameters
116 * @param rightCamera The right camera profile defining the projection, must be a pure pinhole model without any distortion parameters
117 * @return The resulting fundamental matrix 'right_F_left'
118 */
119 static SquareMatrix3 essential2fundamental(const SquareMatrix3& normalizedRight_E_normalizedLeft, const PinholeCamera& leftCamera, const PinholeCamera& rightCamera);
120
121 /**
122 * Calculates the essential matrix from a given fundamental matrix and the two intrinsic camera matrices.
123 * @param right_F_left The fundamental matrix to convert into essential matrix, must be valid
124 * @param leftIntrinsic Left intrinsic camera matrix
125 * @param rightIntrinsic Right intrinsic camera matrix
126 * @return The resulting essential matrix 'normalizedRight_E_normalizedLeft'
127 */
128 static SquareMatrix3 fundamental2essential(const SquareMatrix3& right_F_left, const SquareMatrix3& leftIntrinsic, const SquareMatrix3& rightIntrinsic);
129
130 /**
131 * Calculates the essential matrix by the given fundamental matrix and the two cameras.
132 * @param right_F_left The fundamental matrix to convert into essential matrix, must be valid
133 * @param leftCamera The left camera profile defining the projection, must be a pure pinhole model without any distortion parameters
134 * @param rightCamera The right camera profile defining the projection, must be a pure pinhole model without any distortion parameters
135 * @return The resulting essential matrix 'normalizedRight_E_normalizedLeft'
136 */
137 static SquareMatrix3 fundamental2essential(const SquareMatrix3& right_F_left, const PinholeCamera& leftCamera, const PinholeCamera& rightCamera);
138
139 /**
140 * Determines the two epipoles corresponding to a fundamental matrix.
141 * This method uses singular values decomposition for the calculation.
142 * @param right_F_left The fundamental matrix to convert into essential matrix, must be valid
143 * @param leftEpipole Resulting left epipole
144 * @param rightEpipole Resulting right epipole
145 * @return True, if succeeded
146 */
147 static bool epipoles(const SquareMatrix3& right_F_left, Vector2& leftEpipole, Vector2& rightEpipole);
148
149 /**
150 * Determines the two epipoles corresponding to two cameras separated by an extrinsic camera matrix.
151 * The matrix will be calculated by the extrinsic camera matrix of the right camera relative to the left camera,<br>
152 * and the two intrinsic camera matrices of both cameras.
153 * @param extrinsic The extrinsic camera matrix of the right camera relative to the left camera (rightTleft)
154 * @param leftIntrinsic Intrinsic camera matrix of the left camera
155 * @param rightIntrinsic Intrinsic camera matrix of the right camera
156 * @param leftEpipole Resulting left epipole
157 * @param rightEpipole Resulting right epipole
158 * @return True, if succeeded
159 * @see essentialMatrix().
160 */
161 static bool epipoles(const HomogenousMatrix4& extrinsic, const SquareMatrix3& leftIntrinsic, const SquareMatrix3& rightIntrinsic, Vector2& leftEpipole, Vector2& rightEpipole);
162
163 /**
164 * Finds the two epipoles corresponding to a fundamental matrix.
165 * This method calculates the intersection of two epipolar lines.
166 * If no intersection can be found the SVD calculation is used.
167 * @param fundamental The fundamental matrix to extract the epipoles from
168 * @param leftEpipole Resulting left epipole
169 * @param rightEpipole Resulting right epipole
170 * @return True, if succeeded
171 */
172 static bool epipolesFast(const SquareMatrix3& fundamental, Vector2& leftEpipole, Vector2& rightEpipole);
173
174 /**
175 * Returns the epipolar line in the left image corresponding to a given point in the right image.
176 * @param fundamental The fundamental matrix
177 * @param rightPoint Point in the right image
178 * @return Resulting epipolar line in the left image
179 */
180 static inline Line2 leftEpipolarLine(const SquareMatrix3& fundamental, const Vector2& rightPoint);
181
182 /**
183 * Returns the epipolar line in the right image corresponding to a given point in the left image.
184 * @param fundamental The fundamental matrix
185 * @param leftPoint Point in the left image
186 * @return Resulting epipolar line in the right image
187 */
188 static inline Line2 rightEpipolarLine(const SquareMatrix3& fundamental, const Vector2& leftPoint);
189
190 /**
191 * Factorizes an essential matrix into a 6-DOF camera pose composed of rotation and translation.
192 * Beware: The translation can be determined up to a scale factor only.<br>
193 * The factorization provides the camera pose for the right camera while the left camera is located at the origin with identity pose.<br>
194 * The resulting transformation transforms points defined in the right camera coordinate system into points defined in the left camera coordinate system: pointLeft = left_T_right * pointRight.<br>
195 * @param normalizedRight_E_normalizedLeft The essential matrix to be factorized, must be valid
196 * @param leftCamera The left camera profile defining the projection, must be valid
197 * @param rightCamera The right camera profile defining the projection, must be valid
198 * @param leftPoints All image points in the left image to be checked whether they produce 3D object points lying in front of the camera, must be valid
199 * @param rightPoints All image points in the right image, one for each left point, must be valid
200 * @param correspondences The number of point correspondences, with range [1, infinity)
201 * @param left_T_right The resulting transformation between the left and the right camera, transforming points from right to left
202 * @return The number of given image points resulting in valid object points, with range [0, infinity)
203 */
204 static size_t factorizeEssential(const SquareMatrix3& normalizedRight_E_normalizedLeft, const PinholeCamera& leftCamera, const PinholeCamera& rightCamera, const Vector2* leftPoints, const Vector2* rightPoints, const size_t correspondences, HomogenousMatrix4& left_T_right);
205
206 /**
207 * Determines the homograph for two (stereo) frames rectifying both images using the transformation between the left and the right camera.
208 * As the resulting homography may not cover the entire input images using the same camera profile a new camera (perfect) profile can be calculated instead.<br>
209 * Thus, the resulting rectified images will have a larger field of view but will cover the entire input frame data.<br>
210 * The projection center of the left camera is expected to be at the origin of the world coordinate system.<br>
211 * The viewing directions of both cameras is towards the negative z-axis in their particular coordinate systems.<br>
212 * The given transformation is equal to the extrinsic camera matrix of the right camera<br>
213 * and thus transforms points defined inside the right camera coordinate system to points defined inside the left camera coordinate system.<br>
214 * The resulting homography transformations transform 3D rectified image points (homogenous 2D coordinates) into 3D unrectified image points for their particular coordinate system.<br>
215 * The coordinate system of the 3D image points has the origin in the top left corner, while the x-axis points to right, the y-axis points to the bottom and the z-axis to the back of the image.<br>
216 * @param transformation Extrinsic camera matrix of the right camera with negative z-axis as viewing direction
217 * @param pinholeCamera The pinhole camera profile used for both images
218 * @param leftHomography Resulting left homography
219 * @param rightHomography Resulting right homography
220 * @param appliedRotation Resulting rotation applied to both cameras
221 * @param newCamera Optional resulting new camera profile used to cover the entire input image data into the output frames, otherwise nullptr
222 * @return True, if succeeded
223 */
224 static bool rectificationHomography(const HomogenousMatrix4& transformation, const PinholeCamera& pinholeCamera, SquareMatrix3& leftHomography, SquareMatrix3& rightHomography, Quaternion& appliedRotation, PinholeCamera* newCamera);
225
226 /**
227 * Calculates the 3D positions for a pair of image point correspondences with corresponding extrinsic camera transformations.
228 * @param world_T_cameraA The extrinsic camera transformations of the first camera, with the camera pointing towards the negative z-space, y-axis pointing up, and the x-axis pointing to the right, must be valid
229 * @param world_T_cameraB The extrinsic camera transformations of the second camera, with the camera pointing towards the negative z-space, y-axis pointing up, and the x-axis pointing to the right, must be valid
230 * @param anyCameraA The first camera profile, must be valid
231 * @param anyCameraB The second camera profile, must be valid
232 * @param imagePointsA The set of 2D image points in the first image, each point must correspond to the point with the same index from the second image
233 * @param imagePointsB The set of 2D image points in the second image, each point must correspond to the point with the same index from the first image
234 * @param numberPoints The number of point correspondences, with range [0, infinity)
235 * @param onlyFrontObjectPoints If true, only points that are located in front of the camera will be used for the optimization, otherwise all points will be used.
236 * @param invalidObjectPoint Optional, the location of an invalid object point which will be used as value for all object points which cannot be determined e.g., because of parallel projection rays
237 * @param invalidIndices Optional, the resulting indices of the resulting object points with invalid location
238 * @return objectPoints The resulting triangulated object points
239 */
240 static Vectors3 triangulateImagePoints(const HomogenousMatrix4& world_T_cameraA, const HomogenousMatrix4& world_T_cameraB, const AnyCamera& anyCameraA, const AnyCamera& anyCameraB, const Vector2* imagePointsA, const Vector2* imagePointsB, const size_t numberPoints, const bool onlyFrontObjectPoints = true, const Vector3& invalidObjectPoint = Vector3(Numeric::minValue(), Numeric::minValue(), Numeric::minValue()), Indices32* invalidIndices = nullptr);
241
242 /**
243 * Calculates the 3D positions for a set of image point correspondences with corresponding poses (Rt) in inverted flipped camera system.
244 * This linear triangulation uses singular value decomposition.<br>
245 * If an object point cannot be determined than the resulting object point will have value (0, 0, 0).
246 * @param camera1 The camera profile used for the first image
247 * @param iFlippedPose1 Given projection matrix for the first camera
248 * @param camera2 The camera profile used for the second image
249 * @param iFlippedPose2 Given projection matrix for the second camera
250 * @param points1 Set of 2D image points in the first image, each point must correspond the one in the right image
251 * @param points2 Set of 2D image points in the second image
252 * @param correspondences Number of point correspondences, with range [1, infinity)
253 * @param invalidObjectPoint Optional, the location of an invalid object point which will be used as value for all object points which cannot be determined e.g., because of parallel projection rays
254 * @param invalidIndices Optional resulting indices of the resulting object points with invalid location
255 * @return objectPoints Resulting object points in inverted flipped coordinate space
256 */
257 static ObjectPoints triangulateImagePointsIF(const PinholeCamera& camera1, const HomogenousMatrix4& iFlippedPose1, const PinholeCamera& camera2, const HomogenousMatrix4& iFlippedPose2, const Vector2* points1, const Vector2* points2, const size_t correspondences, const Vector3& invalidObjectPoint = Vector3(Numeric::minValue(), Numeric::minValue(), Numeric::minValue()), Indices32* invalidIndices = nullptr);
258
259 /**
260 * Calculates the 3D positions for a set of image point correspondences in multiple views with corresponding camera projection matrices (K * Rt) or poses (Rt) in inverted flipped camera system.
261 * This linear triangulation uses singular value decomposition.
262 * @param posesIF Given poses or projection matrices per view
263 * @param imagePointsPerPose Set of 2D image points per the view, each point must correspond the one in the other views
264 * @param pinholeCamera The pinhole camera profile, one for all views. If no camera profile is given, posesIF act as projection matrices
265 * @param invalidObjectPoint Optional, the location of an invalid object point which will be used as value for all object points which cannot be determined e.g., because of parallel projection rays
266 * @param invalidIndices Optional resulting indices of the resulting object points with invalid location
267 * @return objectPoints Resulting object points in inverted flipped coordinates
268 */
269 static ObjectPoints triangulateImagePointsIF(const ConstIndexedAccessor<HomogenousMatrix4>& posesIF, const ConstIndexedAccessor<Vectors2>& imagePointsPerPose, const PinholeCamera* pinholeCamera = nullptr, const Vector3& invalidObjectPoint = Vector3(Numeric::minValue(), Numeric::minValue(), Numeric::minValue()), Indices32* invalidIndices = nullptr);
270
271 protected:
272
273 /**
274 * Calculates the essential matrix based on corresponding viewing rays from the 'left' and 'right' camera.
275 * This function implements the 8-point algorithm based on corresponding viewing rays.
276 * The resulting essential matrix is defined by the following equation:
277 * <pre>
278 * rightViewingRay^T * normalizedRight_E_normalizedLeft * leftViewingRay = 0
279 * </pre>
280 * The normalized image points are defined in the flipped camera, with default flipped camera pointing towards the positive z-space with y-axis upwards.
281 * @param leftImageRays Three 3D rays with unit length, defined in the coordinate system of the left camera, starting at the camera's center of projection (equal to the origin) and hitting the image plane at a known image points
282 * @param rightImageRays The 3D rays with unit length, defined in the coordinate system of the right camera, starting at the camera's center of projection (equal to the origin) and hitting the image plane at a known image points, one for each left image ray
283 * @param correspondences The number of bearing vector correspondences, with range [8, infinity)
284 * @param normalizedRight_E_normalizedLeft The resulting essential matrix
285 * @return True, if succeeded
286 * @tparam tRaysAreFlipped True, to interpret the rays as flipped (pointing towards the positive z-space with y-axis upwards); False, to interpret the rays as normal (pointing towards the negative z space with y-axis downwards)
287 */
288 template <bool tRaysAreFlipped>
289 static bool essentialMatrix(const Vector3* leftImageRays, const Vector3* rightImageRays, const size_t correspondences, SquareMatrix3& normalizedRight_E_normalizedLeft);
290
291 /**
292 * Returns the number of 3D object points lying in front of two cameras for a given transformation between the two cameras.
293 * The pose of the first camera is located in the origin (identity transformation) while the pose of the second camera is defined by the given transformation.
294 * @param leftCamera_T_rightCamera The transformation between the right and the left camera, must be valid
295 * @param leftCamera The left camera profile defining the projection, must be valid
296 * @param rightCamera The right camera profile defining the projection, must be valid
297 * @param leftPoints The left image points, must be valid if correspondences != 0
298 * @param rightPoints The right image points, one for each left point, must be valid if correspondences != 0
299 * @param correspondences The number of provided point correspondences, with range [0, infinity)
300 * @return Number of valid object points, with range [0, correspondences]
301 */
302 static size_t validateCameraPose(const HomogenousMatrix4& leftCamera_T_rightCamera, const PinholeCamera& leftCamera, const PinholeCamera& rightCamera, const Vector2* leftPoints, const Vector2* rightPoints, const size_t correspondences);
303
304 /**
305 * Converts a epipolar line to a line object.
306 * @param line The epipolar line to be converted
307 * @return Resulting line object
308 */
309 static inline Line2 epipolarLine2Line(const Vector3& line);
310};
311
313{
314 return fundamental.transposed();
315}
316
317inline Line2 EpipolarGeometry::leftEpipolarLine(const SquareMatrix3& fundamental, const Vector2& rightPoint)
318{
319 return epipolarLine2Line(fundamental.transposed() * Vector3(rightPoint, 1));
320}
321
322inline Line2 EpipolarGeometry::rightEpipolarLine(const SquareMatrix3& fundamental, const Vector2& leftPoint)
323{
324 return epipolarLine2Line(fundamental * Vector3(leftPoint, 1));
325}
326
328{
329 const Vector2 normal(line[0], line[1]);
330 ocean_assert(!normal.isNull());
331
332 const Scalar normalLength = normal.length();
333 ocean_assert(Numeric::isNotEqualEps(normalLength));
334
335 /*const Scalar distance = normalLength * line[2];
336 const Scalar factor = 1 / normalLength;*/
337
338 return Line2(line / normalLength);
339
340 //return Line2(Vector3(normal.x() * factor, normal.y() * factor, distance *));
341}
342
343}
344
345}
346
347#endif // META_OCEAN_GEOMETRY_EPIPOLAR_GEOMETRY_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
This class implements epipolar geometry functions.
Definition EpipolarGeometry.h:33
static bool fundamentalMatrix(const Vector2 *leftPoints, const Vector2 *rightPoints, const size_t correspondences, SquareMatrix3 &right_F_left)
Calculates the fundamental matrix based on corresponding image points in a 'left' and in a 'right' ca...
static Line2 leftEpipolarLine(const SquareMatrix3 &fundamental, const Vector2 &rightPoint)
Returns the epipolar line in the left image corresponding to a given point in the right image.
Definition EpipolarGeometry.h:317
static Vectors3 triangulateImagePoints(const HomogenousMatrix4 &world_T_cameraA, const HomogenousMatrix4 &world_T_cameraB, const AnyCamera &anyCameraA, const AnyCamera &anyCameraB, const Vector2 *imagePointsA, const Vector2 *imagePointsB, const size_t numberPoints, const bool onlyFrontObjectPoints=true, const Vector3 &invalidObjectPoint=Vector3(Numeric::minValue(), Numeric::minValue(), Numeric::minValue()), Indices32 *invalidIndices=nullptr)
Calculates the 3D positions for a pair of image point correspondences with corresponding extrinsic ca...
static bool epipoles(const HomogenousMatrix4 &extrinsic, const SquareMatrix3 &leftIntrinsic, const SquareMatrix3 &rightIntrinsic, Vector2 &leftEpipole, Vector2 &rightEpipole)
Determines the two epipoles corresponding to two cameras separated by an extrinsic camera matrix.
static Line2 epipolarLine2Line(const Vector3 &line)
Converts a epipolar line to a line object.
Definition EpipolarGeometry.h:327
static bool essentialMatrix(const Vector3 *leftImageRays, const Vector3 *rightImageRays, const size_t correspondences, SquareMatrix3 &normalizedRight_E_normalizedLeft)
Calculates the essential matrix based on corresponding viewing rays from the 'left' and 'right' camer...
static Line2 rightEpipolarLine(const SquareMatrix3 &fundamental, const Vector2 &leftPoint)
Returns the epipolar line in the right image corresponding to a given point in the left image.
Definition EpipolarGeometry.h:322
static SquareMatrix3 reverseFundamentalMatrix(const SquareMatrix3 &right_F_left)
Returns the reverted fundamental matrix.
Definition EpipolarGeometry.h:312
static bool essentialMatrix(const Vector3 *leftImageRays, const Vector3 *rightImageRays, const size_t correspondences, SquareMatrix3 &normalizedRight_E_normalizedLeft)
Calculates the essential matrix based on corresponding viewing rays from the 'left' and 'right' camer...
static bool epipoles(const SquareMatrix3 &right_F_left, Vector2 &leftEpipole, Vector2 &rightEpipole)
Determines the two epipoles corresponding to a fundamental matrix.
static ObjectPoints triangulateImagePointsIF(const ConstIndexedAccessor< HomogenousMatrix4 > &posesIF, const ConstIndexedAccessor< Vectors2 > &imagePointsPerPose, const PinholeCamera *pinholeCamera=nullptr, const Vector3 &invalidObjectPoint=Vector3(Numeric::minValue(), Numeric::minValue(), Numeric::minValue()), Indices32 *invalidIndices=nullptr)
Calculates the 3D positions for a set of image point correspondences in multiple views with correspon...
static bool epipolesFast(const SquareMatrix3 &fundamental, Vector2 &leftEpipole, Vector2 &rightEpipole)
Finds the two epipoles corresponding to a fundamental matrix.
static SquareMatrix3 essential2fundamental(const SquareMatrix3 &normalizedRight_E_normalizedLeft, const SquareMatrix3 &leftIntrinsic, const SquareMatrix3 &rightIntrinsic)
Calculates the fundamental matrix from a given essential matrix and the two intrinsic camera matrices...
static size_t validateCameraPose(const HomogenousMatrix4 &leftCamera_T_rightCamera, const PinholeCamera &leftCamera, const PinholeCamera &rightCamera, const Vector2 *leftPoints, const Vector2 *rightPoints, const size_t correspondences)
Returns the number of 3D object points lying in front of two cameras for a given transformation betwe...
static SquareMatrix3 fundamental2essential(const SquareMatrix3 &right_F_left, const PinholeCamera &leftCamera, const PinholeCamera &rightCamera)
Calculates the essential matrix by the given fundamental matrix and the two cameras.
static SquareMatrix3 essentialMatrix(const HomogenousMatrix4 &rightCamera_T_leftCamera)
Calculates the essential matrix based on 6-DOF camera pose between two cameras.
static bool essentialMatrixF(const Vector3 *flippedLeftImageRays, const Vector3 *flippedRightImageRays, const size_t correspondences, SquareMatrix3 &normalizedRight_E_normalizedLeft)
Calculates the essential matrix based on corresponding viewing rays from the 'left' and 'right' camer...
static SquareMatrix3 essential2fundamental(const SquareMatrix3 &normalizedRight_E_normalizedLeft, const PinholeCamera &leftCamera, const PinholeCamera &rightCamera)
Calculates the fundamental matrix from a given essential matrix and the two intrinsic camera matrices...
static bool rectificationHomography(const HomogenousMatrix4 &transformation, const PinholeCamera &pinholeCamera, SquareMatrix3 &leftHomography, SquareMatrix3 &rightHomography, Quaternion &appliedRotation, PinholeCamera *newCamera)
Determines the homograph for two (stereo) frames rectifying both images using the transformation betw...
static SquareMatrix3 fundamental2essential(const SquareMatrix3 &right_F_left, const SquareMatrix3 &leftIntrinsic, const SquareMatrix3 &rightIntrinsic)
Calculates the essential matrix from a given fundamental matrix and the two intrinsic camera matrices...
static ObjectPoints triangulateImagePointsIF(const PinholeCamera &camera1, const HomogenousMatrix4 &iFlippedPose1, const PinholeCamera &camera2, const HomogenousMatrix4 &iFlippedPose2, const Vector2 *points1, const Vector2 *points2, const size_t correspondences, const Vector3 &invalidObjectPoint=Vector3(Numeric::minValue(), Numeric::minValue(), Numeric::minValue()), Indices32 *invalidIndices=nullptr)
Calculates the 3D positions for a set of image point correspondences with corresponding poses (Rt) in...
static size_t factorizeEssential(const SquareMatrix3 &normalizedRight_E_normalizedLeft, const PinholeCamera &leftCamera, const PinholeCamera &rightCamera, const Vector2 *leftPoints, const Vector2 *rightPoints, const size_t correspondences, HomogenousMatrix4 &left_T_right)
Factorizes an essential matrix into a 6-DOF camera pose composed of rotation and translation.
This class implements an infinite line in 2D space.
Definition Line2.h:83
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2246
SquareMatrixT3< T > transposed() const
Returns the transposed of this matrix.
Definition SquareMatrix3.h:1145
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition Vector2.h:746
T length() const
Returns the length of the vector.
Definition Vector2.h:627
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< ObjectPoint > ObjectPoints
Definition of a vector holding 3D object points.
Definition geometry/Geometry.h:129
LineT2< Scalar > Line2
Definition of the Line2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single o...
Definition Line2.h:28
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
The namespace covering the entire Ocean framework.
Definition Accessor.h:15