Search in sources :

Example 1 with LlahDocument

use of boofcv.alg.feature.describe.llah.LlahDocument in project BoofCV by lessthanoptimal.

the class TestUchiyaMarkerTracker method fitHomography.

@Test
void fitHomography() {
    var doc_to_image = new Homography2D_F64(2, 0, 10, 0, 1.5, -5.6, 0, 0, 1);
    List<Point2D_F64> landmarks = UtilPoint2D_F64.random(-1, 1, 10, rand);
    List<Point2D_F64> dots = new ArrayList<>();
    for (var m : landmarks) {
        var d = new Point2D_F64();
        HomographyPointOps_F64.transform(doc_to_image, m, d);
        dots.add(d);
    }
    // Shuffle the order to test to see if the correct book keeping is being done
    List<Point2D_F64> dotsShuffled = new ArrayList<>(dots);
    Collections.shuffle(dotsShuffled, rand);
    var document = new LlahDocument();
    document.landmarks.copyAll(landmarks, (src, dst) -> dst.setTo(src));
    var observed = new LlahOperations.FoundDocument();
    observed.init(document);
    for (int i = 0; i < landmarks.size(); i++) {
        observed.landmarkHits.data[i] = 1000;
        observed.landmarkToDots.data[i] = dotsShuffled.indexOf(dots.get(i));
    }
    UchiyaMarkerTracker alg = createTracker();
    assertTrue(alg.fitHomography(dotsShuffled, observed));
    Homography2D_F64 found = alg.ransac.getModelParameters();
    CommonOps_DDF3.divide(found, found.a33);
    assertTrue(MatrixFeatures_DDF3.isIdentical(doc_to_image, found, UtilEjml.TEST_F64));
}
Also used : LlahDocument(boofcv.alg.feature.describe.llah.LlahDocument) Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) ArrayList(java.util.ArrayList) Homography2D_F64(georegression.struct.homography.Homography2D_F64) Test(org.junit.jupiter.api.Test)

Aggregations

LlahDocument (boofcv.alg.feature.describe.llah.LlahDocument)1 UtilPoint2D_F64 (georegression.geometry.UtilPoint2D_F64)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1