Ocean
Loading...
Searching...
No Matches
Disparity.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_CV_DEPTH_DISPARITY_H
9#define META_OCEAN_CV_DEPTH_DISPARITY_H
10
12
13#include "ocean/base/Frame.h"
14
15#include "ocean/math/Numeric.h"
16
17namespace Ocean
18{
19
20namespace CV
21{
22
23namespace Depth
24{
25
26/**
27 * This class implements disparity functions.
28 * @ingroup cvdepth
29 */
30class OCEAN_CV_DEPTH_EXPORT Disparity
31{
32 public:
33
34 /**
35 * Fills holes in a disparity map.
36 * @param disparityMap The disparity map to be filled
37 * @return True, if succeeded
38 */
39 static bool fillHolesDisparityMap(Frame& disparityMap);
40
41 /**
42 * Merges a given set of disparity maps into a single disparity map.
43 * The merged disparity map will hold NaN values whenever input is invalid or the specified threshold don't hold.
44 * @param disparityMaps The disparity maps to merge, at least two
45 * @param inlierThreshold The maximal distance to median value to be considered inlier, with range [0, infinity)
46 * @param minInliers The minimal number of inliers required, with range [1, infinity)
47 * @param mergedDisparityMap The resulting disparity map
48 * @return True, if succeeded
49 */
50 static bool mergeDisparityMaps(const Frames& disparityMaps, const double inlierThreshold, const size_t minInliers, Frame& mergedDisparityMap);
51
52 protected:
53
54 /**
55 * Fills holes in a disparity map.
56 * @param disparityMap The disparity map to be filled
57 * @return True, if succeeded
58 * @tparam T The data type of the disparity elements, e.g., 'float' or 'double'
59 */
60 template <typename T>
61 static bool fillHolesDisparityMap(Frame& disparityMap);
62
63 /**
64 * Merges a given set of disparity maps into a single disparity map.
65 * @param disparityMaps The disparity maps to merge, at least two
66 * @param inlierThreshold The maximal distance to median value to be considered inlier, with range [0, infinity)
67 * @param minInliers The minimal number of inliers required, with range [1, infinity)
68 * @param mergedDisparityMap The resulting disparity map
69 * @return True, if succeeded
70 * @tparam T The data type of the disparity elements, e.g., 'float' or 'double'
71 */
72 template <typename T>
73 static bool mergeDisparityMaps(const Frames& disparityMaps, const double inlierThreshold, const size_t minInliers, Frame& mergedDisparityMap);
74
75 /**
76 * Returns whether a given value is valid number (whether it is not NaN and finite).
77 * @param value The value to check
78 * @return True, if so
79 * @tparam T The data type of the value to check
80 */
81 template <typename T>
82 static inline bool isValid(const T& value);
83};
84
85template <typename T>
86inline bool Disparity::isValid(const T& value)
87{
88 return !NumericT<T>::isNan(value) && !NumericT<T>::isInf(value);
89}
90
91}
92
93}
94
95}
96
97#endif // META_OCEAN_CV_DEPTH_DISPARITY_H
This class implements disparity functions.
Definition Disparity.h:31
static bool mergeDisparityMaps(const Frames &disparityMaps, const double inlierThreshold, const size_t minInliers, Frame &mergedDisparityMap)
Merges a given set of disparity maps into a single disparity map.
static bool mergeDisparityMaps(const Frames &disparityMaps, const double inlierThreshold, const size_t minInliers, Frame &mergedDisparityMap)
Merges a given set of disparity maps into a single disparity map.
static bool fillHolesDisparityMap(Frame &disparityMap)
Fills holes in a disparity map.
static bool isValid(const T &value)
Returns whether a given value is valid number (whether it is not NaN and finite).
Definition Disparity.h:86
static bool fillHolesDisparityMap(Frame &disparityMap)
Fills holes in a disparity map.
This class implements Ocean's image class.
Definition Frame.h:1808
static bool isInf(const T value)
Returns whether a given value is positive or negative infinity.
Definition Numeric.h:3111
static bool isNan(const T value)
Returns whether a given value is not a number.
Definition Numeric.h:3021
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition Frame.h:1771
The namespace covering the entire Ocean framework.
Definition Accessor.h:15