Search in sources :

Example 1 with RectangleLength2D_F32

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

the class TestLensDistortionOps method boundBoxInside_F32.

@Test
public void boundBoxInside_F32() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 1, 0, 1, 1, 2);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_F32 found = LensDistortionOps.boundBoxInside(20, 10, transform);
    assertEquals(10, found.x0, 1e-4);
    assertEquals(2, found.y0, 1e-4);
    assertEquals(20 - 9, found.width, 1e-4);
    assertEquals(10, 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 2 with RectangleLength2D_F32

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

the class CirculantVisualizationPanel method update.

public synchronized void update(final CirculantTracker tracker) {
    if (hasSelected) {
        RectangleLength2D_F32 r = tracker.getTargetLocation();
        selected.x0 = (int) r.x0;
        selected.y0 = (int) r.y0;
        selected.x1 = selected.x0 + (int) r.width;
        selected.y1 = selected.y0 + (int) r.height;
        GrayF64 template = tracker.getTargetTemplate();
        GrayF64 response = tracker.getResponse();
        if (this.template == null) {
            this.template = new BufferedImage(template.width, template.height, BufferedImage.TYPE_INT_RGB);
            this.response = new BufferedImage(template.width, template.height, BufferedImage.TYPE_INT_RGB);
            tmp.reshape(template.width, template.height);
        }
        ConvertImage.convert(template, tmp);
        PixelMath.plus(tmp, 0.5f, tmp);
        PixelMath.multiply(tmp, 255, 0, 255, tmp);
        ConvertBufferedImage.convertTo(tmp, this.template, true);
        ConvertImage.convert(response, tmp);
        VisualizeImageData.colorizeSign(tmp, this.response, -1);
    }
    repaint();
}
Also used : GrayF64(boofcv.struct.image.GrayF64) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 3 with RectangleLength2D_F32

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

the class VisualizeCirculantTrackerApp method process.

public void process(final SimpleImageSequence<T> sequence) {
    if (!sequence.hasNext())
        throw new IllegalArgumentException("Empty sequence");
    image = sequence.next();
    gui.setFrame((BufferedImage) sequence.getGuiImage());
    ShowImages.showWindow(gui, "Circulant Tracker", true);
    // tracker.initialize(image,273,156,358-273,293-156);
    paused = true;
    while (paused) {
        Thread.yield();
    }
    int totalFrames = 0;
    long totalTime = 0;
    while (sequence.hasNext()) {
        totalFrames++;
        image = sequence.next();
        gui.setFrame((BufferedImage) sequence.getGuiImage());
        long before = System.nanoTime();
        tracker.performTracking(image);
        long after = System.nanoTime();
        totalTime += after - before;
        System.out.println("FPS = " + (totalFrames) / (totalTime / 2e9));
        gui.update(tracker);
        RectangleLength2D_F32 r = tracker.getTargetLocation();
        System.out.println("Target: " + r);
        gui.repaint();
        while (paused) {
            Thread.yield();
        }
    }
    System.out.println("DONE");
}
Also used : RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32)

Example 4 with RectangleLength2D_F32

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

the class ImplRectifyImageOps_F32 method allInsideLeft.

public static void allInsideLeft(int imageWidth, int imageHeight, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight) {
    PointTransformHomography_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft);
    RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(imageWidth, imageHeight, new PointToPixelTransform_F32(tranLeft));
    float scaleX = imageWidth / (float) bound.width;
    float scaleY = imageHeight / (float) bound.height;
    float scale = (float) Math.max(scaleX, scaleY);
    adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale);
}
Also used : PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32)

Example 5 with RectangleLength2D_F32

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

the class ImplRectifyImageOps_F32 method allInsideLeft.

public static void allInsideLeft(CameraPinholeRadial paramLeft, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight, FMatrixRMaj rectifyK) {
    // need to take in account the order in which image distort will remove rectification later on
    paramLeft = new CameraPinholeRadial(paramLeft);
    Point2Transform2_F32 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
    RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(tranLeft));
    LensDistortionOps.roundInside(bound);
    float scaleX = paramLeft.width / (float) bound.width;
    float scaleY = paramLeft.height / (float) bound.height;
    float scale = (float) Math.max(scaleX, scaleY);
    adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_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