Search in sources :

Example 1 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestLensDistortionOps method boundBoxInside_F64.

@Test
public void boundBoxInside_F64() {
    // basic sanity check
    Affine2D_F64 affine = new Affine2D_F64(1, 1, 0, 1, 1, 2);
    PixelTransformAffine_F64 transform = new PixelTransformAffine_F64(affine);
    RectangleLength2D_F64 found = LensDistortionOps.boundBoxInside(20, 10, transform);
    assertEquals(10, found.x0, 1e-8);
    assertEquals(2, found.y0, 1e-8);
    assertEquals(20 - 9, found.width, 1e-8);
    assertEquals(10, found.height, 1e-8);
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) RectangleLength2D_F64(georegression.struct.shapes.RectangleLength2D_F64) Test(org.junit.Test)

Example 2 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class FactoryMotion2D method createMotion2D.

/**
 * Estimates the 2D motion of an image using different models.
 *
 * @param ransacIterations Number of RANSAC iterations
 * @param inlierThreshold Threshold which defines an inlier.
 * @param outlierPrune If a feature is an outlier for this many turns in a row it is dropped. Try 2
 * @param absoluteMinimumTracks New features will be respawned if the number of inliers drop below this number.
 * @param respawnTrackFraction If the fraction of current inliers to the original number of inliers drops below
 *                             this fraction then new features are spawned.  Try 0.3
 * @param respawnCoverageFraction If the area covered drops by this fraction then spawn more features.  Try 0.8
 * @param refineEstimate Should it refine the model estimate using all inliers.
 * @param tracker Point feature tracker.
 * @param motionModel Instance of the model model used. Affine2D_F64 or Homography2D_F64
 * @param <I> Image input type.
 * @param <IT> Model model
 * @return  ImageMotion2D
 */
public static <I extends ImageBase<I>, IT extends InvertibleTransform> ImageMotion2D<I, IT> createMotion2D(int ransacIterations, double inlierThreshold, int outlierPrune, int absoluteMinimumTracks, double respawnTrackFraction, double respawnCoverageFraction, boolean refineEstimate, PointTracker<I> tracker, IT motionModel) {
    ModelManager<IT> manager;
    ModelGenerator<IT, AssociatedPair> fitter;
    DistanceFromModel<IT, AssociatedPair> distance;
    ModelFitter<IT, AssociatedPair> modelRefiner = null;
    if (motionModel instanceof Homography2D_F64) {
        GenerateHomographyLinear mf = new GenerateHomographyLinear(true);
        manager = (ModelManager) new ModelManagerHomography2D_F64();
        fitter = (ModelGenerator) mf;
        if (refineEstimate)
            modelRefiner = (ModelFitter) mf;
        distance = (DistanceFromModel) new DistanceHomographySq();
    } else if (motionModel instanceof Affine2D_F64) {
        manager = (ModelManager) new ModelManagerAffine2D_F64();
        GenerateAffine2D mf = new GenerateAffine2D();
        fitter = (ModelGenerator) mf;
        if (refineEstimate)
            modelRefiner = (ModelFitter) mf;
        distance = (DistanceFromModel) new DistanceAffine2DSq();
    } else if (motionModel instanceof Se2_F64) {
        manager = (ModelManager) new ModelManagerSe2_F64();
        MotionTransformPoint<Se2_F64, Point2D_F64> alg = new MotionSe2PointSVD_F64();
        GenerateSe2_AssociatedPair mf = new GenerateSe2_AssociatedPair(alg);
        fitter = (ModelGenerator) mf;
        distance = (DistanceFromModel) new DistanceSe2Sq();
    // no refine, already optimal
    } else {
        throw new RuntimeException("Unknown model type: " + motionModel.getClass().getSimpleName());
    }
    ModelMatcher<IT, AssociatedPair> modelMatcher = new Ransac(123123, manager, fitter, distance, ransacIterations, inlierThreshold);
    ImageMotionPointTrackerKey<I, IT> lowlevel = new ImageMotionPointTrackerKey<>(tracker, modelMatcher, modelRefiner, motionModel, outlierPrune);
    ImageMotionPtkSmartRespawn<I, IT> smartRespawn = new ImageMotionPtkSmartRespawn<>(lowlevel, absoluteMinimumTracks, respawnTrackFraction, respawnCoverageFraction);
    return new WrapImageMotionPtkSmartRespawn<>(smartRespawn);
}
Also used : Homography2D_F64(georegression.struct.homography.Homography2D_F64) ModelManagerHomography2D_F64(georegression.fitting.homography.ModelManagerHomography2D_F64) Ransac(org.ddogleg.fitting.modelset.ransac.Ransac) MotionSe2PointSVD_F64(georegression.fitting.se.MotionSe2PointSVD_F64) ModelManagerAffine2D_F64(georegression.fitting.affine.ModelManagerAffine2D_F64) AssociatedPair(boofcv.struct.geo.AssociatedPair) ModelManagerHomography2D_F64(georegression.fitting.homography.ModelManagerHomography2D_F64) WrapImageMotionPtkSmartRespawn(boofcv.abst.sfm.d2.WrapImageMotionPtkSmartRespawn) ModelManagerSe2_F64(georegression.fitting.se.ModelManagerSe2_F64) Se2_F64(georegression.struct.se.Se2_F64) ModelManagerSe2_F64(georegression.fitting.se.ModelManagerSe2_F64) ModelManagerAffine2D_F64(georegression.fitting.affine.ModelManagerAffine2D_F64) Affine2D_F64(georegression.struct.affine.Affine2D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) WrapImageMotionPtkSmartRespawn(boofcv.abst.sfm.d2.WrapImageMotionPtkSmartRespawn)

Example 3 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestAffine2DCodec method decode.

@Test
public void decode() {
    Affine2DCodec codec = new Affine2DCodec();
    Affine2D_F64 model = new Affine2D_F64();
    double[] param = new double[6];
    for (int i = 0; i < 6; i++) {
        param[i] = i + 1;
    }
    codec.decode(param, model);
    assertEquals(1, model.a11, 1e-4);
    assertEquals(2, model.a12, 1e-4);
    assertEquals(3, model.a21, 1e-4);
    assertEquals(4, model.a22, 1e-4);
    assertEquals(5, model.tx, 1e-4);
    assertEquals(6, model.ty, 1e-4);
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Test(org.junit.Test)

Example 4 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestDetectCircleHexagonalGrid method process_rotated.

@Test
public void process_rotated() {
    double c = Math.cos(0.4);
    double s = Math.sin(0.4);
    Affine2D_F64 affine = new Affine2D_F64(c, -s, s, c, 100, 100);
    performDetectionCheck(5, 6, 5, 6, affine);
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Test(org.junit.Test)

Example 5 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestDetectCircleHexagonalGrid method process_negative.

@Test
public void process_negative() {
    Affine2D_F64 affine = new Affine2D_F64(1, 0, 0, 1, 100, 100);
    performDetectionCheck(4, 6, 5, 6, affine);
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Test(org.junit.Test)

Aggregations

Affine2D_F64 (georegression.struct.affine.Affine2D_F64)24 Test (org.junit.Test)20 Se2_F64 (georegression.struct.se.Se2_F64)6 GrayF32 (boofcv.struct.image.GrayF32)4 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Rectangle2D_I32 (georegression.struct.shapes.Rectangle2D_I32)3 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)2 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)2 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)2 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)2 WrapImageMotionPtkSmartRespawn (boofcv.abst.sfm.d2.WrapImageMotionPtkSmartRespawn)1 ImageDistort (boofcv.alg.distort.ImageDistort)1 PixelTransformHomography_F32 (boofcv.alg.distort.PixelTransformHomography_F32)1 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)1 AssociatedPair (boofcv.struct.geo.AssociatedPair)1 ModelManagerAffine2D_F64 (georegression.fitting.affine.ModelManagerAffine2D_F64)1 ModelManagerHomography2D_F64 (georegression.fitting.homography.ModelManagerHomography2D_F64)1 ModelManagerSe2_F64 (georegression.fitting.se.ModelManagerSe2_F64)1 MotionSe2PointSVD_F64 (georegression.fitting.se.MotionSe2PointSVD_F64)1 Homography2D_F32 (georegression.struct.homography.Homography2D_F32)1