Search in sources :

Example 6 with Homography2D_F32

use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.

the class GenericBackgroundModelMovingChecks method markNoBackgroundAsBackground.

private <T extends ImageBase<T>> void markNoBackgroundAsBackground(ImageType<T> imageType) {
    T frame = imageType.createImage(width, height);
    GrayU8 segmented = new GrayU8(width, height);
    BackgroundModelMoving<T, Homography2D_F32> alg = create(frame.getImageType());
    alg.setUnknownValue(2);
    Homography2D_F32 homeToWorld = new Homography2D_F32();
    alg.initialize(width, height, homeToWorld);
    Homography2D_F32 homeToCurrent = new Homography2D_F32();
    homeToCurrent.a13 = 5;
    alg.updateBackground(homeToCurrent, frame);
    alg.segment(homeToCurrent, frame, segmented);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < 5; x++) {
            assertEquals(2, segmented.get(x, y));
        }
        for (int x = 5; x < width; x++) {
            assertEquals(0, segmented.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Homography2D_F32(georegression.struct.homography.Homography2D_F32)

Example 7 with Homography2D_F32

use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.

the class GenericBackgroundModelMovingChecks method reset.

private <T extends ImageBase<T>> void reset(ImageType<T> imageType) {
    T frame = imageType.createImage(width, height);
    BackgroundModelMoving<T, Homography2D_F32> alg = create(frame.getImageType());
    Homography2D_F32 homeToWorld = new Homography2D_F32(1, 0, width / 2, 0, 1, height / 2, 0, 0, 1);
    alg.initialize(width * 2, height * 2, homeToWorld);
    Homography2D_F32 homeToCurrent = new Homography2D_F32();
    GImageMiscOps.fill(frame, 100);
    alg.updateBackground(homeToCurrent, frame);
    alg.reset();
    GImageMiscOps.fill(frame, 50);
    alg.updateBackground(homeToCurrent, frame);
    GrayU8 segmented = new GrayU8(width, height);
    GrayU8 expected = new GrayU8(width, height);
    // there should be no change
    // if reset isn't the case then this will fail
    alg.segment(homeToCurrent, frame, segmented);
    BoofTesting.assertEquals(expected, segmented, 1e-8);
    GImageMiscOps.fill(frame, 100);
    ImageMiscOps.fill(expected, 1);
    // it should be all changed.  really just a sanity check
    alg.segment(homeToCurrent, frame, segmented);
    BoofTesting.assertEquals(expected, segmented, 1e-8);
}
Also used : Homography2D_F32(georegression.struct.homography.Homography2D_F32) GrayU8(boofcv.struct.image.GrayU8)

Example 8 with Homography2D_F32

use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.

the class GenericBackgroundMovingBasicChecks method performStationaryTests.

@Test
public void performStationaryTests() {
    GenericBackgroundStationaryBasicChecks stationary = new GenericBackgroundStationaryBasicChecks() {

        @Override
        public BackgroundModelStationary create(ImageType imageType) {
            BackgroundModelMoving moving = GenericBackgroundMovingBasicChecks.this.create(imageType);
            return new MovingToStationary((BackgroundMovingBasic) moving, new Homography2D_F32());
        }
    };
    stationary.checkLearnRate();
    stationary.checkThreshold();
    stationary.checkBandsUsed();
}
Also used : GenericBackgroundStationaryBasicChecks(boofcv.alg.background.stationary.GenericBackgroundStationaryBasicChecks) BackgroundModelMoving(boofcv.alg.background.BackgroundModelMoving) Homography2D_F32(georegression.struct.homography.Homography2D_F32) ImageType(boofcv.struct.image.ImageType) Test(org.junit.Test)

Example 9 with Homography2D_F32

use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.

the class GenericBackgroundMovingGaussianChecks method performStationaryTests.

@Test
public void performStationaryTests() {
    GenericBackgroundStationaryGaussianChecks stationary = new GenericBackgroundStationaryGaussianChecks() {

        @Override
        public BackgroundModelStationary create(ImageType imageType) {
            BackgroundModelMoving moving = GenericBackgroundMovingGaussianChecks.this.create(imageType);
            return new MovingToStationary((BackgroundMovingGaussian) moving, new Homography2D_F32());
        }
    };
    stationary.initialVariance();
    stationary.minimumDifference();
    stationary.learnRate();
    stationary.checkBandsUsed();
}
Also used : BackgroundModelMoving(boofcv.alg.background.BackgroundModelMoving) GenericBackgroundStationaryGaussianChecks(boofcv.alg.background.stationary.GenericBackgroundStationaryGaussianChecks) Homography2D_F32(georegression.struct.homography.Homography2D_F32) ImageType(boofcv.struct.image.ImageType) Test(org.junit.Test)

Example 10 with Homography2D_F32

use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.

the class TestBackgroundModelMoving method segment.

@Test
public void segment() {
    Helper helper = new Helper();
    helper.initialize(400, 600, new Homography2D_F32(1, 0, 100, 0, 1, 150, 0, 0, 1));
    helper.segment(new Homography2D_F32(1, 0, -10, 0, 1, -15, 0, 0, 1), new GrayU8(100, 120), new GrayU8(100, 120));
}
Also used : Homography2D_F32(georegression.struct.homography.Homography2D_F32) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Aggregations

Homography2D_F32 (georegression.struct.homography.Homography2D_F32)18 GrayU8 (boofcv.struct.image.GrayU8)8 Test (org.junit.Test)7 BackgroundModelMoving (boofcv.alg.background.BackgroundModelMoving)4 ImageType (boofcv.struct.image.ImageType)4 Random (java.util.Random)3 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)2 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 PointTracker (boofcv.abst.feature.tracker.PointTracker)1 GenericBackgroundStationaryBasicChecks (boofcv.alg.background.stationary.GenericBackgroundStationaryBasicChecks)1 GenericBackgroundStationaryGaussianChecks (boofcv.alg.background.stationary.GenericBackgroundStationaryGaussianChecks)1 GenericBackgroundStationaryGmmChecks (boofcv.alg.background.stationary.GenericBackgroundStationaryGmmChecks)1 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)1 PixelTransformHomography_F32 (boofcv.alg.distort.PixelTransformHomography_F32)1 PointTransformHomography_F32 (boofcv.alg.distort.PointTransformHomography_F32)1 ConfigBackgroundBasic (boofcv.factory.background.ConfigBackgroundBasic)1 ConfigBackgroundGaussian (boofcv.factory.background.ConfigBackgroundGaussian)1 ConfigBackgroundGmm (boofcv.factory.background.ConfigBackgroundGmm)1