Ocean
MultiViewPlaneFinder.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_TRACKING_MULTI_VIEW_PLANE_FINDER_H
9 #define META_OCEAN_TRACKING_MULTI_VIEW_PLANE_FINDER_H
10 
13 
14 #include "ocean/base/Accessor.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Tracking
20 {
21 
22 /**
23  * This class implements a 3D plane finder that determines a plane within several frames taken from different camera positions.
24  * @ingroup tracking
25  */
26 class OCEAN_TRACKING_EXPORT MultiViewPlaneFinder : public PlaneFinder
27 {
28  public:
29 
30  /**
31  * Determines the initial 3D plane and the corresponding 6DOF poses of the camera.
32  * The plane and camera positions can be determined only up to an unknown scale factor.<br>
33  * This function needs at least two corresponding sets of image points.<br>
34  * @param pinholeCamera The pinhole camera object that is applied for the projection
35  * @param plane Resulting 3D plane
36  * @param poses Resulting poses that correspond to the given image points
37  * @param initialPose Pose of the first camera position
38  * @param initialPlane Initial plane that will be determined more accurate (the plane can be very rough while it should be in front of the initial pose)
39  * @return True, if succeeded
40  */
41  bool determinePlane(const PinholeCamera& pinholeCamera, Plane3& plane, HomogenousMatrices4& poses, const HomogenousMatrix4& initialPose = HomogenousMatrix4(Vector3(0, 0, 1)), const Plane3& initialPlane = Plane3(Vector3(0, 0, 1), 0)) const;
42 
43  /**
44  * Returns whether this plane finder object holds at least two sets of corresponding image points.
45  * @return True, if so
46  */
47  explicit inline operator bool() const;
48 
49  protected:
50 
51  /**
52  * Determines the initial plane from two individual views.
53  * @param pinholeCamera The pinhole camera object that is applied for the projection
54  * @param poseFirst First pose that is associated with the image points from the first view
55  * @param roughPlane Rough plane that should be a very rough guess of the resulting initial plane (at least the plane should lie in front of the camera)
56  * @param imagePointsFirst Image points in the first view associated with the first pose
57  * @param imagePointsSecond Image points in the second view associated with the resulting second pose, each point corresponds to a point in the first view (by index)
58  * @param poseSecond Resulting second pose
59  * @param plane Resulting initial plane best matching to the given image point correspondences
60  * @return True, if succeeded
61  */
62  static bool determinePlaneFromTwoViews(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& poseFirst, const Plane3& roughPlane, const ConstIndexedAccessor<Vector2>& imagePointsFirst, const ConstIndexedAccessor<Vector2>& imagePointsSecond, HomogenousMatrix4& poseSecond, Plane3& plane);
63 
64  /**
65  * Determines the poses that correspond to the given sets of image point correspondences and the given rough plane.
66  * @param pinholeCamera The pinhole camera object that is applied for the projection
67  * @param poseFirst First pose that is associated with the image points from the first view
68  * @param plane 3D plane on that all 3D object points visible in the first view are located
69  * @param imagePointsFirst Image points in the first view associated with the first pose
70  * @param imagePointsSuccessive The sets of image points visible in the successive views
71  * @param posesSuccessive Resulting poses for the successive views
72  * @return True, if succeeded
73  */
74  static bool determineInitialPoses(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& poseFirst, const Plane3& plane, const Vectors2& imagePointsFirst, const std::vector<Vectors2>& imagePointsSuccessive, HomogenousMatrices4& posesSuccessive);
75 };
76 
77 inline MultiViewPlaneFinder::operator bool() const
78 {
79  return imagePointCorrespondences.size() >= 2;
80 }
81 
82 }
83 
84 }
85 
86 #endif // META_OCEAN_TRACKING_MULTI_VIEW_PLANE_FINDER_H
This class implements a 3D plane finder that determines a plane within several frames taken from diff...
Definition: MultiViewPlaneFinder.h:27
static bool determineInitialPoses(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &poseFirst, const Plane3 &plane, const Vectors2 &imagePointsFirst, const std::vector< Vectors2 > &imagePointsSuccessive, HomogenousMatrices4 &posesSuccessive)
Determines the poses that correspond to the given sets of image point correspondences and the given r...
static bool determinePlaneFromTwoViews(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &poseFirst, const Plane3 &roughPlane, const ConstIndexedAccessor< Vector2 > &imagePointsFirst, const ConstIndexedAccessor< Vector2 > &imagePointsSecond, HomogenousMatrix4 &poseSecond, Plane3 &plane)
Determines the initial plane from two individual views.
bool determinePlane(const PinholeCamera &pinholeCamera, Plane3 &plane, HomogenousMatrices4 &poses, const HomogenousMatrix4 &initialPose=HomogenousMatrix4(Vector3(0, 0, 1)), const Plane3 &initialPlane=Plane3(Vector3(0, 0, 1), 0)) const
Determines the initial 3D plane and the corresponding 6DOF poses of the camera.
This class implements a 3D plane finder without any previous knowledge about the plane or the camera ...
Definition: PlaneFinder.h:32
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition: HomogenousMatrix4.h:73
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
PlaneT3< Scalar > Plane3
Definition of the Plane3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single ...
Definition: Plane3.h:24
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15