8 #ifndef META_OCEAN_TRACKING_MAPBUILDING_PATCH_TRACKER_H
9 #define META_OCEAN_TRACKING_MAPBUILDING_PATCH_TRACKER_H
75 inline Options(
const size_t maximalFeaturesPerFrame,
const double newFeaturesInterval,
const bool keepUnlocatedFeatures,
const size_t minimalNumberObservationsPerFeature,
const Scalar minimalBoxDiagonalForLocatedFeature);
81 static inline Options realtimeOptions();
87 static inline Options offlineOptions();
92 size_t maximalFeaturesPerFrame_ = 0;
95 double newFeaturesInterval_ = -1.0;
98 bool keepUnlocatedFeatures_ =
false;
101 size_t minimalNumberObservationsPerFeature_ = 0;
104 Scalar minimalBoxDiagonalForLocatedFeature_ = 0;
195 unsigned int framesWithoutGoodTracking_ = 0u;
205 explicit inline PatchTracker(
const std::shared_ptr<UnifiedDescriptorExtractor>& unifiedDescriptorExtractor,
const Options& options = Options::offlineOptions());
224 inline const Database& database()
const;
230 inline std::shared_ptr<UnifiedDescriptorMap> unifiedDescriptorMap()
const;
243 void reset(
Database* database =
nullptr, std::shared_ptr<UnifiedDescriptorMap>* unifiedDescriptorMap =
nullptr);
335 bool needToUpdateFramePyramidForDescriptors_ =
true;
365 inline PatchTracker::Options::Options(
const size_t maximalFeaturesPerFrame,
const double newFeaturesInterval,
const bool keepUnlocatedFeatures,
const size_t minimalNumberObservationsPerFeature,
const Scalar minimalBoxDiagonalForLocatedFeature) :
366 maximalFeaturesPerFrame_(maximalFeaturesPerFrame),
367 newFeaturesInterval_(newFeaturesInterval),
368 keepUnlocatedFeatures_(keepUnlocatedFeatures),
369 minimalNumberObservationsPerFeature_(minimalNumberObservationsPerFeature),
370 minimalBoxDiagonalForLocatedFeature_(minimalBoxDiagonalForLocatedFeature)
380 constexpr
size_t maximalFeaturesPerFrame_ = 400;
381 constexpr
double newFeaturesInterval = 0.25;
383 constexpr
bool keepUnlocatedFeatures =
false;
384 constexpr
size_t minimalNumberObservationsPerFeature = 30;
385 constexpr
Scalar minimalBoxDiagonalForLocatedFeature =
Scalar(0.1);
387 return Options(maximalFeaturesPerFrame_, newFeaturesInterval, keepUnlocatedFeatures, minimalNumberObservationsPerFeature, minimalBoxDiagonalForLocatedFeature);
392 constexpr
size_t maximalFeaturesPerFrame_ = 1200;
393 constexpr
double newFeaturesInterval = 0.0;
395 constexpr
bool keepUnlocatedFeatures =
true;
396 constexpr
size_t minimalNumberObservationsPerFeature = 30;
397 constexpr
Scalar minimalBoxDiagonalForLocatedFeature =
Scalar(0.05);
399 return Options(maximalFeaturesPerFrame_, newFeaturesInterval, keepUnlocatedFeatures, minimalNumberObservationsPerFeature, minimalBoxDiagonalForLocatedFeature);
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
This class implements a frame pyramid.
Definition: FramePyramid.h:37
This class implements the abstract base class for all device players.
Definition: DevicePlayer.h:41
This class implements Ocean's image class.
Definition: Frame.h:1792
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
This class implements an occupancy array.
Definition: SpatialDistribution.h:370
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements a timestamp.
Definition: Timestamp.h:36
This class implements a database for 3D object points, 2D image points and 6DOF camera poses.
Definition: Database.h:67
This class implements functions necessary when handling descriptors.
Definition: DescriptorHandling.h:32
This class holds the tracking data for feature points for which the 3D location is know.
Definition: PatchTracker.h:172
bool isValid() const override
Returns whether this object holds valid data.
Vectors3 objectPoints_
The 3D locations of all feature points.
Definition: PatchTracker.h:186
Vectors2 reusablePredictedCurrentImagePoints_
A vector with 2D image points, can be re-used for each new frame.
Definition: PatchTracker.h:192
Vectors3 poseTranslationsWhenDeterminedObjectPoints_
The translational part of the camera pose for each 3D object point in the moment the initial location...
Definition: PatchTracker.h:189
This class implement a container holding options for the tracker.
Definition: PatchTracker.h:64
Scalar minimalBoxDiagonalForLocatedFeature_
The minimal diagonal of the bounding box of all camera poses observing an object point necessary so t...
Definition: PatchTracker.h:104
size_t maximalFeaturesPerFrame_
The maximal number of features which will be managed in each frame.
Definition: PatchTracker.h:92
double newFeaturesInterval_
The time interval between frames in which new feature points will be added to the tracker,...
Definition: PatchTracker.h:95
static Options offlineOptions()
Creates default options for offline execution.
Definition: PatchTracker.h:390
Options(const size_t maximalFeaturesPerFrame, const double newFeaturesInterval, const bool keepUnlocatedFeatures, const size_t minimalNumberObservationsPerFeature, const Scalar minimalBoxDiagonalForLocatedFeature)
Creates new options.
Definition: PatchTracker.h:365
size_t minimalNumberObservationsPerFeature_
The minimal number of observations a feature must have, with range [2, infinity).
Definition: PatchTracker.h:101
static Options realtimeOptions()
Creates default options for realtime execution.
Definition: PatchTracker.h:378
This class implements the base class for all tracking data objects.
Definition: PatchTracker.h:126
virtual bool isValid() const
Returns whether this object holds valid data.
Vectors2 previousImagePoints_
the 2D image points associated with this tracking data.
Definition: PatchTracker.h:149
Indices32 objectPointIds_
The ids of the object points associated with this tracking data.
Definition: PatchTracker.h:146
SharedFramePyramid yPreviousFramePyramid_
The image pyramid associated with this tracking data.
Definition: PatchTracker.h:143
virtual ~TrackingData()=default
Destructs the object.
This class holds the tracking data for feature points for which the 3D location is not yet known.
Definition: PatchTracker.h:156
CV::Detector::HarrisCorners reusableHarrisCorners_
A vector with Harris corners, can be re-used for each new frame.
Definition: PatchTracker.h:162
Timestamp lastNewFeaturesAddedTimestamp_
The timestamp when the last time new unlocated features have been added.
Definition: PatchTracker.h:165
This class implements a tracker for 3D feature points in an image sequence (offline) or a live video ...
Definition: PatchTracker.h:52
Database database_
The database holding the topology of the tracked features.
Definition: PatchTracker.h:323
void convertUnlocatedPointsToLocatedPoints(const AnyCamera ¤tAnyCamera, const HomogenousMatrix4 &world_T_currentCamera)
Converts unlocated 2D feature points to located 3D feature points.
RandomGenerator randomGenerator_
The random generator to be used.
Definition: PatchTracker.h:347
bool trackFrame(const Index32 frameIndex, const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, const SharedFramePyramid &yCurrentFramePyramid, const Timestamp &frameTimestamp, Worker *worker=nullptr, Frame *debugFrame=nullptr)
Tracks the features from the previous frame to the current frame.
std::shared_ptr< UnifiedDescriptorExtractor > unifiedDescriptorExtractor_
The feature extractor to be used.
Definition: PatchTracker.h:344
Indices32 reusableValidIndices_
Reusable indices.
Definition: PatchTracker.h:350
Indices32 reusableImagePointIds_
Reusable point indices.
Definition: PatchTracker.h:359
LocatedTrackingData locatedTrackingData_
The tracking data for all located feature points (for which a 3D location is known).
Definition: PatchTracker.h:329
std::shared_ptr< UnifiedDescriptorMap > unifiedDescriptorMap_
The map mapping object point ids to feature descriptors.
Definition: PatchTracker.h:341
Vectors2 reusableImagePoints_
Reusable 2D points.
Definition: PatchTracker.h:362
CV::FramePyramid yReusableFramePyramidForDescriptors_
The image pyramid for descriptor extraction, can be reused for each new frame.
Definition: PatchTracker.h:338
const Database & database() const
Returns the current database of the tracker.
Definition: PatchTracker.h:409
static bool trackRecording(Devices::DevicePlayer &devicePlayer, const std::vector< std::string > &worldTrackerNames, Database &database, SharedAnyCamera &anyCamera, std::shared_ptr< UnifiedDescriptorMap > &descriptorMap, const std::shared_ptr< UnifiedDescriptorExtractor > &unifiedDescriptorExtractor)
Runs the tracker on a recording provided through a device player.
LocationResult
Definition of individual location results.
Definition: PatchTracker.h:113
@ LR_NOT_YET
The location could not yet be determined.
Definition: PatchTracker.h:115
@ LR_FLAKY
The location is flaky and thus the object point should not be used.
Definition: PatchTracker.h:117
void trackLocatedPoints(const Index32 frameIndex, const AnyCamera ¤tAnyCamera, const HomogenousMatrix4 &world_T_currentCamera, const SharedFramePyramid &yCurrentFramePyramid, Geometry::SpatialDistribution::OccupancyArray &occupancyArray, Worker *worker)
Tracks the located feature points from the previous frame to the current frame.
void reset(Database *database=nullptr, std::shared_ptr< UnifiedDescriptorMap > *unifiedDescriptorMap=nullptr)
Resets the tracker so that it can be used for a new tracking session.
Indices32 reusabledPoseIds_
Reusable pose indices.
Definition: PatchTracker.h:356
Vectors2 reusableCurrentImagePoints_
Reusable 2D points.
Definition: PatchTracker.h:353
Options options_
The tracker's options.
Definition: PatchTracker.h:320
void trackUnlocatedPoints(const Index32 frameIndex, const SharedFramePyramid &yCurrentFramePyramid, Geometry::SpatialDistribution::OccupancyArray &occupancyArray, Worker *worker)
Tracks the unlocated feature points from the previous frame to the current frame.
std::shared_ptr< UnifiedDescriptorMap > unifiedDescriptorMap() const
Returns the current descriptor map of the tracker.
Definition: PatchTracker.h:414
Vectors3 latestObjectPoints(Indices32 *objectPointIds=nullptr) const
Returns the 3D locations of all currently known located 3D object points.
Geometry::SpatialDistribution::OccupancyArray reusableOccupancyArray_
An occupancy array, can be reused for each new frame.
Definition: PatchTracker.h:332
static size_t removeFlakyObjectPoints(Database &database, const size_t minimalNumberObservations, const Scalar mimimalBoxDiagonal, Indices32 *removedObjectPointIds=nullptr)
Removes flaky object points from the database.
void addUnlocatedPoints(const Index32 frameIndex, const AnyCamera ¤tAnyCamera, const CV::FramePyramid &yCurrentFramePyramid, const Timestamp &frameTimestamp, Geometry::SpatialDistribution::OccupancyArray &occupancyArray, Worker *worker)
Adds new unlocated 2D feature points into image regions without feature points.
UnlocatedTrackingData unlocatedTrackingData_
The tracking data for all unlocated feature points.
Definition: PatchTracker.h:326
PatchTracker(const std::shared_ptr< UnifiedDescriptorExtractor > &unifiedDescriptorExtractor, const Options &options=Options::offlineOptions())
Creates a new tracker object with specified descriptor extractor.
Definition: PatchTracker.h:402
std::shared_ptr< CV::FramePyramid > SharedFramePyramid
Definition of a shared FramePyramid.
Definition: PatchTracker.h:58
LocationResult determineObjectPointLocation(const AnyCamera ¤tAnyCamera, const Index32 objectPointId, const Geometry::Estimator::EstimatorType estimatorType, Vector3 &objectPoint)
Determines the location of a 3D feature point.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
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::vector< HarrisCorner > HarrisCorners
Definition of a vector holding Harris corners.
Definition: HarrisCorner.h:24
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:60
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15