use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestGeoModelEstimatorNto1 method checkSelectBestSolution.
/**
* Generate one matrix which should match the epipolar constraint and a bunch of random
* ones. See if it selects the correct matrix
*/
@Test
public void checkSelectBestSolution() {
DMatrixRMaj correct = createSolution();
GeoModelEstimatorNto1<DMatrixRMaj, AssociatedPair> alg = new DummyEstimator(new Dummy(correct, 7), distance, 2);
assertTrue(alg.process(obs, found));
// See if it selected the correct matrix
assertTrue(MatrixFeatures_DDRM.isIdentical(found, correct, 1e-8));
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class CheckEstimate1ofEpipolar method checkConstraint.
/**
* Make sure the ordering of the epipolar constraint is computed correctly
*/
@Test
public void checkConstraint() {
init(50, isPixels);
boolean workedOnce = false;
DMatrixRMaj F = new DMatrixRMaj(3, 3);
for (int i = 0; i < 10; i++) {
List<AssociatedPair> pairs = randomPairs(alg.getMinimumPoints());
if (!alg.process(pairs, F)) {
continue;
}
workedOnce = true;
// normalize to ensure proper scaling
double n = CommonOps_DDRM.elementMaxAbs(F);
CommonOps_DDRM.scale(1.0 / n, F);
for (AssociatedPair p : pairs) {
double correct = Math.abs(GeometryMath_F64.innerProd(p.p2, F, p.p1));
double wrong = Math.abs(GeometryMath_F64.innerProd(p.p1, F, p.p2));
assertTrue(correct < wrong * 0.001);
}
}
assertTrue(workedOnce);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class CheckEstimateNofEpipolar method checkConstraint.
/**
* Make sure the ordering of the epipolar constraint is computed correctly
*/
@Test
public void checkConstraint() {
init(50, isPixels);
boolean workedOnce = false;
FastQueue<DMatrixRMaj> solutions = new QueueMatrix(3, 3);
for (int i = 0; i < 10; i++) {
List<AssociatedPair> pairs = randomPairs(alg.getMinimumPoints());
if (!alg.process(pairs, solutions)) {
continue;
}
if (solutions.size() <= 0)
continue;
workedOnce = true;
for (DMatrixRMaj F : solutions.toList()) {
// normalize to ensure proper scaling
double n = CommonOps_DDRM.elementMaxAbs(F);
CommonOps_DDRM.scale(1.0 / n, F);
for (AssociatedPair p : pairs) {
double correct = Math.abs(GeometryMath_F64.innerProd(p.p2, F, p.p1));
double wrong = Math.abs(GeometryMath_F64.innerProd(p.p1, F, p.p2));
assertTrue(correct < wrong * 0.001);
}
}
}
assertTrue(workedOnce);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class GenerateAffine2D method generate.
@Override
public boolean generate(List<AssociatedPair> dataSet, Affine2D_F64 model) {
from.clear();
to.clear();
for (int i = 0; i < dataSet.size(); i++) {
AssociatedPair p = dataSet.get(i);
from.add(p.p1);
to.add(p.p2);
}
if (!fitter.process(from, to))
return false;
model.set(fitter.getTransformSrcToDst());
return true;
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class GenerateSe2_AssociatedPair method generate.
@Override
public boolean generate(List<AssociatedPair> dataSet, Se2_F64 output) {
from.clear();
to.clear();
for (int i = 0; i < dataSet.size(); i++) {
AssociatedPair p = dataSet.get(i);
from.add(p.getP1());
to.add(p.getP2());
}
if (!estimate.process(from, to))
return false;
output.set(estimate.getTransformSrcToDst());
return true;
}
Aggregations