首页 > 解决方案 > BoofCV。校正鱼眼图像

问题描述

我正在制作一个使用库 BoofCV 校正鱼眼图像的应用程序。我找到了一个例子,但我不知道如何在这样的校正后显示所有校正图像

    static public BufferedImage calibrationCircular(BufferedImage image, CameraUniversalOmni fisheyeModel) {
    logger.info("Called function calibrationCircular()");
    // Specify what the pinhole camera should look like
    CameraPinhole pinholeModel = new CameraPinhole(400,400,0,300,300,600,600);

    // Create the transform from pinhole to fisheye views
    LensDistortionNarrowFOV pinholeDistort = new LensDistortionPinhole(pinholeModel);
    LensDistortionWideFOV fisheyeDistort = new LensDistortionUniversalOmni(fisheyeModel);
    NarrowToWidePtoP_F32 transform = new NarrowToWidePtoP_F32(pinholeDistort,fisheyeDistort);

    // Load fisheye RGB image
    Planar<GrayU8> fisheyeImage = ConvertBufferedImage.convertFrom(
            image, true, ImageType.pl(3,GrayU8.class));

    // Create the image distorter which will render the image
    InterpolatePixel<Planar<GrayU8>> interp = FactoryInterpolation.
            createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, fisheyeImage.getImageType());
    ImageDistort<Planar<GrayU8>,Planar<GrayU8>> distorter =
            FactoryDistort.distort(false,interp,fisheyeImage.getImageType());

    // Pass in the transform created above
    distorter.setModel(new PointToPixelTransform_F32(transform));
    // Render the image.  The camera will have a rotation of 0 and will thus be looking straight forward
    Planar<GrayU8> pinholeImage = fisheyeImage.createNew(pinholeModel.width, pinholeModel.height);
    distorter.apply(fisheyeImage,pinholeImage);
    BufferedImage bufferedPinhole0 = ConvertBufferedImage.convertTo(pinholeImage,null,true);

    distorter.apply(fisheyeImage,pinholeImage);
    BufferedImage bufferedPinhole1 = ConvertBufferedImage.convertTo(pinholeImage,null,true);

    return ConvertBufferedImage.convertTo(pinholeImage, null, true);
}

标签: javafisheyeboofcv

解决方案


推荐阅读