Search in sources :

Example 11 with Homography2D_F32

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

the class TestBackgroundModelMoving method updateBackground.

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

Example 12 with Homography2D_F32

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

the class GenericBackgroundModelMovingChecks method checkSubImage_process.

private <T extends ImageBase<T>> void checkSubImage_process(T frame, GrayU8 segmented) {
    rand = new Random(2345);
    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);
    for (int i = 0; i < 5; i++) {
        Homography2D_F32 homeToCurrent = new Homography2D_F32();
        if (i > 0) {
            homeToCurrent.a13 = rand.nextFloat() * 5 - 2.5f;
            homeToCurrent.a23 = rand.nextFloat() * 5 - 2.5f;
        }
        noise(100, 30, frame);
        alg.updateBackground(homeToCurrent, frame);
    }
    Homography2D_F32 homeToCurrent = new Homography2D_F32();
    noise(100, 30, frame);
    alg.segment(homeToCurrent, frame, segmented);
}
Also used : Random(java.util.Random) Homography2D_F32(georegression.struct.homography.Homography2D_F32)

Example 13 with Homography2D_F32

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

the class GenericBackgroundModelMovingChecks method markUnobservedAsUnknown.

private <T extends ImageBase<T>> void markUnobservedAsUnknown(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();
    alg.segment(homeToCurrent, frame, segmented);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            assertEquals(2, segmented.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Homography2D_F32(georegression.struct.homography.Homography2D_F32)

Example 14 with Homography2D_F32

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

the class GenericBackgroundModelMovingChecks method basicCheck.

private <T extends ImageBase<T>> void basicCheck(ImageType<T> imageType) {
    BackgroundModelMoving<T, Homography2D_F32> alg = create(imageType);
    T frame = imageType.createImage(width, height);
    Homography2D_F32 homeToWorld = new Homography2D_F32(1, 0, width / 2, 0, 1, height / 2, 0, 0, 1);
    alg.initialize(width * 2, height * 2, homeToWorld);
    for (int i = 0; i < 30; i++) {
        Homography2D_F32 homeToCurrent = new Homography2D_F32();
        if (i > 0) {
            homeToCurrent.a13 = rand.nextFloat() * 5 - 2.5f;
            homeToCurrent.a23 = rand.nextFloat() * 5 - 2.5f;
        }
        noise(100, 2, frame);
        alg.updateBackground(new Homography2D_F32(), frame);
    }
    int x0 = 10, y0 = 12, x1 = 40, y1 = 38;
    noise(100, 2, frame);
    GImageMiscOps.fillRectangle(frame, 200, x0, y0, x1 - x0, y1 - y0);
    Homography2D_F32 homeToCurrent = new Homography2D_F32();
    GrayU8 segmented = new GrayU8(width, height);
    alg.segment(homeToCurrent, frame, segmented);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (x >= x0 && x < x1 && y >= y0 && y < y1) {
                assertEquals(1, segmented.get(x, y));
            } else {
                assertEquals(0, segmented.get(x, y));
            }
        }
    }
}
Also used : Homography2D_F32(georegression.struct.homography.Homography2D_F32) GrayU8(boofcv.struct.image.GrayU8)

Example 15 with Homography2D_F32

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

the class BenchmarkPixelTransform method main.

public static void main(String[] args) {
    Random rand = new Random(234);
    Affine2D_F32 affine = new Affine2D_F32((float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian());
    Homography2D_F32 homography = new Homography2D_F32((float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian(), (float) rand.nextGaussian());
    System.out.println("=========  Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
    System.out.println();
    benchmark(new PixelTransformHomography_F32(homography), "Homography");
    benchmark(new PixelTransformAffine_F32(affine), "Affine");
}
Also used : Random(java.util.Random) Affine2D_F32(georegression.struct.affine.Affine2D_F32) Homography2D_F32(georegression.struct.homography.Homography2D_F32)

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