Search in sources :

Example 11 with RectangleLength2D_F32

use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.

the class DistortImageOps method boundBox_F32.

/**
 * Finds an axis-aligned bounding box which would contain a image after it has been transformed.
 * The returned bounding box can be larger then the original image.
 *
 * @param srcWidth Width of the source image
 * @param srcHeight Height of the source image
 * @param transform Transform being applied to the image
 * @return Bounding box
 */
public static RectangleLength2D_F32 boundBox_F32(int srcWidth, int srcHeight, PixelTransform2_F32 transform) {
    ImageRectangle_F32 r = new ImageRectangle_F32();
    r.x0 = r.y0 = Float.MAX_VALUE;
    r.x1 = r.y1 = -Float.MAX_VALUE;
    for (int y = 0; y < srcHeight; y++) {
        transform.compute(0, y);
        updateBoundBox(transform, r);
        transform.compute(srcWidth, y);
        updateBoundBox(transform, r);
    }
    for (int x = 0; x < srcWidth; x++) {
        transform.compute(x, 0);
        updateBoundBox(transform, r);
        transform.compute(x, srcHeight);
        updateBoundBox(transform, r);
    }
    return new RectangleLength2D_F32(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0);
}
Also used : ImageRectangle_F32(boofcv.struct.ImageRectangle_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32)

Example 12 with RectangleLength2D_F32

use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.

the class TestDistortImageOps method boundBox_F32.

@Test
public void boundBox_F32() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 0, 0, 1, 2, 3);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_F32 found = DistortImageOps.boundBox_F32(10, 20, transform);
    assertEquals(2, found.x0, 1e-4);
    assertEquals(3, found.y0, 1e-4);
    assertEquals(10, found.width, 1e-4);
    assertEquals(20, found.height, 1e-4);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32) Test(org.junit.Test)

Example 13 with RectangleLength2D_F32

use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.

the class Circulant_to_TrackerObjectQuad method process.

@Override
public boolean process(T image, Quadrilateral_F64 results) {
    tracker.performTracking(image);
    RectangleLength2D_F32 r = tracker.getTargetLocation();
    if (r.x0 >= image.width || r.y0 >= image.height)
        return false;
    if (r.x0 + r.width < 0 || r.y0 + r.height < 0)
        return false;
    float x0 = r.x0;
    float y0 = r.y0;
    float x1 = r.x0 + r.width;
    float y1 = r.y0 + r.height;
    results.a.x = x0;
    results.a.y = y0;
    results.b.x = x1;
    results.b.y = y0;
    results.c.x = x1;
    results.c.y = y1;
    results.d.x = x0;
    results.d.y = y1;
    return true;
}
Also used : RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32)

Aggregations

RectangleLength2D_F32 (georegression.struct.shapes.RectangleLength2D_F32)13 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)4 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)4 SequencePoint2Transform2_F32 (boofcv.struct.distort.SequencePoint2Transform2_F32)4 Test (org.junit.Test)4 PointTransformHomography_F32 (boofcv.alg.distort.PointTransformHomography_F32)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 GrayF32 (boofcv.struct.image.GrayF32)2 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 ImageRectangle_F32 (boofcv.struct.ImageRectangle_F32)1 GrayF64 (boofcv.struct.image.GrayF64)1 BufferedImage (java.awt.image.BufferedImage)1 FMatrixRMaj (org.ejml.data.FMatrixRMaj)1