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