Ocean
Ocean::Geometry::JLinkage Class Reference

This class implements several J-linkage functions for pose/homography determination. More...

Inheritance diagram for Ocean::Geometry::JLinkage:

Static Public Member Functions

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 between the two images using J-linkage The resulting homographies transform its image points defined in the left image to image points defined in the right image (rightPoint_i = H_i * leftPoint_i). More...
 
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 Indices32 &leftPointIndicesForInitialModels, 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 between the two images using J-linkage The resulting homographies transform its image points defined in the left image to image points defined in the right image (rightPoint_i = H_i * leftPoint_i). More...
 
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. More...
 

Protected Types

typedef std::pair< Scalar, Index32DistancePair
 Definition of a pair combining a point index with the distance to a reference. More...
 

Static Protected Member Functions

static std::vector< Indices32buildingMinimalSampleSet (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. More...
 
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) More...
 
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) More...
 
static Scalar jaccardDistance (const IndexSet32 &setA, const IndexSet32 &setB)
 Calculates the jaccard distance d(A, B) = ( |union(A, B)| - |intersection(A, B)| ) / |union(A, B)|. More...
 
static bool distancePairSortAscending (const DistancePair &firstPair, const DistancePair &seccondPair)
 Sorts pairs of indices and their corresponding distances in ascending order regarding the distance values. More...
 

Detailed Description

This class implements several J-linkage functions for pose/homography determination.

J-linkage aims to fit multiple models from data given The J-linkage algorithm is an agglomerative clustering that proceeds by linking elements with Jaccard distance smaller than 1 and stop as soon as there are no such elements left.

Member Typedef Documentation

◆ DistancePair

Definition of a pair combining a point index with the distance to a reference.

Member Function Documentation

◆ buildingMinimalSampleSet()

static std::vector<Indices32> Ocean::Geometry::JLinkage::buildingMinimalSampleSet ( const ImagePoint imagePoints,
const size_t  pointCount,
const ImagePoints pointForInitialModels,
const unsigned int  testCandidates,
const SpatialDistribution::DistributionArray distributionImagePoints = nullptr 
)
staticprotected

Generates minimal sample set for J-/T-Linkage.

Parameters
imagePointsImage points
pointCountNumber of points
pointForInitialModelsInitial points of minimal sample sets. Note: some maybe be discarded
testCandidatesNumber of candidates used for each minimal sampling set, with range [1, correspondences]
distributionImagePointsSpatial distribution for approximate search (if nullptr, brute force methode is used)
Returns
List of minimal sample sets (represented by indices)

◆ buildingMinimalSampleSetHomography()

static SquareMatrices3 Ocean::Geometry::JLinkage::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 
)
staticprotected

Generates a homography per minimal sample set (for J-/T-Linkage)

Parameters
leftImagePointsImage points in the left camera, each point corresponds to one point in the right image
rightImagePointsImage points in the right camera
correspondencesNumber of points correspondences
leftPointForInitialModelsInitial points of minimal sample sets. Note: some maybe be discarded
testCandidatesNumber of candidates used for each minimal sampling set, with range [4, correspondences]
distributionImagePointsSpatial distribution for approximate search (if nullptr, brute force methode is used)
randomRansacRandom generator object to be used for creating random numbers, RANSAC is used if this is not null
Returns
Resulting homographies for each minimal sample set (its count is possibly smaller then the given image points)

◆ buildingMinimalSampleSetLine()

static Lines2 Ocean::Geometry::JLinkage::buildingMinimalSampleSetLine ( const ImagePoint imagePoints,
const size_t  pointCount,
const ImagePoints pointForInitialModels,
const unsigned int  testCandidates,
const SpatialDistribution::DistributionArray distributionImagePoints = nullptr 
)
staticprotected

Generates a line model per minimal sample set (for J-/T-Linkage)

Parameters
imagePointsImage points
pointCountNumber of points
pointForInitialModelsInitial points of minimal sample sets. Note: some maybe be discarded
testCandidatesNumber of candidates used for each minimal sampling set, with range [2, correspondences]
distributionImagePointsSpatial distribution for approximate search (if nullptr, brute force methode is used)
Returns
Resulting line for each minimal sample set (its count is possibly smaller then the given image points)

◆ distancePairSortAscending()

bool Ocean::Geometry::JLinkage::distancePairSortAscending ( const DistancePair firstPair,
const DistancePair seccondPair 
)
inlinestaticprotected

Sorts pairs of indices and their corresponding distances in ascending order regarding the distance values.

Parameters
firstPairFirst pair of distance and index
seccondPairSecond pair of distance and index
Returns
True, if the distance value of the first pair is smaller than distance value of the second pair

◆ fitLines()

static bool Ocean::Geometry::JLinkage::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 
)
static

Multiple line detector using J-linkage.

Parameters
imagePointsimage points
pointCountNumber of points
widthThe width of the image in pixel
heightThe height of the image in pixel
linesResulting valid line model
testCandidatesNumber of candidates used in for minimum sample set, with range [2, correspondences]
pointForInitialModelsInitial image points, one per each sample set
pixelErrorAssignmentThresholdMaximal pixel error of a point-line corresspodance (0, infinity)
usedIndicesPerHomographyOptional set of indices which will receive the indices of the used image correspondences per model, if defined
approximatedNeighborSearchDefines if speeded up spatial neighbor search is used
Returns
True, if successfully completed

◆ homographyMatrices() [1/2]

static bool Ocean::Geometry::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 ImagePoints leftPointForInitialModels,
const Scalar  squarePixelErrorAssignmentThreshold,
std::vector< IndexSet32 > *  usedIndicesPerHomography = nullptr,
bool  refineHomographies = true,
bool  approximatedNeighborSearch = true,
Ocean::RandomGenerator randomGenerator = nullptr 
)
static

Calculates multiple homographies between two images transforming the projected planar object points between the two images using J-linkage The resulting homographies transform its image points defined in the left image to image points defined in the right image (rightPoint_i = H_i * leftPoint_i).


Parameters
leftImagePointsImage points in the left camera, each point corresponds to one point in the right image
rightImagePointsImage points in the right camera
correspondencesNumber of points correspondences
widthThe width of the left image in pixel
heightThe height of the left image in pixel
homographiesResulting valid homographies for each image plane
testCandidatesNumber of candidates used in for minimum sample set, with range [4, correspondences]
leftPointForInitialModelsInitial image points, one per each sample set
squarePixelErrorAssignmentThresholdMaximal square pixel error of a valid projection of a 3D point onto the 2D image plane, with range (0, infinity)
usedIndicesPerHomographyOptional set of indices which will receive the indices of the used image correspondences per model, if defined
refineHomographiesDetermines whether a not linear least square algorithm is used to increase the pose accuracies after J-linkage
approximatedNeighborSearchDefines if speeded up spatial neighbor search is used
randomGeneratorRandom number generator. If is not nullptr, RANSAC is used for homography determination within initial minimum sample set
Returns
True, if successfully completed

◆ homographyMatrices() [2/2]

bool Ocean::Geometry::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 = nullptr,
bool  refineHomographies = true,
bool  approximatedNeighborSearch = true,
Ocean::RandomGenerator randomGenerator = nullptr 
)
inlinestatic

Calculates multiple homographies between two images transforming the projected planar object points between the two images using J-linkage The resulting homographies transform its image points defined in the left image to image points defined in the right image (rightPoint_i = H_i * leftPoint_i).


Parameters
leftImagePointsImage points in the left camera, each point corresponds to one point in the right image
rightImagePointsImage points in the right camera
correspondencesNumber of points correspondences
widthThe width of the left image in pixel
heightThe height of the left image in pixel
homographiesResulting valid homographies for each image plane
testCandidatesNumber of candidates used in for minimum sample set, with range [4, correspondences]
leftPointIndicesForInitialModelsInitial indices of image points, one per each sample set
squarePixelErrorAssignmentThresholdMaximal square pixel error of a valid projection of a 3D point onto the 2D image plane, with range (0, infinity)
usedIndicesPerHomographyOptional set of indices which will receive the indices of the used image correspondences per model, if defined
refineHomographiesDetermines whether a not linear least square algorithm is used to increase the pose accuracies after J-linkage
approximatedNeighborSearchDefines if speeded up spatial neighbor search is used
randomGeneratorRandom number generator. If is not nullptr, RANSAC is used for homography determination within initial minimum sample set
Returns
True, if successfully completed

◆ jaccardDistance()

Scalar Ocean::Geometry::JLinkage::jaccardDistance ( const IndexSet32 setA,
const IndexSet32 setB 
)
inlinestaticprotected

Calculates the jaccard distance d(A, B) = ( |union(A, B)| - |intersection(A, B)| ) / |union(A, B)|.

Parameters
setAfirst set of indices to compare
setBsecond set of indices to compare
Returns
Jaccard distance [0, 1]

The documentation for this class was generated from the following file: