8#ifndef META_OCEAN_TRACKING_SPHERICAL_ENVIRONMENT_H
9#define META_OCEAN_TRACKING_SPHERICAL_ENVIRONMENT_H
52 using IndexMap = std::unordered_map<uint32_t, uint32_t>;
67 class CameraOrientationsData;
77 class TransformationTableData2x2;
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>
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>
447 static inline uint32_t
frameIndex(
const uint64_t
id);
454 static inline uint32_t
pointIndex(
const uint64_t
id);
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 updateMode() const
Returns the update mode of this panorama frame.
Definition PanoramaFrame.h:1154
LookupCorner2< Vector2 > LookupTable
Definition of a lookup table for 2D vectors.
Definition PanoramaFrame.h:72
const Frame & frame() const
Returns the current panorama sub-frame (not the maximal possible panorama frame).
Definition PanoramaFrame.h:1139
uint8_t maskValue() const
Returns the mask value defining the 8 bit pixel value of valid pixels.
Definition PanoramaFrame.h:1149
unsigned int dimensionHeight() const
Returns the maximal possible height of the entire panorama frame representing vertical 180 degrees,...
Definition PanoramaFrame.h:1169
UpdateMode
Definition of individual frame update modes.
Definition PanoramaFrame.h:54
const Frame & mask() const
Returns the mask of the current panorama frame.
Definition PanoramaFrame.h:1144
unsigned int dimensionWidth() const
Returns the maximal possible width of the entire panorama frame representing horizontal 360 degrees,...
Definition PanoramaFrame.h:1164
PanoramaFrame()=default
Creates an invalid panorama frame instance.
This class implements a frame pyramid.
Definition FramePyramid.h:46
DownsamplingMode
Definition of individual down sampling modes.
Definition FramePyramid.h:53
@ DM_FILTER_14641
Down sampling is realized by a 5x5 Gaussian filter.
Definition FramePyramid.h:81
This class implements a container for callback functions.
Definition Callback.h:3454
This class implements Ocean's image class.
Definition Frame.h:1969
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:272
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 Scalar deg2rad(const Scalar deg)
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.
virtual void clear()
Clears the panorama frame and allows to set a new first camera frame.
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::unordered_map< uint32_t, uint32_t > IndexMap
Definition of a map mapping indices.
Definition SphericalEnvironment.h:52
std::vector< Buffer > Buffers
Definition of a vector holding buffers.
Definition SphericalEnvironment.h:47
SquareMatrix3 previousOrientation_
The orientation of the camera of the most recent frame.
Definition SphericalEnvironment.h:462
SquareMatrix3 initialOrientation_
The initial orientation of the first camera frame.
Definition SphericalEnvironment.h:459
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 ...
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.
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
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< IndexPairs32 > PoseImagePointPairGroups
Definition of a vector holding groups of pairs between camera pose ids and image point ids.
Definition SphericalEnvironment.h:99
std::vector< uint8_t > Buffer
Definition of a vector holding 8 bit characters.
Definition SphericalEnvironment.h:42
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 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...
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
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:94
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
std::unordered_set< Index64 > UnorderedIndexSet64
Definition of an unordered_set holding 64 bit indices.
Definition Base.h:132
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition Frame.h:1932
std::vector< IndexPair32 > IndexPairs32
Definition of a vector holding 32 bit index pairs.
Definition Base.h:144
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
PinholeCameraT< Scalar > PinholeCamera
Definition of an pinhole camera object with Scalar precision.
Definition PinholeCamera.h:39
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition SquareMatrix3.h:43
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
std::vector< SquareMatrix3 > SquareMatrices3
Definition of a vector holding SquareMatrix3 objects.
Definition SquareMatrix3.h:72
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition Tracking.h:55
Namespace of the CV library.
Definition Advanced.h:17
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15