8#ifndef META_OCEAN_TRACKING_SLAM_LOCALIZED_OBJECT_POINT_H
9#define META_OCEAN_TRACKING_SLAM_LOCALIZED_OBJECT_POINT_H
37class LocalizedObjectPoint;
112 inline bool isSubsetApplied()
const;
118 inline bool isEmpty()
const;
163 inline void add(
const Indices32& objectPointIds);
218 inline void addObservation(
const Index32 frameIndex,
const Vector2& imagePoint);
231 inline void removeObservation(
const Index32 frameIndex);
240 inline bool hasObservation(
const Index32& frameIndex,
Vector2* imagePoint =
nullptr)
const;
262 inline Index32 lastObservationFrameIndex()
const;
269 inline size_t numberObservations()
const;
275 inline const Vector3& position()
const;
282 inline void setPosition(
const Vector3& objectPoint,
const bool isBundleAdjusted);
288 inline bool isBundleAdjusted()
const;
321 inline bool needDescriptor(
const Index32 frameIndex)
const;
523 bool isBundleAdjusted_ =
false;
580 for (
const ObservationMap::value_type& observationPair :
observationMap_)
582 const Index32 candidateFrameIndex = observationPair.first;
593 const ObservationMap::const_iterator iObservation =
observationMap_.find(frameIndex);
600 if (imagePoint !=
nullptr)
602 *imagePoint = iObservation->second;
610 const ObservationMap::const_iterator iObservation =
observationMap_.find(frameIndex);
614 return iObservation->second;
624 return Observation(iObservation->first, iObservation->second);
668 ocean_assert(descriptor.isValid());
696 const unsigned int basicInterval = 30u;
698 const unsigned int intervalFactor = (
unsigned int)(1u << (
unsigned int)(
descriptors_.size() - 1u));
702 return frameIndex >= nextFrameIndex;
708 const OptimizationResult optimizationResult =
optimizedObjectPoint(mapVersion, camera, cameraPoses, currentFrameIndex, minimalNumberObservations, maximalProjectionError, estimatorType, optimizedPosition);
715 return optimizationResult;
730 ocean_assert(!objectPoints_.empty() || (imagePoints_.empty() && objectPointIds_.empty() && localizationPrecisions_.empty() && imagePointSqrDistances_.empty() && usedIndices_.empty() && badObjectPointIds_.empty()));
732 return objectPoints_.empty();
739 objectPointIdSet_.insert(objectPointIds.begin(), objectPointIds.end());
747 objectPointIdSet_.clear();
756 objectPointIdSet_.clear();
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
EstimatorType
Definition of individual robust estimator types.
Definition Estimator.h:34
This class implements a container allowing to define gravity constraints during e....
Definition GravityConstraints.h:63
This class implements an output bitstream.
Definition Bitstream.h:215
This class implements a recursive lock object.
Definition Lock.h:31
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
This class implements a scoped lock object for recursive lock objects.
Definition Lock.h:147
This class implements a container for camera poses.
Definition CameraPoses.h:32
This class implements a container for correspondences between object points and image points which ca...
Definition LocalizedObjectPoint.h:94
UnorderedIndexSet32 poseNotPreciseObjectPointIds_
The ids of object points with imprecise localization used for the pose, for debugging and visualizati...
Definition LocalizedObjectPoint.h:147
Vectors3 objectPoints_
The 3D object points.
Definition LocalizedObjectPoint.h:123
Scalars imagePointSqrDistances_
The individual squared distances between previous and current image points, one for each observation,...
Definition LocalizedObjectPoint.h:135
void applySubset()
Applies the subset of used indices to filter the correspondence data.
UnorderedIndexSet32 posePreciseObjectPointIds_
The ids of object points with precise localization used for the pose, for debugging and visualization...
Definition LocalizedObjectPoint.h:144
bool isEmpty() const
Returns whether this correspondence data object is empty.
Definition LocalizedObjectPoint.h:728
LocalizationPrecisions localizationPrecisions_
The localization precisions of the object points.
Definition LocalizedObjectPoint.h:132
bool isSubsetApplied() const
Returns whether the subset has already been applied.
Definition LocalizedObjectPoint.h:723
Indices32 badObjectPointIds_
The ids of object points that were rejected during pose determination.
Definition LocalizedObjectPoint.h:141
Indices32 usedIndices_
The indices of the used correspondences after pose determination.
Definition LocalizedObjectPoint.h:138
Indices32 objectPointIds_
The ids of the object points.
Definition LocalizedObjectPoint.h:129
Vectors2 imagePoints_
The 2D image points corresponding to the object points.
Definition LocalizedObjectPoint.h:126
void reset()
Resets this data object so that it can be re-used.
This class implements a thread-safe container for object point ids.
Definition LocalizedObjectPoint.h:155
UnorderedIndexSet32 objectPointIdSet_
The set of object point ids.
Definition LocalizedObjectPoint.h:181
UnorderedIndexSet32 objectPointIds()
Returns and clears all object point ids from this container.
Definition LocalizedObjectPoint.h:742
Lock lock_
The lock for thread-safe access.
Definition LocalizedObjectPoint.h:184
void add(const Indices32 &objectPointIds)
Adds object point ids to this container.
Definition LocalizedObjectPoint.h:735
void clear()
Clears all object point ids from this container.
Definition LocalizedObjectPoint.h:752
This class implements a localized 3D object point.
Definition LocalizedObjectPoint.h:52
LocalizedObjectPoint(const PointTrack &pointTrack)
Creates a new localized object point from an unlocalized object point.
static SharedCameraPose determineCameraPose(const AnyCamera &camera, const CameraPoses &cameraPoses, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, RandomGenerator &randomGenerator, const Geometry::Estimator::EstimatorType estimatorType, CorrespondenceData &correspondenceData, const Geometry::GravityConstraints *gravityConstraints)
Determines the camera pose for a specific frame using the localized object points.
static size_t determineNumberTrackedObjectPoints(const CameraPoses &cameraPoses, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap)
Determines the number of tracked object points for a specific frame.
Index32 lastObservationFrameIndex_
The index of the last observation, -1 if no observation exists.
Definition LocalizedObjectPoint.h:529
Scalar determineMedianViewingAngle(const CameraPoses &cameraPoses) const
Determines the median viewing angle of this object point.
LocalizationPrecision localizationPrecision_
The localization precision of the object point.
Definition LocalizedObjectPoint.h:532
static size_t determineBundleAdjustmentQuality(const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, size_t &bundleAdjustedObjectPoints)
Determines the quality of bundle adjustment for a specific frame.
static LocalizationPrecision determineLocalizedObjectPointUncertaintyIF(const AnyCamera &camera, const HomogenousMatrices4 &flippedCameras_T_world, const Vector3 &objectPoint)
Determines the localization precision of an object point based on camera poses using an inverted flip...
static size_t determineCameraPoseQualityIF(const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, Scalar &minError, Scalar &averageError, Scalar &maxError)
Determines the quality of a camera pose for a specific frame by computing projection errors using an ...
void addDescriptors(const Index32 frameIndex, const CV::Detector::FREAKDescriptor32 &descriptor)
Adds a new visual descriptor to this object point.
Definition LocalizedObjectPoint.h:665
bool isBundleAdjusted() const
Returns whether the position of this object point has been determined during a bundle adjustment.
Definition LocalizedObjectPoint.h:718
bool hasObservation(const Index32 &frameIndex, Vector2 *imagePoint=nullptr) const
Returns whether this object point has an observation for a given frame index.
Definition LocalizedObjectPoint.h:591
static Scalar determineMedianLocalizedObjectDistances(const CameraPoses &cameraPoses, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, const bool onlyTrackedObjectPoints)
Determines the median distance from the camera to the localized object points.
CV::Detector::FREAKDescriptors32 descriptors_
The visual descriptors of the object point.
Definition LocalizedObjectPoint.h:538
Index32 lastDescriptorFrameIndex_
The index of the frame in which the last descriptor was added, -1 if no descriptor has been added yet...
Definition LocalizedObjectPoint.h:535
Index32 lastObservationFrameIndex() const
Returns the frame index of the last observation of this object point.
Definition LocalizedObjectPoint.h:627
LocalizationPrecision
Definition of possible localization precisions.
Definition LocalizedObjectPoint.h:59
@ LP_MEDIUM
The localization precision is medium, because the object point has been observed from quite narrow vi...
Definition LocalizedObjectPoint.h:67
@ LP_UNKNOWN
The localization precision could not yet be decided (e.g., because of too few observations).
Definition LocalizedObjectPoint.h:63
@ LP_LOW
The localization precision is low, because the object point has not been observed from enough differe...
Definition LocalizedObjectPoint.h:65
bool isBundleAdjusted_
True, if the position of the object point has been determined during a Bundle Adjustment; False,...
Definition LocalizedObjectPoint.h:523
static void determineObjectPointQualityIF(const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, const Scalar maximalProjectionError, Indices32 &validObjectPointIds, Indices32 &invalidObjectPointIds)
Determines the quality of object points for a specific frame by computing projection errors using an ...
void addObservation(const Index32 frameIndex, const Vector2 &imagePoint)
Adds a new observation of this object point for a given frame index.
Definition LocalizedObjectPoint.h:551
static std::string translateLocalizationPrecision(const LocalizationPrecision localizationPrecision)
Translates a localization precision enum value to a human-readable string.
OptimizationResult optimizeObjectPoint(const Index32 mapVersion, const AnyCamera &camera, const CameraPoses &cameraPoses, const Index32 currentFrameIndex, const size_t minimalNumberObservations, const Scalar maximalProjectionError, const Geometry::Estimator::EstimatorType estimatorType)
Optimizes this localized 3D object point which is visible in the current camera frame and in several ...
Definition LocalizedObjectPoint.h:705
static size_t determineCameraPoseQuality(const AnyCamera &camera, const CameraPoses &cameraPoses, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, Scalar &minError, Scalar &averageError, Scalar &maxError)
Determines the quality of a camera pose for a specific frame by computing projection errors.
OptimizationResult optimizedObjectPoint(const Index32 mapVersion, const AnyCamera &camera, const CameraPoses &cameraPoses, const Index32 currentFrameIndex, const size_t minimalNumberObservations, const Scalar maximalProjectionError, const Geometry::Estimator::EstimatorType estimatorType, Vector3 &optimizedPosition) const
Determines the optimized 3D position of this localized object point visible in the current camera fra...
void removeObservation(const Index32 frameIndex)
Removes the observation of this object point for a given frame index.
Definition LocalizedObjectPoint.h:561
bool needDescriptor(const Index32 frameIndex) const
Returns whether this object point needs a visual descriptor.
Definition LocalizedObjectPoint.h:675
std::vector< LocalizationPrecision > LocalizationPrecisions
Definition of a vector holding localization precisions.
Definition LocalizedObjectPoint.h:75
OptimizationResult
Definition of individual optimization results.
Definition LocalizedObjectPoint.h:81
@ OR_INACCURATE
The optimization failed because the object point location does not fit to all observations.
Definition LocalizedObjectPoint.h:85
@ OR_SUCCEEDED
The optimization succeeded.
Definition LocalizedObjectPoint.h:87
@ OR_NOT_ENOUGH_OBSERVATIONS
The optimization failed because the object point does not have enough observations.
Definition LocalizedObjectPoint.h:83
Vector2 observation(const Index32 frameIndex) const
Returns the observation of this object point for a given frame index.
Definition LocalizedObjectPoint.h:608
void addObservations(const PointTrack &pointTrack)
Adds all observations from a point track to this localized object point.
static bool determineCameraPose(const AnyCamera &camera, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, HomogenousMatrix4 &world_T_camera, RandomGenerator &randomGenerator, const size_t minimalCorrespondences, const Scalar maximalProjectionError, Indices32 &usedObjectPointIds, Scalar &sqrError, const Geometry::GravityConstraints *gravityConstraints)
Determines the camera pose for a specific frame using RANSAC-based P3P pose estimation.
const Vector3 & position() const
Returns the position of this object point.
Definition LocalizedObjectPoint.h:637
void setPosition(const Vector3 &objectPoint, const bool isBundleAdjusted)
Sets or updates the position of this object point.
Definition LocalizedObjectPoint.h:642
static bool serialize(const LocalizedObjectPoint &localizedObjectPoint, IO::OutputBitstream &outputBitstream)
Serializes a single localized object point to a bitstream.
bool updateLocalizedObjectPointUncertainty(const AnyCamera &camera, const CameraPoses &cameraPose)
Updates the localization precision of this object point based on its observations and the camera pose...
LocalizationPrecision localizationPrecision() const
Returns the localization precision of this object point.
Definition LocalizedObjectPoint.h:650
static size_t determineNumberTrackedObjectPoints(const CameraPoses &cameraPoses, const Index32 frameIndex, const LocalizedObjectPointMap &localizedObjectPointMap, const UnorderedIndexSet32 &objectPointIds)
Determines the number of tracked object points for a specific frame from a given set of object point ...
void setLocalizationPrecision(const LocalizationPrecision localizationPrecision)
Sets or updates the localization precision of this object point.
Definition LocalizedObjectPoint.h:655
Observation lastObservation() const
Returns the last observation of this object point.
Definition LocalizedObjectPoint.h:617
std::unordered_map< Index32, Vector2 > ObservationMap
Definition of an unordered map mapping camera indices to 2D observations.
Definition LocalizedObjectPoint.h:192
Vector3 position_
The 3D position of the object point.
Definition LocalizedObjectPoint.h:520
static bool serialize(const LocalizedObjectPointMap &localizedObjectPointMap, IO::OutputBitstream &outputBitstream)
Serializes a map of localized object points to a bitstream.
const CV::Detector::FREAKDescriptors32 & descriptors() const
Returns the visual descriptors of this object point.
Definition LocalizedObjectPoint.h:660
ObservationMap observationMap_
The map mapping camera indices to 2D observations.
Definition LocalizedObjectPoint.h:526
size_t numberObservations() const
Returns the number of observations of this object point.
Definition LocalizedObjectPoint.h:632
static LocalizationPrecision determineLocalizedObjectPointUncertainty(const SquareMatrix3 &covarianceMatrix)
Determines the localization precision of an object point based on its covariance matrix.
This class implements an observation of a 3D feature point in a camera frame.
Definition Observation.h:39
This class implements a point track which stores continuous 2D observations of a 3D object point over...
Definition PointTrack.h:40
static VectorT3< Scalar > minValue()
Returns a 3D vector with all elements set to NumericT::minValue().
Definition Vector3.h:1059
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::unordered_set< Index32 > UnorderedIndexSet32
Definition of an unordered_set holding 32 bit indices.
Definition Base.h:126
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition HomogenousMatrix4.h:73
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
std::unordered_map< Index32, LocalizedObjectPoint > LocalizedObjectPointMap
Definition of an unordered map mapping object point ids to localized object points.
Definition LocalizedObjectPoint.h:43
std::shared_ptr< CameraPose > SharedCameraPose
Definition of a shared pointer holding a CameraPose object.
Definition CameraPose.h:36
std::vector< FREAKDescriptor32 > FREAKDescriptors32
Vector of 32-bytes long FREAK descriptors.
Definition FREAKDescriptor.h:69
FREAKDescriptorT< 32 > FREAKDescriptor32
Typedef for the 32-bytes long FREAK descriptor.
Definition FREAKDescriptor.h:66
The namespace covering the entire Ocean framework.
Definition Accessor.h:15