use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class GenericTestsDetectDescribeMulti method checkIdenticalResponse.
private void checkIdenticalResponse(DetectDescribeMulti<T, TD> alg1, DetectDescribeMulti<T, TD> alg2) {
for (int n = 0; n < alg1.getNumberOfSets(); n++) {
PointDescSet<TD> set1 = alg1.getFeatureSet(n);
PointDescSet<TD> set2 = alg2.getFeatureSet(n);
int N = set1.getNumberOfFeatures();
assertTrue(N > 1);
assertEquals(N, set2.getNumberOfFeatures());
for (int i = 0; i < N; i++) {
Point2D_F64 p1 = set1.getLocation(i);
Point2D_F64 p2 = set2.getLocation(i);
assertTrue(p1.isIdentical(p2, 1e-16));
TD desc1 = set1.getDescription(i);
TD desc2 = set2.getDescription(i);
for (int j = 0; j < desc1.size(); j++) {
assertTrue(desc1.getDouble(j) == desc2.getDouble(j));
}
}
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class GeneralInterestPointDetectorChecks method checkSubImage.
/**
* Does it handle sub-images correctly?
*/
@Test
public void checkSubImage() {
List<Point2D_F64> original = new ArrayList<>();
List<Point2D_F64> found = new ArrayList<>();
detector.detect(image);
assertTrue(detector.getNumberOfFeatures() > 0);
for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
Point2D_F64 p = detector.getLocation(i);
original.add(p.copy());
}
T subimage = BoofTesting.createSubImageOf(image);
detector.detect(subimage);
for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
Point2D_F64 p = detector.getLocation(i);
found.add(p.copy());
}
// see if processing the two images produces the same results
assertEquals(original.size(), found.size());
for (int i = 0; i < original.size(); i++) {
Point2D_F64 o = original.get(i);
Point2D_F64 f = found.get(i);
assertTrue(o.x == f.x);
assertTrue(o.y == f.y);
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestPointTransformHomography_F64 method compareToDirect.
/**
* Directly computes the output
*/
@Test
public void compareToDirect() {
Point2D_F64 input = new Point2D_F64(50, 60);
Point2D_F64 output = new Point2D_F64();
Point2D_F64 expected = new Point2D_F64();
Homography2D_F64 H = new Homography2D_F64(1, 2, 3, 4, 5, 6, 7, 8, 9);
HomographyPointOps_F64.transform(H, input, expected);
PointTransformHomography_F64 alg = new PointTransformHomography_F64();
alg.set(H);
alg.compute(input.x, input.y, output);
assertEquals(expected.x, output.x, 1e-4);
assertEquals(expected.y, output.y, 1e-4);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class BaseAssociateLocation2DFilter method associate.
@Override
public void associate() {
unassociatedSrc.reset();
matched.reset();
for (int i = 0; i < locationSrc.size(); i++) {
Point2D_F64 p_s = locationSrc.get(i);
D d_s = descSrc.get(i);
setActiveSource(p_s);
double bestScore = maxError;
int bestIndex = -1;
// find the best match in destination list
for (int j = 0; j < locationDst.size(); j++) {
D d_d = descDst.get(j);
// compute distance between the two features
double distance = computeDistanceToSource(locationDst.get(j));
if (distance > maxDistance)
continue;
double score = scoreAssociation.score(d_s, d_d);
if (score < bestScore) {
bestScore = score;
bestIndex = j;
}
}
if (bestIndex == -1) {
unassociatedSrc.add(i);
continue;
}
if (backwardsValidation && !backwardsValidation(i, bestIndex)) {
unassociatedSrc.add(i);
continue;
}
AssociatedIndex m = matched.grow();
m.src = i;
m.dst = bestIndex;
m.fitScore = bestScore;
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class BinaryEllipseDetectorPixel method isApproximatelyElliptical.
/**
* Look at the maximum distance contour points are from the ellipse and see if they exceed a maximum threshold
*/
boolean isApproximatelyElliptical(EllipseRotated_F64 ellipse, List<Point2D_F64> points, int maxSamples) {
closestPoint.setEllipse(ellipse);
double maxDistance2 = maxDistanceFromEllipse * maxDistanceFromEllipse;
if (points.size() <= maxSamples) {
for (int i = 0; i < points.size(); i++) {
Point2D_F64 p = points.get(i);
closestPoint.process(p);
double d = closestPoint.getClosest().distance2(p);
if (d > maxDistance2) {
return false;
}
}
} else {
for (int i = 0; i < maxSamples; i++) {
Point2D_F64 p = points.get(i * points.size() / maxSamples);
closestPoint.process(p);
double d = closestPoint.getClosest().distance2(p);
if (d > maxDistance2) {
return false;
}
}
}
return true;
}
Aggregations