8 #ifndef META_OCEAN_TRACKING_OFFLINE_FRAME_2_FRAME_TRACKER_H
9 #define META_OCEAN_TRACKING_OFFLINE_FRAME_2_FRAME_TRACKER_H
78 template <
unsigned int tSize>
79 static size_t trackPlanarObject(
const PinholeCamera& pinholeCamera,
const CV::FramePyramid& previousPyramid,
const CV::FramePyramid& nextPyramid,
const unsigned int layerRadius,
const HomogenousMatrix4& previousPose,
const Plane3& previousPlane,
const CV::SubRegion& previousSubRegion,
HomogenousMatrix4& nextPose,
const Scalar maximalSqrError ,
const unsigned int horizontalBins ,
const unsigned int verticalBins ,
const unsigned int strength = 30u,
Worker* worker =
nullptr,
const unsigned int trackingLayers = 1u,
Vectors2* previousImagePoints =
nullptr,
Vectors2* currentImagePoints =
nullptr);
100 template <
unsigned int tSize>
101 static inline size_t trackPlanarObject(
const PinholeCamera& pinholeCamera,
const Frame& previousFrame,
const Frame& nextFrame,
const unsigned int layerRadius,
const HomogenousMatrix4& previousPose,
const Plane3& previousPlane,
const CV::SubRegion& previousSubRegion,
HomogenousMatrix4& nextPose,
const Scalar maximalSqrError =
Scalar(0.9 * 0.9),
const CV::FramePyramid::DownsamplingMode downsamplingMode =
CV::FramePyramid::DM_FILTER_14641,
Worker* worker =
nullptr);
104 template <
unsigned int tSize>
105 size_t Frame2FrameTracker::trackPlanarObject(
const PinholeCamera& pinholeCamera,
const CV::FramePyramid& previousPyramid,
const CV::FramePyramid& nextPyramid,
const unsigned int layerRadius,
const HomogenousMatrix4& previousPose,
const Plane3& previousPlane,
const CV::SubRegion& previousSubRegion,
HomogenousMatrix4& nextPose,
const Scalar maximalSqrError,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const unsigned int strength,
Worker* worker,
const unsigned int trackingLayers,
Vectors2* previousImagePoints,
Vectors2* currentImagePoints)
107 ocean_assert(pinholeCamera && previousPyramid && nextPyramid);
108 ocean_assert(previousPose.
isValid());
109 ocean_assert(previousPlane.
isValid());
111 Vectors2 previousRobustImagePoints, nextRobustImagePoints;
112 if (!CV::Advanced::AdvancedMotionZeroMeanSSD::trackArbitraryPointsBidirectionalSubPixelMirroredBorder<tSize>(previousPyramid, nextPyramid, layerRadius, previousRobustImagePoints, nextRobustImagePoints, maximalSqrError, previousSubRegion, horizontalBins, verticalBins, strength, worker, trackingLayers) || previousRobustImagePoints.size() < 5)
117 ocean_assert(previousRobustImagePoints.size() == nextRobustImagePoints.size());
119 if (!
trackPlanarObject(pinholeCamera, previousPose, previousPlane, previousRobustImagePoints.data(), nextRobustImagePoints.data(), previousRobustImagePoints.size(), nextPose))
124 ocean_assert(previousRobustImagePoints.size() >= 5);
125 const size_t result = previousRobustImagePoints.size();
127 if (previousImagePoints)
129 *previousImagePoints = std::move(previousRobustImagePoints);
132 if (currentImagePoints)
134 *currentImagePoints = std::move(nextRobustImagePoints);
140 template <
unsigned int tSize>
141 size_t Frame2FrameTracker::trackPlanarObject(
const PinholeCamera& pinholeCamera,
const Frame& previousFrame,
const Frame& nextFrame,
const unsigned int layerRadius,
const HomogenousMatrix4& previousPose,
const Plane3& previousPlane,
const CV::SubRegion& previousSubRegion,
HomogenousMatrix4& nextPose,
const Scalar maximalSqrError,
const CV::FramePyramid::DownsamplingMode downsamplingMode,
Worker* worker)
143 ocean_assert(pinholeCamera && previousFrame && nextFrame);
144 ocean_assert(previousPose.
isValid());
157 const CV::FramePyramid previousPyramid(previousFrame, downsamplingMode, layers,
false , worker);
158 const CV::FramePyramid nextPyramid(nextFrame, downsamplingMode, layers,
false , worker);
160 return trackPlanarObject<tSize>(pinholeCamera, previousPyramid, nextPyramid, layerRadius, previousPose, previousPlane, previousSubRegion, nextPose, maximalSqrError, worker);
This class implements a frame pyramid.
Definition: FramePyramid.h:37
static unsigned int idealLayers(const unsigned int width, const unsigned int height, const unsigned int invalidCoarsestWidthOrHeight, unsigned int *coarsestLayerWidth=nullptr, unsigned int *coarsestLayerHeight=nullptr)
Determines the number of layers until an invalid frame size would be reached in the next layer.
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 implement a sub-region either defined by 2D triangles or defined by a binary mask.
Definition: SubRegion.h:32
This class implements Ocean's image class.
Definition: Frame.h:1792
const FrameType & frameType() const
Returns the frame type of this frame.
Definition: Frame.h:3775
unsigned int width() const
Returns the width of the frame format in pixel.
Definition: Frame.h:3143
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3148
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
bool isValid() const
Returns whether this plane is valid.
Definition: Plane3.h:538
This class implements a tracker allowing to tracker feature points between two frames.
Definition: offline/Frame2FrameTracker.h:38
static bool trackPlanarObject(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &previousPose, const Plane3 &previousPlane, const Vector2 *previousImagePoints, const Vector2 *nextImagePoints, const size_t correspondences, HomogenousMatrix4 &nextPose)
This function tracks a planar plane or object between two successive frames.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15