java - 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);
}
解决方案
推荐阅读
- avfoundation - 如何在 macOS 上使用 MTLTexture 和 MTLStorageModeShared 在 kCVPixelFormatType_422YpCbCr8 中渲染 CVPixelBuffer
- javascript - 如果我按 x 次按钮的事件
- mysql - Laravel 数据库查询。用户信息
- python - 如何使用 django 通知和 celery 在网站上发送通知
- java - 避免使用基于时间戳列的 JPA 更新实体
- cryptocurrency - 使用交易执行批准语言 (TEAL) 我可以自己制作硬币吗?
- javascript - 使用 CSS 为按钮包装文本以显示带有 javascript 交互的代码
- mongodb - Mongodb:$expr比较同一文档中同一数组的两个元素
- java - 为什么 findViewById() 返回“null”?
- php - 如何在不使用简码的情况下调用函数/类 | WordPress?