Search in sources :

Example 6 with UtilPoint2D_F64

use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.

the class CompareTwoImagePanel method findBestPoints.

private void findBestPoints(int x, int y, List<Point2D_F64> pts, List<Integer> selected) {
    double bestDist = clickDistance * clickDistance;
    DogArray_I32 bestIndexes = new DogArray_I32(20);
    for (int i = 0; i < pts.size(); i++) {
        if (!isValidPoint(i))
            continue;
        Point2D_F64 p = pts.get(i);
        double d = UtilPoint2D_F64.distanceSq(p.x, p.y, x, y);
        if (d < bestDist) {
            bestDist = d;
            bestIndexes.reset();
            bestIndexes.add(i);
        } else if (Math.abs(d - bestDist) < 0.01) {
            bestIndexes.add(i);
        }
    }
    for (int i = 0; i < bestIndexes.size(); i++) {
        selected.add(bestIndexes.get(i));
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32)

Example 7 with UtilPoint2D_F64

use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.

the class DetectUserActions method isAtLocation.

public boolean isAtLocation(double x, double y) {
    double centerX = 0, centerY = 0;
    for (int i = 0; i < points.size(); i++) {
        Point2D_F64 p = points.points.get(i).p;
        centerX += p.x;
        centerY += p.y;
    }
    centerX /= points.size();
    centerY /= points.size();
    double distance = UtilPoint2D_F64.distanceSq(centerX, centerY, x, y);
    return distance <= thresholdDistance * 4;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64)

Example 8 with UtilPoint2D_F64

use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.

the class TestAssociateImageDistanceEuclideanSq method checkDistance.

@Test
void checkDistance() {
    var alg = new AssociateImageDistanceEuclideanSq();
    alg.setSource(-1, new Point2D_F64(5, 7));
    double expected = UtilPoint2D_F64.distanceSq(5, 7, 10, 1.5);
    assertEquals(expected, alg.distance(-1, new Point2D_F64(10, 1.5)));
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) Test(org.junit.jupiter.api.Test)

Example 9 with UtilPoint2D_F64

use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.

the class TestLlahOperations method findNeighbors.

/**
 * Sees if all the neighbors are found for the specified point. The specified point should not be
 * included in the neighbor list
 */
@Test
void findNeighbors() {
    LlahOperations llahOps = createLlahOps(LlahInvariant.AFFINE);
    List<Point2D_F64> list = UtilPoint2D_F64.random(-1, 1, 20, rand);
    List<Point2D_F64> expected = new ArrayList<>();
    llahOps.nn.setPoints(list, false);
    Point2D_F64 target = list.get(10);
    var distances = new double[list.size()];
    for (int i = 0; i < list.size(); i++) {
        expected.add(list.get(i));
        distances[i] = target.distance(list.get(i));
    }
    new QuickSort_F64().sort(distances, list.size(), expected);
    llahOps.findNeighbors(target);
    for (int i = 0; i < neighborsN; i++) {
        assertTrue(llahOps.neighbors.contains(expected.get(i + 1)));
    }
}
Also used : QuickSort_F64(org.ddogleg.sorting.QuickSort_F64) Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 10 with UtilPoint2D_F64

use of georegression.geometry.UtilPoint2D_F64 in project BoofCV by lessthanoptimal.

the class TestUchiyaMarkerTracker method sequence_Easy.

/**
 * Give it an image sequence and see if it can track the target. Only translation
 */
@Test
void sequence_Easy() {
    int targetID = 2;
    List<Point2D_F64> dots = documents.get(targetID);
    UchiyaMarkerTracker tracker = createTracker();
    for (var doc : documents) {
        tracker.llahOps.createDocument(doc);
    }
    var prevMean = new Point2D_F64();
    var currMean = new Point2D_F64();
    for (int frame = 0; frame < 10; frame++) {
        List<Point2D_F64> copied = new ArrayList<>();
        var affine = new Affine2D_F64(1, 0, 0, 1, frame * 5, frame);
        for (int i = 0; i < dots.size(); i++) {
            Point2D_F64 c = new Point2D_F64();
            AffinePointOps_F64.transform(affine, dots.get(i), c);
            copied.add(c);
        }
        tracker.process(copied);
        DogArray<UchiyaMarkerTracker.Track> tracks = tracker.getCurrentTracks();
        assertEquals(1, tracks.size);
        UchiyaMarkerTracker.Track t = tracks.get(0);
        assertEquals(targetID, t.globalDoc.documentID);
        // Make sure the track is moving in the expected way
        UtilPoint2D_F64.mean(t.predicted.toList(), currMean);
        if (frame > 0) {
            assertEquals(5.0, currMean.x - prevMean.x, 0.5);
        }
        prevMean.setTo(currMean);
    }
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

UtilPoint2D_F64 (georegression.geometry.UtilPoint2D_F64)10 Point2D_F64 (georegression.struct.point.Point2D_F64)10 Test (org.junit.jupiter.api.Test)5 ArrayList (java.util.ArrayList)4 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)2 LlahDocument (boofcv.alg.feature.describe.llah.LlahDocument)1 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)1 Affine2D_F64 (georegression.struct.affine.Affine2D_F64)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 List (java.util.List)1 QuickSort_F64 (org.ddogleg.sorting.QuickSort_F64)1 DogArray (org.ddogleg.struct.DogArray)1 DogArray_I32 (org.ddogleg.struct.DogArray_I32)1