Ocean
Loading...
Searching...
No Matches
HomographyImageAlignmentSparse.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TRACKING_HOMOGRAPHY_IMAGE_ALIGNMENT_SPARSE_H
9#define META_OCEAN_TRACKING_HOMOGRAPHY_IMAGE_ALIGNMENT_SPARSE_H
10
12
13#include "ocean/base/Worker.h"
14
16#include "ocean/cv/SubRegion.h"
17
19
20namespace Ocean
21{
22
23namespace Tracking
24{
25
26/**
27 * This class implements image alignment functions internally using sparse image information like e.g., feature points.
28 * @see HomographyTracker.
29 * @ingroup tracking
30 */
31class OCEAN_TRACKING_EXPORT HomographyImageAlignmentSparse
32{
33 public:
34
35 /**
36 * Determines the global homography between two successive frames by applying a tracking of sparse feature points.
37 * The function tries to track sparse feature points scattered over the entire image (or sub-region) by detecting even quite weak feature points.<br>
38 * The resulting homography transforms image points defined in the previous image to image points defined in the current image (currentPoint = H * previousPoint).<br>
39 * Additionally, this function can return all point correspondences that have been determined between both frames,<br>
40 * or only those point correspondences that have been verified by a homography-based RANSAC.<br>
41 * Beware: Provide a valid 'validPointIndices' parameter and you will receive any point correspondences (stored in 'previousPoints' and 'currentPoints').<br>
42 * Instead, setting the 'validPointIndices' parameter to nullptr will return RANSAC-verified point correspondences only (stored in 'previousPoints' and 'currentPoints').<br>
43 * Ensure that 'previousPoints' and 'currentPoints' are defined if 'validPointIndices' is defined.
44 * @param previousFrame The previous frame which is used to determine the feature points, should have 8 bit grayscale pixel format to improve the performance, otherwise it will be converted internally, can be previousFramePyramid.finestLayer()
45 * @param previousFramePyramid The pyramid of the previous frame, all pyramid layers will be used for tracking, with same pixel origin as 'previousFrame'
46 * @param currentFramePyramid The pyramid of the current frame, with same pixel format, pixel original and layer number as 'previousFramePyramid'
47 * @param previousSubRegion The sub-region specified in the previous frame, image content outside this sub-region will not be used for tracking, define an invalid sub-region to use the entire image information
48 * @param numberFeaturePoints The number of feature points to be used, with range [1, infinity)
49 * @param patchSize The size of the image patches used for point tracking, possible values are 5, 7, 15, 31
50 * @param coarsestLayerRadius The search radius on the coarsest pyramid layer in pixel, with range [1, infinity)
51 * @param determineFullHomography True, to determine an 8-DOF homography; False, to determine a 2-DOF translational homography
52 * @param subPixelIterations Number of sub-pixel iterations that will be applied, each iteration doubles the sub-pixel accuracy, 1 = 0.5, 2 = 0.25, 3 = 0.125, ..., with range [1, infinity)
53 * @param homography Resulting homography transforming points in the previous image to points in the current image (currentPoint = H * previousPoint)
54 * @param worker Optional worker object to distribute the computation
55 * @param previousPoints Optional resulting image points located in the previous frame that have been either tracked and/or used for homography determination, the behavior depends whether 'validPointIndices' is defined or not, nullptr otherwise
56 * @param currentPoints Optional resulting image points located in the current frame that have been either tracked and/or used for homograph determination, one for each point in the previous frame, nullptr otherwise
57 * @param validPointIndices Optional resulting indices of all point correspondences that have been verified by a homography-based RANSAC, nullptr otherwise
58 * @param squarePixelErrorThreshold Maximal square pixel error between a right point and a transformed left point so that a point correspondence counts as valid, with range (0, infinity)
59 * @param zeroMean True, to subtract the color intensities from the corresponding mean intensity before determining the error; False, to determine the error directly
60 * @return True, if succeeded
61 * @see Subset::subset(), Subset::indices2statements().* @see Subset::subset(), Subset::indices2statements().
62 */
63 static bool determineHomographyWithPoints(const Frame& previousFrame, const CV::FramePyramid& previousFramePyramid, const CV::FramePyramid& currentFramePyramid, const CV::SubRegion& previousSubRegion, const size_t numberFeaturePoints, const unsigned int patchSize, const unsigned int coarsestLayerRadius, const bool determineFullHomography, const unsigned int subPixelIterations, SquareMatrix3& homography, Worker* worker = nullptr, Vectors2* previousPoints = nullptr, Vectors2* currentPoints = nullptr, Indices32* validPointIndices = nullptr, const Scalar squarePixelErrorThreshold = Scalar(3 * 3), const bool zeroMean = true);
64};
65
66}
67
68}
69
70#endif // META_OCEAN_TRACKING_HOMOGRAPHY_IMAGE_ALIGNMENT_SPARSE_H
This class implements a frame pyramid.
Definition FramePyramid.h:37
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:1808
This class implements image alignment functions internally using sparse image information like e....
Definition HomographyImageAlignmentSparse.h:32
static bool determineHomographyWithPoints(const Frame &previousFrame, const CV::FramePyramid &previousFramePyramid, const CV::FramePyramid &currentFramePyramid, const CV::SubRegion &previousSubRegion, const size_t numberFeaturePoints, const unsigned int patchSize, const unsigned int coarsestLayerRadius, const bool determineFullHomography, const unsigned int subPixelIterations, SquareMatrix3 &homography, Worker *worker=nullptr, Vectors2 *previousPoints=nullptr, Vectors2 *currentPoints=nullptr, Indices32 *validPointIndices=nullptr, const Scalar squarePixelErrorThreshold=Scalar(3 *3), const bool zeroMean=true)
Determines the global homography between two successive frames by applying a tracking of sparse featu...
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
float Scalar
Definition of a scalar type.
Definition Math.h:129
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