Ocean
Loading...
Searching...
No Matches
VanishingProjection.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_VANISHING_PROJECTION_H
9#define META_OCEAN_GEOMETRY_VANISHING_PROJECTION_H
10
12
13#include "ocean/base/Accessor.h"
14
16#include "ocean/math/Vector2.h"
17#include "ocean/math/Vector3.h"
18
19namespace Ocean
20{
21
22namespace Geometry
23{
24
25/**
26 * This class implements functions for vanishing projections.
27 * @ingroup geometry
28 */
29class OCEAN_GEOMETRY_EXPORT VanishingProjection
30{
31 public:
32
33 /**
34 * Calculates the normal of a plane that is determined by four given image points defining a parallelogram and all lying on the same 3D plane.
35 * The resulting normal is defined in the coordinate system of the camera which is located in the origin and locking along the negative z-axis, with y-axis as up vector.<br>
36 * @param pinholeCamera The pinhole camera profile to be applied
37 * @param parallelogramPoints The four corners of the parallelogram visible in the camera frame
38 * @param undistortImagePoints True, so that the given image points will be undistorted before the normal is calculated
39 * @param normal Resulting normal of the plane
40 * @return True, if succeeded
41 */
42 static bool planeNormal(const PinholeCamera& pinholeCamera, const Vector2 parallelogramPoints[4], const bool undistortImagePoints, Vector3& normal);
43
44 /**
45 * Determines the vanishing line for four given (undistorted) image points defining a parallelogram that lies in a 3D plane.
46 * @param parallelogramPoints Four (undistorted) image points defining a parallelogram
47 * @param line Resulting vanishing line
48 * @return True, if succeeded
49 */
50 static bool vanishingLine(const Vector2 parallelogramPoints[4], Line2& line);
51
52 /**
53 * Determines the largest subset of perspectively parallel lines from a set of given infinite lines.
54 * The lines may be absolute parallel or may have a common vanishing point.
55 * @param lines The lines from which the largest group of (perspectively) parallel lines will be determined
56 * @param projectiveParallelAngle The maximal angle between two projected lines (actually the given lines interpreted in the coordinate system of the frame) count as parallel, in radian with range [0, PI/2)
57 * @param orientationError The expected orientation error each provided line can have e.g., due to measurement/detection inaccuracies, in radian with range [0, PI/2)
58 * @param maximalAngle The maximal angle between two lines so that they still count as perspectively parallel, in radian with range (max(orientationError, projectiveParallelAngle), PI/2)
59 * @return The indices of the requested lines out of the given group of lines
60 */
61 static Indices32 perspectiveParallelLines(const ConstIndexedAccessor<Line2>& lines, const Scalar projectiveParallelAngle = Numeric::deg2rad(5), const Scalar orientationError = Numeric::deg2rad(2), const Scalar maximalAngle = Numeric::deg2rad(35));
62};
63
64}
65
66}
67
68#endif // META_OCEAN_GEOMETRY_VANISHING_PROJECTION_H
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
This class implements functions for vanishing projections.
Definition VanishingProjection.h:30
static Indices32 perspectiveParallelLines(const ConstIndexedAccessor< Line2 > &lines, const Scalar projectiveParallelAngle=Numeric::deg2rad(5), const Scalar orientationError=Numeric::deg2rad(2), const Scalar maximalAngle=Numeric::deg2rad(35))
Determines the largest subset of perspectively parallel lines from a set of given infinite lines.
static bool vanishingLine(const Vector2 parallelogramPoints[4], Line2 &line)
Determines the vanishing line for four given (undistorted) image points defining a parallelogram that...
static bool planeNormal(const PinholeCamera &pinholeCamera, const Vector2 parallelogramPoints[4], const bool undistortImagePoints, Vector3 &normal)
Calculates the normal of a plane that is determined by four given image points defining a parallelogr...
This class implements an infinite line in 2D space.
Definition Line2.h:83
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15