Search in sources :

Example 1 with RectangleRotate_F64

use of boofcv.struct.RectangleRotate_F64 in project BoofCV by lessthanoptimal.

the class TestSparseFlowObjectTracker method checkMotion.

protected void checkMotion(double tranX, double tranY, double rot) {
    GrayU8 frame0 = new GrayU8(320, 240);
    GrayU8 frame1 = new GrayU8(320, 240);
    ImageMiscOps.fillUniform(frame0, rand, 0, 256);
    double c = Math.cos(rot);
    double s = Math.sin(rot);
    new FDistort(frame0, frame1).affine(c, -s, s, c, tranX, tranY).apply();
    SfotConfig config = new SfotConfig();
    ImageGradient<GrayU8, GrayS16> gradient = FactoryDerivative.sobel(GrayU8.class, GrayS16.class);
    SparseFlowObjectTracker<GrayU8, GrayS16> alg = new SparseFlowObjectTracker<>(config, GrayU8.class, GrayS16.class, gradient);
    RectangleRotate_F64 region0 = new RectangleRotate_F64(120, 140, 30, 40, 0.1);
    RectangleRotate_F64 region1 = new RectangleRotate_F64();
    alg.init(frame0, region0);
    assertTrue(alg.update(frame1, region1));
    double expectedX = c * region0.cx - s * region0.cy + tranX;
    double expectedY = s * region0.cx + c * region0.cy + tranY;
    double expectedYaw = UtilAngle.bound(region0.theta + rot);
    assertEquals(expectedX, region1.cx, 0.5);
    assertEquals(expectedY, region1.cy, 0.5);
    assertEquals(expectedYaw, region1.theta, 0.01);
}
Also used : FDistort(boofcv.abst.distort.FDistort) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) RectangleRotate_F64(boofcv.struct.RectangleRotate_F64)

Aggregations

FDistort (boofcv.abst.distort.FDistort)1 RectangleRotate_F64 (boofcv.struct.RectangleRotate_F64)1 GrayS16 (boofcv.struct.image.GrayS16)1 GrayU8 (boofcv.struct.image.GrayU8)1