8 #ifndef META_OCEAN_TRACKING_SPHERICAL_ENVIRONMENT_H
9 #define META_OCEAN_TRACKING_SPHERICAL_ENVIRONMENT_H
52 typedef std::unordered_map<uint32_t, uint32_t>
IndexMap;
67 class CameraOrientationsData;
77 class TransformationTableData2x2;
115 inline SphericalEnvironment(
const unsigned int panoramaDimensionWidth,
const unsigned int panoramaDimensionHeight,
const uint8_t maskValue,
const UpdateMode frameMode);
191 static bool determinePointCorrespondencesHomography(
const CV::FramePyramid& sourceFramePyramid,
const Frame& targetFrame,
const SquareMatrix3& homography,
const Vectors2& sourcePointCandidates,
Vectors2& validSourcePoints,
Vectors2& validTargetPoints,
Indices32& validSourcePointIndices,
const unsigned int patchSize,
const unsigned int maximalDistance = 32u,
const unsigned int coarsestLayerRadius = 8u,
const CV::FramePyramid::DownsamplingMode downsamplingMode =
CV::FramePyramid::DM_FILTER_14641,
Worker* worker =
nullptr,
size_t* usedPointCandidates =
nullptr);
237 static bool optimizeCamera(
const PinholeCamera& pinholeCamera,
const SquareMatrices3& orientations,
const ImagePoints& imagePoints,
const PoseImagePointPairGroups& orientationImagePointPairGroups,
PinholeCamera& optimizedCamera,
SquareMatrices3& optimizedOrientations,
const unsigned int iterations = 20u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
Scalar lambda =
Scalar(0.001),
const Scalar lambdaFactor =
Scalar(5),
Scalar* initialError =
nullptr,
Scalar* finalError =
nullptr,
Scalars* intermediateErrors =
nullptr);
271 static bool determineTransformationTable2x2(
const unsigned int width,
const unsigned int height,
const Vectors2& points0,
const Vectors2& points1,
LookupCorner2<Vector2>& transformation0to1,
const unsigned int iterations = 20u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
Scalar lambda =
Scalar(0.001),
const Scalar lambdaFactor =
Scalar(5),
Scalar* initialError =
nullptr,
Scalar* finalError =
nullptr);
283 template <
unsigned int tSize>
298 template <
unsigned int tChannels,
unsigned int tSize>
314 template <
unsigned int tChannels,
unsigned int tSize>
315 static void interpolateSquarePatches8BitPerChannelSubset(
const uint8_t* frame,
const unsigned int width,
const unsigned int height,
const unsigned int framePaddingElements,
const Vector2* positions, uint8_t* result,
const unsigned int firstPosition,
const unsigned int numberPositions);
335 template <
unsigned int tSize>
336 static IndexPairs32 findBijectiveCorrespondences(
const PinholeCamera& camera0,
const PinholeCamera& camera1,
const FrameType::PixelFormat pixelFormat,
const SquareMatrix3& orientation0,
const SquareMatrix3& orientation1,
const Buffer& buffer0,
const Buffer& buffer1,
const Vectors2& points0,
const Vectors2& points1,
const Geometry::SpatialDistribution::DistributionArray& distribution0,
const Geometry::SpatialDistribution::DistributionArray& distribution1,
Worker* worker);
356 template <
unsigned int tChannels,
unsigned int tSize>
357 static IndexPairs32 findBijectiveCorrespondences8BitPerChannel(
const PinholeCamera& camera0,
const PinholeCamera& camera1,
const SquareMatrix3& orientation0,
const SquareMatrix3& orientation1,
const uint8_t* datas0,
const uint8_t* datas1,
const Vectors2& points0,
const Vectors2& points1,
const Geometry::SpatialDistribution::DistributionArray& distribution0,
const Geometry::SpatialDistribution::DistributionArray& distribution1,
Worker* worker);
377 template <
unsigned int tChannels,
unsigned int tSize>
378 static IndexPairs32 findBidirectionalCorrespondences8BitPerChannel(
const PinholeCamera& camera0,
const PinholeCamera& camera1,
const SquareMatrix3& orientation0,
const SquareMatrix3& orientation1,
const uint8_t* datas0,
const uint8_t* datas1,
const Vectors2& points0,
const Vectors2& points1,
const Geometry::SpatialDistribution::DistributionArray& distribution0,
const Geometry::SpatialDistribution::DistributionArray& distribution1,
Worker* worker);
400 template <
unsigned int tChannels,
unsigned int tSize>
401 static void findBidirectionalCorrespondences8BitPerChannelSubset(
const PinholeCamera* camera0,
const PinholeCamera* camera1,
const SquareMatrix3* orientation0,
const SquareMatrix3* orientation1,
const uint8_t* datas0,
const uint8_t* datas1,
const Vectors2* points0,
const Vectors2* points1,
const Geometry::SpatialDistribution::DistributionArray* distribution0,
const Geometry::SpatialDistribution::DistributionArray* distribution1,
Lock* lock,
IndexPairs32* results,
const unsigned int firstPoint,
const unsigned int numberPoints);
412 template <
unsigned int tChannels,
unsigned int tSize>
440 static inline uint64_t uniqueFeaturePointId(
const uint32_t frameIndex,
const uint32_t pointIndex);
447 static inline uint32_t frameIndex(
const uint64_t
id);
454 static inline uint32_t pointIndex(
const uint64_t
id);
472 CV::Advanced::PanoramaFrame(dimensionWidth, dimensionHeight, maskValue, updateMode),
473 initialOrientation_(true),
474 previousOrientation_(false)
486 return uint32_t(
id >> 32ull);
491 return uint32_t(
id & 0xFFFFFFFFull);
This class implements a panorama frame with spherical projection model.
Definition: PanoramaFrame.h:47
UpdateMode
Definition of individual frame update modes.
Definition: PanoramaFrame.h:54
This class implements a frame pyramid.
Definition: FramePyramid.h:37
DownsamplingMode
Definition of individual down sampling modes.
Definition: FramePyramid.h:44
@ DM_FILTER_14641
Down sampling is realized by a 5x5 Gaussian filter.
Definition: FramePyramid.h:72
This class implements a container for callback functions.
Definition: Callback.h:3456
This class implements Ocean's image class.
Definition: Frame.h:1792
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
@ ET_INVALID
An invalid estimator type.
Definition: Estimator.h:38
This class implements a distribution array.
Definition: SpatialDistribution.h:228
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a 2D lookup object with values at the bins' corners defining the individual loo...
Definition: Lookup2.h:636
static constexpr T deg2rad(const T deg)
Converts deg to rad.
Definition: Numeric.h:3232
This class implements a spherical environment based on a panorama frame.
Definition: SphericalEnvironment.h:36
static FeaturePointMap::const_iterator determineSiblings(const FeaturePointMap &correspondences, const FeaturePointMap::const_iterator &iStart, UnorderedIndexSet64 &siblings, UnorderedIndexSet64 &usedSet, IndexMap &frameSet)
Determines all sibling image point correspondences for a given correspondence.
std::vector< IndexPairs32 > PoseImagePointPairGroups
Definition of a vector holding groups of pairs between camera pose ids and image point ids.
Definition: SphericalEnvironment.h:99
virtual void clear()
Clears the panorama frame and allows to set a new first camera frame.
std::vector< uint8_t > Buffer
Definition of a vector holding 8 bit characters.
Definition: SphericalEnvironment.h:42
static bool optimizeCamera(const PinholeCamera &pinholeCamera, const Frames &frames, const SquareMatrices3 &orientations, PinholeCamera &optimizedCamera, Worker *worker=nullptr)
Optimizes the camera profile for a given set of camera frames with known orientations so that the off...
SphericalEnvironment()=default
Creates an invalid spherical environment object.
static bool determinePointCorrespondencesHomography(const CV::FramePyramid &sourceFramePyramid, const Frame &targetFrame, const SquareMatrix3 &homography, const Vectors2 &sourcePointCandidates, Vectors2 &validSourcePoints, Vectors2 &validTargetPoints, Indices32 &validSourcePointIndices, const unsigned int patchSize, const unsigned int maximalDistance=32u, const unsigned int coarsestLayerRadius=8u, const CV::FramePyramid::DownsamplingMode downsamplingMode=CV::FramePyramid::DM_FILTER_14641, Worker *worker=nullptr, size_t *usedPointCandidates=nullptr)
Determines point correspondences between two camera frames captured with individual locations (descri...
static void interpolateSquarePatches8BitPerChannelSubset(const uint8_t *frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const Vector2 *positions, uint8_t *result, const unsigned int firstPosition, const unsigned int numberPositions)
Interpolates a subset of square image patches with sub-pixel position and stores the image content as...
std::multimap< uint64_t, uint64_t > FeaturePointMap
Definition of a map mapping unique frame-feature-point-ids to unique frame-feature-point-ids.
Definition: SphericalEnvironment.h:57
Callback< bool, const CV::FramePyramid &, const CV::FramePyramid &, const PinholeCamera &, const PinholeCamera &, const SquareMatrix3 &, const SquareMatrix3 &, const uint8_t, Frame &, Worker * > FrameCallback
Definition of a callback function allowing to determine an update mask for a current camera frame.
Definition: SphericalEnvironment.h:77
CV::FramePyramid previousFramePyramid_
The frame pyramid of the most recent frame.
Definition: SphericalEnvironment.h:468
static IndexPairs32 findBidirectionalCorrespondences8BitPerChannel(const PinholeCamera &camera0, const PinholeCamera &camera1, const SquareMatrix3 &orientation0, const SquareMatrix3 &orientation1, const uint8_t *datas0, const uint8_t *datas1, const Vectors2 &points0, const Vectors2 &points1, const Geometry::SpatialDistribution::DistributionArray &distribution0, const Geometry::SpatialDistribution::DistributionArray &distribution1, Worker *worker)
Finds bidirectional point correspondences between two given camera frames with eight bit per channel ...
std::unordered_map< uint32_t, uint32_t > IndexMap
Definition of a map mapping indices.
Definition: SphericalEnvironment.h:52
static bool findInitialFieldOfView(const unsigned int width, const unsigned int height, const SquareMatrices3 &orientations, const ImagePoints &imagePoints, const PoseImagePointPairGroups &orientationImagePointPairGroups, PinholeCamera &optimizedCamera, SquareMatrices3 &optimizedOrientations, const Scalar lowerFovX=Numeric::deg2rad(40), const Scalar upperFovX=Numeric::deg2rad(90), const unsigned int steps=10u)
Determines the initial field of view for a set of camera frames with known orientation and a correspo...
static Buffer interpolateSquarePatches(const Frame &frame, const Vectors2 &positions, Worker *worker=nullptr)
Interpolates square image patches with sub-pixel position and stores the image content as patch buffe...
static void findBidirectionalCorrespondences8BitPerChannelSubset(const PinholeCamera *camera0, const PinholeCamera *camera1, const SquareMatrix3 *orientation0, const SquareMatrix3 *orientation1, const uint8_t *datas0, const uint8_t *datas1, const Vectors2 *points0, const Vectors2 *points1, const Geometry::SpatialDistribution::DistributionArray *distribution0, const Geometry::SpatialDistribution::DistributionArray *distribution1, Lock *lock, IndexPairs32 *results, const unsigned int firstPoint, const unsigned int numberPoints)
Finds subsets of bidirectional point correspondences between two given camera frames with eight bit p...
bool optimizeOrientation(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, const Frame &frame, const Frame &mask, const Geometry::Estimator::EstimatorType estimator, SquareMatrix3 &optimizedOrientation, PinholeCamera *optimizedCamera=nullptr, LookupTable *fineAdjustment=nullptr, const unsigned int approximationBinSize=20u, Worker *worker=nullptr)
Determines the precise orientation of a given camera frame.
static bool determinePointCorrespondencesHomography(const Frame &sourceFrame, const Frame &targetFrame, const SquareMatrix3 &homography, Vectors2 &sourcePoints, Vectors2 &targetPoints, const unsigned int patchSize, const unsigned int maximalDistance=32u, const unsigned int coarsestLayerRadius=8u, const CV::FramePyramid::DownsamplingMode downsamplingMode=CV::FramePyramid::DM_FILTER_14641, Worker *worker=nullptr)
Determines point correspondences between two camera frames captured with individual locations (descri...
static bool optimizeCamera(const PinholeCamera &pinholeCamera, const SquareMatrices3 &orientations, const ImagePoints &imagePoints, const PoseImagePointPairGroups &orientationImagePointPairGroups, PinholeCamera &optimizedCamera, SquareMatrices3 &optimizedOrientations, const unsigned int iterations=20u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the camera profile for a given set of image points from individual camera frames so that th...
static unsigned int findCorrespondingPoint8BitPerChannel(const uint8_t *data0, const uint8_t *datas1, const Indices32 &indices)
Finds a corresponding patch for a given patch from a second set of patches.
bool extendEnvironment(const PinholeCamera &pinholeCamera, const Frame &frame, const unsigned int approximationBinSize=20u, const Geometry::Estimator::EstimatorType fineAdjustmentEstimator=Geometry::Estimator::ET_INVALID, const bool optimizeCamera=false, Worker *worker=nullptr, SquareMatrix3 *orientation=nullptr, PinholeCamera *optimizedCamera=nullptr, const FrameCallback &frameCallback=FrameCallback())
Adds a new camera frame to the panorama frame for which the orientation is unknown.
static IndexPairs32 findBijectiveCorrespondences8BitPerChannel(const PinholeCamera &camera0, const PinholeCamera &camera1, const SquareMatrix3 &orientation0, const SquareMatrix3 &orientation1, const uint8_t *datas0, const uint8_t *datas1, const Vectors2 &points0, const Vectors2 &points1, const Geometry::SpatialDistribution::DistributionArray &distribution0, const Geometry::SpatialDistribution::DistributionArray &distribution1, Worker *worker)
Finds unique bijective point correspondences between two given camera frames with eight bit per chann...
static void interpolateSquarePatches8BitPerChannel(const uint8_t *frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const Vectors2 &positions, uint8_t *result, Worker *worker=nullptr)
Interpolates square image patches with sub-pixel position and stores the image content as patch buffe...
std::vector< Buffer > Buffers
Definition of a vector holding buffers.
Definition: SphericalEnvironment.h:47
static bool nonHomographyMask(const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid ¤tFramePyramid, const PinholeCamera &previousCamera, const PinholeCamera ¤tCamera, const SquareMatrix3 &previousOrientation, const SquareMatrix3 ¤tOrientation, const uint8_t maskValue, Frame ¤tMask, Worker *worker=nullptr)
This function determines a mask for image areas not matching with the common homography between two s...
static uint64_t uniqueFeaturePointId(const uint32_t frameIndex, const uint32_t pointIndex)
Creates a unique ids for a given frame index and points index located in the frame.
Definition: SphericalEnvironment.h:479
static IndexPairs32 findBijectiveCorrespondences(const PinholeCamera &camera0, const PinholeCamera &camera1, const FrameType::PixelFormat pixelFormat, const SquareMatrix3 &orientation0, const SquareMatrix3 &orientation1, const Buffer &buffer0, const Buffer &buffer1, const Vectors2 &points0, const Vectors2 &points1, const Geometry::SpatialDistribution::DistributionArray &distribution0, const Geometry::SpatialDistribution::DistributionArray &distribution1, Worker *worker)
Finds unique bijective point correspondences between two given camera frames from a set of already de...
static uint32_t frameIndex(const uint64_t id)
Extracts the frame index of a unique feature point id.
Definition: SphericalEnvironment.h:484
static bool determineTransformationTable2x2(const unsigned int width, const unsigned int height, const Vectors2 &points0, const Vectors2 &points1, LookupCorner2< Vector2 > &transformation0to1, const unsigned int iterations=20u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Determines a 2x2 transformation table (a lookup table) transforming a set of points (defined in the d...
static uint32_t pointIndex(const uint64_t id)
Extracts the point index of a unique feature point id.
Definition: SphericalEnvironment.h:489
PinholeCamera previousCamera_
The camera profile of the most recent frame.
Definition: SphericalEnvironment.h:465
static std::vector< Indices64 > determineFeaturePointsFromPointCloud(const FeaturePointMap &correspondences, const unsigned int minSiblings=0u)
Determines a set of corresponding image points representing the same unique feature point (only obser...
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
std::vector< IndexPair32 > IndexPairs32
Definition of a vector holding 32 bit index pairs.
Definition: Base.h:144
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition: Frame.h:1755
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
std::unordered_set< Index64 > UnorderedIndexSet64
Definition of an unordered_set holding 64 bit indices.
Definition: Base.h:132
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition: SquareMatrix3.h:35
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
std::vector< SquareMatrix3 > SquareMatrices3
Definition of a vector holding SquareMatrix3 objects.
Definition: SquareMatrix3.h:71
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition: Tracking.h:55
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15