Search in sources :

Example 1 with RemovePerspectiveDistortion

use of boofcv.alg.distort.RemovePerspectiveDistortion in project BoofCV by lessthanoptimal.

the class ExampleRemovePerspectiveDistortion method main.

public static void main(String[] args) {
    // load a color image
    BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample("goals_and_stuff.jpg"));
    Planar<GrayF32> input = ConvertBufferedImage.convertFromPlanar(buffered, null, true, GrayF32.class);
    RemovePerspectiveDistortion<Planar<GrayF32>> removePerspective = new RemovePerspectiveDistortion<>(400, 500, ImageType.pl(3, GrayF32.class));
    // Order matters! top-left, top-right, bottom-right, bottom-left
    if (!removePerspective.apply(input, new Point2D_F64(267, 182), new Point2D_F64(542, 68), new Point2D_F64(519, 736), new Point2D_F64(276, 570))) {
        throw new RuntimeException("Failed!?!?");
    }
    Planar<GrayF32> output = removePerspective.getOutput();
    BufferedImage flat = ConvertBufferedImage.convertTo_F32(output, null, true);
    ShowImages.showWindow(buffered, "Original Image", true);
    ShowImages.showWindow(flat, "Without Perspective Distortion", true);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) RemovePerspectiveDistortion(boofcv.alg.distort.RemovePerspectiveDistortion) Point2D_F64(georegression.struct.point.Point2D_F64) Planar(boofcv.struct.image.Planar) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Aggregations

RemovePerspectiveDistortion (boofcv.alg.distort.RemovePerspectiveDistortion)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 GrayF32 (boofcv.struct.image.GrayF32)1 Planar (boofcv.struct.image.Planar)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1 BufferedImage (java.awt.image.BufferedImage)1