Ocean
P4P.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_P4P_H
9 #define META_OCEAN_GEOMETRY_P4P_H
10 
13 
14 #include "ocean/math/AnyCamera.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Geometry
20 {
21 
22 /**
23  * This class provides functions determining the camera's pose by a set of four 3D object and 2D image points.
24  * @ingroup geometry
25  */
26 class OCEAN_GEOMETRY_EXPORT P4P : public PerspectivePose
27 {
28  public:
29 
30  /**
31  * Calculates the pose of a camera by a set of four image and object points.
32  * @param camera The camera profile defining the projection, must be valid
33  * @param objectPoints Four 3D object points, defined in world, must be valid
34  * @param imagePoints Four 2D image points, one for each 3D object point, must be valid
35  * @param world_T_camera Resulting camera pose, with default camera pointing towards the negative z-space, with y-axis upwards
36  * @return True, if succeeded
37  */
38  static bool pose(const AnyCamera& camera, const Vector3* objectPoints, const Vector2* imagePoints, HomogenousMatrix4& world_T_camera);
39 
40  protected:
41 
42  /**
43  * Calculates four distances between camera center and the four 3D object points.
44  * @param objectPoints Four object points, must be valid
45  * @param imageRays Three 3D rays with unit length, defined in the coordinate system of the camera, starting at the camera's center of projection (equal to the origin), hitting the image plane at image points corresponding to the 3D object points and pointing towards the object points, each ray corresponds to one 3D object point, must be valid
46  * @param distances The four resulting distances between camera center and each of the four object points
47  * @return True, if succeeded
48  */
49  static bool calculatePointDistances(const Vector3* objectPoints, const Vector3* imageRays, Scalar distances[4]);
50 };
51 
52 }
53 
54 }
55 
56 #endif // META_OCEAN_GEOMETRY_P4P_H
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
This class provides functions determining the camera's pose by a set of four 3D object and 2D image p...
Definition: P4P.h:27
static bool pose(const AnyCamera &camera, const Vector3 *objectPoints, const Vector2 *imagePoints, HomogenousMatrix4 &world_T_camera)
Calculates the pose of a camera by a set of four image and object points.
static bool calculatePointDistances(const Vector3 *objectPoints, const Vector3 *imageRays, Scalar distances[4])
Calculates four distances between camera center and the four 3D object points.
This class is the base class for all perspective pose classes.
Definition: PerspectivePose.h:27
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15