Search in sources :

Example 1 with SelectOverheadParameters

use of boofcv.alg.sfm.overhead.SelectOverheadParameters in project BoofCV by lessthanoptimal.

the class ExampleOverheadView method main.

public static void main(String[] args) {
    BufferedImage input = UtilImageIO.loadImage(UtilIO.pathExample("road/left01.png"));
    Planar<GrayU8> imageRGB = ConvertBufferedImage.convertFromPlanar(input, null, true, GrayU8.class);
    StereoParameters stereoParam = CalibrationIO.load(UtilIO.pathExample("road/stereo01.yaml"));
    Se3_F64 groundToLeft = CalibrationIO.load(UtilIO.pathExample("road/ground_to_left_01.yaml"));
    CreateSyntheticOverheadView<Planar<GrayU8>> generateOverhead = new CreateSyntheticOverheadViewPL<>(InterpolationType.BILINEAR, 3, GrayU8.class);
    // size of cells in the overhead image in world units
    double cellSize = 0.05;
    // You can use this to automatically select reasonable values for the overhead image
    SelectOverheadParameters selectMapSize = new SelectOverheadParameters(cellSize, 20, 0.5);
    selectMapSize.process(stereoParam.left, groundToLeft);
    int overheadWidth = selectMapSize.getOverheadWidth();
    int overheadHeight = selectMapSize.getOverheadHeight();
    Planar<GrayU8> overheadRGB = new Planar<>(GrayU8.class, overheadWidth, overheadHeight, 3);
    generateOverhead.configure(stereoParam.left, groundToLeft, selectMapSize.getCenterX(), selectMapSize.getCenterY(), cellSize, overheadRGB.width, overheadRGB.height);
    generateOverhead.process(imageRGB, overheadRGB);
    // note that the left/right values are swapped in the overhead image.  This is an artifact of the plane's
    // 2D coordinate system having +y pointing up, while images have +y pointing down.
    BufferedImage output = ConvertBufferedImage.convertTo(overheadRGB, null, true);
    ShowImages.showWindow(input, "Input Image", true);
    ShowImages.showWindow(output, "Overhead Image", true);
}
Also used : CreateSyntheticOverheadViewPL(boofcv.alg.sfm.overhead.CreateSyntheticOverheadViewPL) SelectOverheadParameters(boofcv.alg.sfm.overhead.SelectOverheadParameters) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) StereoParameters(boofcv.struct.calib.StereoParameters) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

CreateSyntheticOverheadViewPL (boofcv.alg.sfm.overhead.CreateSyntheticOverheadViewPL)1 SelectOverheadParameters (boofcv.alg.sfm.overhead.SelectOverheadParameters)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 StereoParameters (boofcv.struct.calib.StereoParameters)1 GrayU8 (boofcv.struct.image.GrayU8)1 Planar (boofcv.struct.image.Planar)1 Se3_F64 (georegression.struct.se.Se3_F64)1 BufferedImage (java.awt.image.BufferedImage)1