use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class CheckRefineFundamental method perfectInput.
@Test
public void perfectInput() {
init(30, false);
// compute true essential matrix
DMatrixRMaj E = MultiViewOps.createEssential(worldToCamera.getR(), worldToCamera.getT());
ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
// give it the perfect matrix and see if it screwed it up
assertTrue(alg.fitModel(pairs, E, found));
// normalize so that they are the same
CommonOps_DDRM.divide(E, E.get(2, 2));
CommonOps_DDRM.divide(found, found.get(2, 2));
assertTrue(MatrixFeatures_DDRM.isEquals(E, found, 1e-8));
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class CheckRefineFundamental method incorrectInput.
@Test
public void incorrectInput() {
init(30, false);
// compute true essential matrix
DMatrixRMaj E = MultiViewOps.createEssential(worldToCamera.getR(), worldToCamera.getT());
// create an alternative incorrect matrix
Vector3D_F64 T = worldToCamera.getT().copy();
T.x += 0.1;
DMatrixRMaj Emod = MultiViewOps.createEssential(worldToCamera.getR(), T);
ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
// compute and compare results
assertTrue(alg.fitModel(pairs, Emod, found));
// normalize to allow comparison
CommonOps_DDRM.divide(E, E.get(2, 2));
CommonOps_DDRM.divide(Emod, Emod.get(2, 2));
CommonOps_DDRM.divide(found, found.get(2, 2));
double error0 = 0;
double error1 = 0;
// very crude error metric
for (int i = 0; i < 9; i++) {
error0 += Math.abs(Emod.data[i] - E.data[i]);
error1 += Math.abs(found.data[i] - E.data[i]);
}
// System.out.println("error "+error1+" other "+error0);
assertTrue(error1 < error0);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class FactoryMultiViewRobust method epipolarLMedS.
private static LeastMedianOfSquares<Se3_F64, AssociatedPair> epipolarLMedS(Estimate1ofEpipolar epipolar, CameraPinholeRadial intrinsic, ConfigLMedS configLMedS) {
TriangulateTwoViewsCalibrated triangulate = FactoryMultiView.triangulateTwoGeometric();
ModelManager<Se3_F64> manager = new ModelManagerSe3_F64();
ModelGenerator<Se3_F64, AssociatedPair> generateEpipolarMotion = new Se3FromEssentialGenerator(epipolar, triangulate);
DistanceFromModel<Se3_F64, AssociatedPair> distanceSe3 = new DistanceSe3SymmetricSq(triangulate, intrinsic.fx, intrinsic.fy, intrinsic.skew, intrinsic.fx, intrinsic.fy, intrinsic.skew);
LeastMedianOfSquares<Se3_F64, AssociatedPair> config = new LeastMedianOfSquares<>(configLMedS.randSeed, configLMedS.totalCycles, manager, generateEpipolarMotion, distanceSe3);
config.setErrorFraction(configLMedS.errorFraction);
return config;
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class DistanceHomographySq method computeDistance.
@Override
public void computeDistance(List<AssociatedPair> points, double[] distance) {
for (int i = 0; i < points.size(); i++) {
AssociatedPair p = points.get(i);
HomographyPointOps_F64.transform(model, p.p1, expected);
distance[i] = expected.distance2(p.p2);
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class ExampleMultiviewSceneReconstruction method estimateStereoPose.
/**
* Given two images compute the relative location of each image using the essential matrix.
*/
protected boolean estimateStereoPose(int imageA, int imageB, Se3_F64 motionAtoB, List<AssociatedIndex> inliers) {
// associate the features together
associate.setSource(imageVisualFeatures.get(imageA));
associate.setDestination(imageVisualFeatures.get(imageB));
associate.associate();
FastQueue<AssociatedIndex> matches = associate.getMatches();
// create the associated pair for motion estimation
FastQueue<Point2D_F64> pixelsA = imagePixels.get(imageA);
FastQueue<Point2D_F64> pixelsB = imagePixels.get(imageB);
List<AssociatedPair> pairs = new ArrayList<>();
for (int i = 0; i < matches.size(); i++) {
AssociatedIndex a = matches.get(i);
pairs.add(new AssociatedPair(pixelsA.get(a.src), pixelsB.get(a.dst)));
}
if (!estimateEssential.process(pairs))
throw new RuntimeException("Motion estimation failed");
List<AssociatedPair> inliersEssential = estimateEssential.getMatchSet();
motionAtoB.set(estimateEssential.getModelParameters());
for (int i = 0; i < inliersEssential.size(); i++) {
int index = estimateEssential.getInputIndex(i);
inliers.add(matches.get(index));
}
return true;
}
Aggregations