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