Search in sources :

Example 21 with Point2D_F64

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));
            }
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 22 with Point2D_F64

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);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with Point2D_F64

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);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Homography2D_F64(georegression.struct.homography.Homography2D_F64) Test(org.junit.Test)

Example 24 with Point2D_F64

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;
    }
}
Also used : AssociateDescription2D(boofcv.abst.feature.associate.AssociateDescription2D) Point2D_F64(georegression.struct.point.Point2D_F64) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 25 with Point2D_F64

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;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Aggregations

Point2D_F64 (georegression.struct.point.Point2D_F64)360 Test (org.junit.Test)129 Point3D_F64 (georegression.struct.point.Point3D_F64)85 Se3_F64 (georegression.struct.se.Se3_F64)68 ArrayList (java.util.ArrayList)57 DMatrixRMaj (org.ejml.data.DMatrixRMaj)48 AssociatedPair (boofcv.struct.geo.AssociatedPair)28 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)16 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)15 GrayF32 (boofcv.struct.image.GrayF32)13 Vector3D_F64 (georegression.struct.point.Vector3D_F64)13 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)13 Point2D3D (boofcv.struct.geo.Point2D3D)11 GrayU8 (boofcv.struct.image.GrayU8)11 Point2D_I32 (georegression.struct.point.Point2D_I32)11 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)10 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)9 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)8 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 BufferedImage (java.awt.image.BufferedImage)8