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