use of boofcv.struct.geo.AssociatedTriple in project BoofCV by lessthanoptimal.
the class TestDistanceTrifocalTransferSq method noise.
@Test
void noise() {
// estimate the tensors to ensure it's in pixels
ConfigTrifocal config = new ConfigTrifocal();
config.which = EnumTrifocal.LINEAR_7;
FactoryMultiView.trifocal_1(config).process(observationsPixels, found);
DistanceTrifocalTransferSq alg = new DistanceTrifocalTransferSq();
alg.setModel(found);
double error = 0.5;
AssociatedTriple tmp = new AssociatedTriple();
for (AssociatedTriple a : observationsPixels) {
tmp.setTo(a);
tmp.p3.x += error;
// the error will be larger than this value but not too much larger
double min = error * error;
double max = 1.5 * min;
double found = alg.distance(tmp);
assertTrue(found >= min && found <= max);
}
}
use of boofcv.struct.geo.AssociatedTriple in project BoofCV by lessthanoptimal.
the class CommonTrifocalChecks method createSceneObservations.
void createSceneObservations(boolean planar) {
P1_k = PerspectiveOps.createCameraMatrix(worldToCam1.R, worldToCam1.T, K, null);
// P1 = [I|0]
P2 = PerspectiveOps.createCameraMatrix(worldToCam2.R, worldToCam2.T, K, null);
P3 = PerspectiveOps.createCameraMatrix(worldToCam3.R, worldToCam3.T, K, null);
tensor = MultiViewOps.createTrifocal(P2, P3, null);
tensorPixels = MultiViewOps.createTrifocal(P1_k, P2, P3, null);
F2 = MultiViewOps.createEssential(worldToCam2.getR(), worldToCam2.getT(), null);
F2 = MultiViewOps.createFundamental(F2, K);
F3 = MultiViewOps.createEssential(worldToCam3.getR(), worldToCam3.getT(), null);
F3 = MultiViewOps.createFundamental(F3, K);
observations = new ArrayList<>();
observationsPixels = new ArrayList<>();
observationsNorm = new ArrayList<>();
for (int i = 0; i < numFeatures; i++) {
Point3D_F64 p = new Point3D_F64();
p.x = rand.nextGaussian() * 0.5;
p.y = rand.nextGaussian() * 0.5;
if (planar) {
p.z = 2;
} else {
p.z = rand.nextGaussian() * 0.5 + 2;
}
worldPts.add(p);
AssociatedTriple o = new AssociatedTriple();
o.p1 = PerspectiveOps.renderPixel(new Se3_F64(), p, null);
o.p2 = PerspectiveOps.renderPixel(P2, p);
o.p3 = PerspectiveOps.renderPixel(P3, p);
AssociatedTriple oP = new AssociatedTriple();
oP.p1 = PerspectiveOps.renderPixel(new Se3_F64(), K, p, null);
oP.p2 = PerspectiveOps.renderPixel(P2, p);
oP.p3 = PerspectiveOps.renderPixel(P3, p);
AssociatedTriple oN = new AssociatedTriple();
oN.p1 = PerspectiveOps.renderPixel(new Se3_F64(), p, null);
oN.p2 = PerspectiveOps.renderPixel(worldToCam2, p, null);
oN.p3 = PerspectiveOps.renderPixel(worldToCam3, p, null);
observations.add(o);
observationsPixels.add(oP);
observationsNorm.add(oN);
}
}
use of boofcv.struct.geo.AssociatedTriple in project BoofCV by lessthanoptimal.
the class TestTrifocalAlgebraicPoint7 method computeTransferError.
/**
* Computes the error using induced homographies.
*/
double computeTransferError(TrifocalTensor tensor, List<AssociatedTriple> observations) {
TrifocalTransfer transfer = new TrifocalTransfer();
transfer.setTrifocal(tensor);
double errors = 0;
for (AssociatedTriple o : observations) {
Point3D_F64 p = new Point3D_F64();
transfer.transfer_1_to_3(o.p1.x, o.p1.y, o.p2.x, o.p2.y, p);
errors += o.p3.distance(p.x / p.z, p.y / p.z);
transfer.transfer_1_to_2(o.p1.x, o.p1.y, o.p3.x, o.p3.y, p);
errors += o.p2.distance(p.x / p.z, p.y / p.z);
}
return errors / (2 * observations.size());
}
Aggregations