Search in sources :

Example 21 with ImageType

use of boofcv.struct.image.ImageType in project BoofCV by lessthanoptimal.

the class GenericBackgroundStationaryBasicChecks method checkLearnRate.

@Test
public void checkLearnRate() {
    for (ImageType type : imageTypes) {
        checkLearnRate_slow(type);
        checkLearnRate_fast(type);
    }
}
Also used : ImageType(boofcv.struct.image.ImageType) Test(org.junit.Test)

Example 22 with ImageType

use of boofcv.struct.image.ImageType in project BoofCV by lessthanoptimal.

the class GenericBackgroundStationaryGaussianChecks method learnRate.

@Test
public void learnRate() {
    for (ImageType type : imageTypes) {
        checkLearnRate_slow(type);
        checkLearnRate_fast(type);
    }
}
Also used : ImageType(boofcv.struct.image.ImageType) Test(org.junit.Test)

Example 23 with ImageType

use of boofcv.struct.image.ImageType in project BoofCV by lessthanoptimal.

the class GenericBackgroundMovingGmmChecks method performStationaryTests.

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

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

Example 24 with ImageType

use of boofcv.struct.image.ImageType in project narchy by automenta.

the class ExampleBackgroundRemovalStationary method main.

public static void main(String[] args) {
    WebCam c = new WebCam();
    Tex output = new Tex();
    SpaceGraph.window(new Gridding(c.view(), output.view()), 800, 800);
    // String fileName = UtilIO.pathExample("background/horse_jitter.mp4"); // degraded performance because of jitter
    // String fileName = UtilIO.pathExample("tracking/chipmunk.mjpeg"); // Camera moves.  Stationary will fail here
    // Comment/Uncomment to switch input image type
    ImageType imageType = ImageType.single(GrayF32.class);
    // ImageType imageType = ImageType.il(3, InterleavedF32.class);
    // ImageType imageType = ImageType.il(3, InterleavedU8.class);
    // Configuration for Gaussian model.  Note that the threshold changes depending on the number of image bands
    // 12 = gray scale and 40 = color
    ConfigBackgroundGaussian configGaussian = new ConfigBackgroundGaussian(40, 0.0005f);
    configGaussian.initialVariance = 100;
    configGaussian.minimumDifference = 10f;
    // Comment/Uncomment to switch algorithms
    BackgroundModelStationary background = // FactoryBackgroundModel.stationaryBasic(new ConfigBackgroundBasic(35, 0.005f), imageType);
    FactoryBackgroundModel.stationaryGaussian(configGaussian, imageType);
    // Declare storage for segmented image.  1 = moving foreground and 0 = background
    GrayU8 segmented = new GrayU8(c.width, c.height);
    GrayF32 input = new GrayF32(c.width, c.height);
    BufferedImage segmentedVis = new BufferedImage(c.width, c.height, BufferedImage.TYPE_INT_RGB);
    new Loop(10f) {

        @Override
        public boolean next() {
            BufferedImage img = c.image;
            if (img != null) {
                ConvertBufferedImage.convertFrom(img, input, true);
                // long before = System.nanoTime();
                background.segment(input, segmented);
                background.updateBackground(input);
                byte[] b = segmented.data;
                for (int i = 0; i < b.length; i++) {
                    if (b[i] != 0)
                        b[i] = 127;
                }
                output.update(// segmented
                ConvertBufferedImage.convertTo(segmented, segmentedVis));
            }
            // }
            return true;
        }
    };
}
Also used : Loop(jcog.exe.Loop) Gridding(spacegraph.space2d.container.Gridding) BackgroundModelStationary(boofcv.alg.background.BackgroundModelStationary) GrayF32(boofcv.struct.image.GrayF32) Tex(spacegraph.video.Tex) WebCam(spacegraph.video.WebCam) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ImageType(boofcv.struct.image.ImageType) ConfigBackgroundGaussian(boofcv.factory.background.ConfigBackgroundGaussian)

Example 25 with ImageType

use of boofcv.struct.image.ImageType 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)

Aggregations

ImageType (boofcv.struct.image.ImageType)36 Test (org.junit.Test)19 ImageBase (boofcv.struct.image.ImageBase)14 ArrayList (java.util.ArrayList)11 File (java.io.File)10 PathLabel (boofcv.io.PathLabel)7 BackgroundModelMoving (boofcv.alg.background.BackgroundModelMoving)4 Homography2D_F32 (georegression.struct.homography.Homography2D_F32)4 Se3_F64 (georegression.struct.se.Se3_F64)4 BufferedImage (java.awt.image.BufferedImage)4 GrayU8 (boofcv.struct.image.GrayU8)3 BackgroundModelStationary (boofcv.alg.background.BackgroundModelStationary)2 ConfigBackgroundBasic (boofcv.factory.background.ConfigBackgroundBasic)2 ConfigBackgroundGaussian (boofcv.factory.background.ConfigBackgroundGaussian)2 ConfigBackgroundGmm (boofcv.factory.background.ConfigBackgroundGmm)2 ImageGridPanel (boofcv.gui.image.ImageGridPanel)2 MediaManager (boofcv.io.MediaManager)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 SimpleImageSequence (boofcv.io.image.SimpleImageSequence)2 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)2