8 #ifndef META_OCEAN_GEOMETRY_JLINKAGE_H
9 #define META_OCEAN_GEOMETRY_JLINKAGE_H
63 static bool homographyMatrices(
const ImagePoint* leftImagePoints,
const ImagePoint* rightImagePoints,
const size_t correspondences,
const unsigned int width,
const unsigned int height,
SquareMatrices3& homographies,
const unsigned int testCandidates,
const ImagePoints& leftPointForInitialModels,
const Scalar squarePixelErrorAssignmentThreshold, std::vector<IndexSet32>* usedIndicesPerHomography =
nullptr,
bool refineHomographies =
true,
bool approximatedNeighborSearch =
true,
Ocean::RandomGenerator* randomGenerator =
nullptr);
83 static inline bool homographyMatrices(
const ImagePoint* leftImagePoints,
const ImagePoint* rightImagePoints,
const size_t correspondences,
const unsigned int width,
const unsigned int height,
SquareMatrices3& homographies,
const unsigned int testCandidates,
const Indices32& leftPointIndicesForInitialModels,
const Scalar squarePixelErrorAssignmentThreshold, std::vector<IndexSet32>* usedIndicesPerHomography =
nullptr,
bool refineHomographies =
true,
bool approximatedNeighborSearch =
true,
Ocean::RandomGenerator* randomGenerator =
nullptr);
99 static bool fitLines(
const ImagePoint* imagePoints,
const size_t pointCount,
const unsigned int width,
const unsigned int height,
Lines2& lines,
const unsigned int testCandidates,
const ImagePoints& pointForInitialModels,
const Scalar pixelErrorAssignmentThreshold, std::vector<IndexSet32>* usedIndicesPerHomography =
nullptr,
bool approximatedNeighborSearch =
true);
194 static bool fitLines(
const ImagePoint* imagePoints,
const size_t pointCount,
Lines2& lines,
const unsigned int testCandidates,
const ImagePoints& pointForInitialModels,
const Scalar pixelErrorAssignmentThreshold, std::vector<IndexSet32>* usedIndicesPerHomography =
nullptr);
209 inline bool JLinkage::homographyMatrices(
const ImagePoint* leftImagePoints,
const ImagePoint* rightImagePoints,
const size_t correspondences,
const unsigned int width,
const unsigned int height,
SquareMatrices3 & homographies,
const unsigned int testCandidates,
const Indices32& leftPointIndicesForInitialModels,
const Scalar squarePixelErrorAssignmentThreshold, std::vector<IndexSet32>* usedIndicesPerHomography,
bool refineHomographies,
bool approximatedNeighborSearch,
Ocean::RandomGenerator* randomGenerator)
211 const ImagePoints leftPointForInitialModels(
Subset::subset(leftImagePoints, correspondences, leftPointIndicesForInitialModels));
213 return homographyMatrices(leftImagePoints, rightImagePoints, correspondences, width, height, homographies, testCandidates, leftPointForInitialModels, squarePixelErrorAssignmentThreshold, usedIndicesPerHomography, refineHomographies, approximatedNeighborSearch, randomGenerator);
218 if (setA.empty() || setB.empty())
224 std::set_intersection(setA.cbegin(), setA.cend(), setB.cbegin(), setB.cend(), std::back_inserter(intersectionSet));
227 std::set_union(setA.cbegin(), setA.cend(), setB.cbegin(), setB.cend(), std::back_inserter(unionSet));
229 const Scalar numberIntersections =
Scalar(intersectionSet.size());
232 ocean_assert(unionSet.size() >= 1);
233 return (numberUnion - numberIntersections) / numberUnion;
238 return firstPair.first < seccondPair.first;
243 ocean_assert((vectorA.
columns() == 1u || vectorA.
rows() == 1u) && (vectorB.
columns() == 1u || vectorB.
rows() == 1u));
252 for (
size_t n = 0u; n < length; ++n)
256 squaredNormAB += vectorA.
data()[n] * vectorB.
data()[n];
259 return (1 -
Numeric::ratio(squaredNormAB, squaredNormA + squaredNormB - squaredNormAB));
This class implements several J-linkage functions for pose/homography determination.
Definition: JLinkage.h:35
static Scalar jaccardDistance(const IndexSet32 &setA, const IndexSet32 &setB)
Calculates the jaccard distance d(A, B) = ( |union(A, B)| - |intersection(A, B)| ) / |union(A,...
Definition: JLinkage.h:216
static bool distancePairSortAscending(const DistancePair &firstPair, const DistancePair &seccondPair)
Sorts pairs of indices and their corresponding distances in ascending order regarding the distance va...
Definition: JLinkage.h:236
static bool fitLines(const ImagePoint *imagePoints, const size_t pointCount, const unsigned int width, const unsigned int height, Lines2 &lines, const unsigned int testCandidates, const ImagePoints &pointForInitialModels, const Scalar pixelErrorAssignmentThreshold, std::vector< IndexSet32 > *usedIndicesPerHomography=nullptr, bool approximatedNeighborSearch=true)
Multiple line detector using J-linkage.
static std::vector< Indices32 > buildingMinimalSampleSet(const ImagePoint *imagePoints, const size_t pointCount, const ImagePoints &pointForInitialModels, const unsigned int testCandidates, const SpatialDistribution::DistributionArray *distributionImagePoints=nullptr)
Generates minimal sample set for J-/T-Linkage.
static Lines2 buildingMinimalSampleSetLine(const ImagePoint *imagePoints, const size_t pointCount, const ImagePoints &pointForInitialModels, const unsigned int testCandidates, const SpatialDistribution::DistributionArray *distributionImagePoints=nullptr)
Generates a line model per minimal sample set (for J-/T-Linkage)
static bool homographyMatrices(const ImagePoint *leftImagePoints, const ImagePoint *rightImagePoints, const size_t correspondences, const unsigned int width, const unsigned int height, SquareMatrices3 &homographies, const unsigned int testCandidates, const ImagePoints &leftPointForInitialModels, const Scalar squarePixelErrorAssignmentThreshold, std::vector< IndexSet32 > *usedIndicesPerHomography=nullptr, bool refineHomographies=true, bool approximatedNeighborSearch=true, Ocean::RandomGenerator *randomGenerator=nullptr)
Calculates multiple homographies between two images transforming the projected planar object points b...
static SquareMatrices3 buildingMinimalSampleSetHomography(const ImagePoint *leftImagePoints, const ImagePoint *rightImagePoints, const size_t correspondences, const ImagePoints &leftPointForInitialModels, const unsigned int testCandidates, const SpatialDistribution::DistributionArray *distributionImagePoints=nullptr, RandomGenerator *randomRansac=nullptr)
Generates a homography per minimal sample set (for J-/T-Linkage)
std::pair< Scalar, Index32 > DistancePair
Definition of a pair combining a point index with the distance to a reference.
Definition: JLinkage.h:41
This class implements a distribution array.
Definition: SpatialDistribution.h:228
This class implements L-linkage functions for pose/homography determination.
Definition: JLinkage.h:163
static bool homographyMatrices(const ImagePoint *leftImagePoints, const ImagePoint *rightImagePoints, const size_t correspondences, SquareMatrices3 &homographies, const unsigned int testCandidates, const ImagePoints &leftPointForInitialModels, const Scalar pixelAssignmentRadius, std::vector< IndexSet32 > *usedIndicesPerHomography=nullptr, bool refineHomographies=true, Ocean::RandomGenerator *randomGenerator=nullptr)
Calculates multiple homographies between two images transforming the projected planar object points b...
static bool fitLines(const ImagePoint *imagePoints, const size_t pointCount, Lines2 &lines, const unsigned int testCandidates, const ImagePoints &pointForInitialModels, const Scalar pixelErrorAssignmentThreshold, std::vector< IndexSet32 > *usedIndicesPerHomography=nullptr)
Multiple line detector using T-linkage.
static Scalar tanimotoDistance(const Matrix &vectorA, const Matrix &vectorB)
Calculates the tanimoto distance d(A, B) = 1 - A*B / (A*A + B*B - A*B).
Definition: JLinkage.h:241
size_t columns() const
Returns the count of columns.
Definition: Matrix.h:698
const T * data() const
Returns a pointer to the internal values.
Definition: Matrix.h:798
size_t elements() const
Returns the number of entire elements, which is the product of rows and columns.
Definition: Matrix.h:704
size_t rows() const
Returns the count of rows.
Definition: Matrix.h:692
static constexpr T ratio(const T nominator, const T denominator, const T fallback=T(1))
Returns the ratio between two values if the denominator is not equal a small epsilon.
Definition: Numeric.h:2076
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition: Numeric.h:1495
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
static std::vector< T > subset(const std::vector< T > &objects, const std::vector< TIndex > &indices)
Extracts a subset of a given set of objects by usage of an index vector holding the indices of all ob...
Definition: Subset.h:751
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition: Base.h:114
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition: geometry/Geometry.h:123
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Line2 > Lines2
Definition of a vector holding Line2 objects.
Definition: Line2.h:57
std::vector< SquareMatrix3 > SquareMatrices3
Definition of a vector holding SquareMatrix3 objects.
Definition: SquareMatrix3.h:71
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15