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);
}
}
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);
}
}
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();
}
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;
}
};
}
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();
}
Aggregations