use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestGenerateScaleTranslate2D method pathological_noscale.
/**
* Both points are at 0,0. Scale can't be resolved
*/
@Test
public void pathological_noscale() {
ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
AssociatedPair a = TestDistanceScaleTranslate2DSq.apply(0, 0, model);
AssociatedPair b = TestDistanceScaleTranslate2DSq.apply(0, 0, model);
List<AssociatedPair> obs = new ArrayList<>();
obs.add(a);
obs.add(b);
ScaleTranslate2D found = new ScaleTranslate2D();
GenerateScaleTranslate2D alg = new GenerateScaleTranslate2D();
assertFalse(alg.generate(obs, found));
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestGenerateScaleTranslate2D method perfect.
@Test
public void perfect() {
ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
AssociatedPair a = TestDistanceScaleTranslate2DSq.apply(-5, 4, model);
AssociatedPair b = TestDistanceScaleTranslate2DSq.apply(2, 3, model);
List<AssociatedPair> obs = new ArrayList<>();
obs.add(a);
obs.add(b);
ScaleTranslate2D found = new ScaleTranslate2D();
GenerateScaleTranslate2D alg = new GenerateScaleTranslate2D();
assertTrue(alg.generate(obs, found));
assertEquals(model.transX, found.transX, 1e-8);
assertEquals(model.transY, found.transY, 1e-8);
assertEquals(model.scale, found.scale, 1e-8);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestGenerateScaleTranslateRotate2D method perfect.
@Test
public void perfect() {
for (int i = 0; i < 100; i++) {
double theta = rand.nextDouble() * Math.PI * 2 - Math.PI;
double scale = rand.nextDouble() * 5 + 0.1;
ScaleTranslateRotate2D model = new ScaleTranslateRotate2D(theta, scale, -2, 3);
AssociatedPair a = TestDistanceScaleTranslateRotate2DSq.apply(-5, 4, model);
AssociatedPair b = TestDistanceScaleTranslateRotate2DSq.apply(2, 3, model);
AssociatedPair c = TestDistanceScaleTranslateRotate2DSq.apply(-3, 2, model);
List<AssociatedPair> obs = new ArrayList<>();
obs.add(a);
obs.add(b);
obs.add(c);
ScaleTranslateRotate2D found = new ScaleTranslateRotate2D();
GenerateScaleTranslateRotate2D alg = new GenerateScaleTranslateRotate2D();
assertTrue(alg.generate(obs, found));
assertEquals(model.transX, found.transX, 1e-8);
assertEquals(model.transY, found.transY, 1e-8);
assertEquals(model.scale, found.scale, 1e-8);
assertEquals(model.theta, found.theta, 1e-8);
}
}
use of boofcv.struct.geo.AssociatedPair in project narchy by automenta.
the class ExampleStereoTwoViewsOneCamera method computeMatches.
/**
* Use the associate point feature example to create a list of {@link AssociatedPair} for use in computing the
* fundamental matrix.
*/
public void computeMatches(GrayF32 left, GrayF32 right) {
DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 0, 1, 9, 4, 4), null, null, GrayF32.class);
// DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 0.9, true);
ExampleAssociatePoints<GrayF32, BrightFeature> findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
findMatches.associate(left, right);
FastQueue<AssociatedIndex> matchIndexes = associate.getMatches();
matchedFeatures.clear();
for (int i = 0; i < matchIndexes.size; i++) {
AssociatedIndex a = matchIndexes.get(i);
matchedFeatures.add(new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst)));
}
}
use of boofcv.struct.geo.AssociatedPair in project narchy by automenta.
the class ExampleStereoTwoViewsOneCamera method drawInliers.
/**
* Draw inliers for debugging purposes. Need to convert from normalized to pixel coordinates.
*/
public void drawInliers(CameraPinholeRadial intrinsic, List<AssociatedPair> normalized) {
Point2Transform2_F64 n_to_p = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
List<AssociatedPair> pixels = new ArrayList<>(normalized.size());
for (AssociatedPair n : normalized) {
AssociatedPair p = new AssociatedPair();
n_to_p.compute(n.p1.x, n.p1.y, p.p1);
n_to_p.compute(n.p2.x, n.p2.y, p.p2);
pixels.add(p);
}
// display the results
assocPanel.setAssociation(pixels);
assocPanel.setImages(ConvertBufferedImage.extractBuffered(distortedPrev), ConvertBufferedImage.extractBuffered(distortedNext));
assocPanel.repaint();
assocPanel.setSize(500, 100);
}
Aggregations