Search in sources :

Example 61 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class ShowRectifyCalibratedApp method addRectified.

private void addRectified(final String name, final DMatrixRMaj rect1, final DMatrixRMaj rect2) {
    // TODO simplify code some how
    FMatrixRMaj rect1_F32 = new FMatrixRMaj(3, 3);
    FMatrixRMaj rect2_F32 = new FMatrixRMaj(3, 3);
    ConvertMatrixData.convert(rect1, rect1_F32);
    ConvertMatrixData.convert(rect2, rect2_F32);
    // Will rectify the image
    ImageType<GrayF32> imageType = ImageType.single(GrayF32.class);
    ImageDistort<GrayF32, GrayF32> imageDistortLeft = RectifyImageOps.rectifyImage(param.getLeft(), rect1_F32, BorderType.ZERO, imageType);
    ImageDistort<GrayF32, GrayF32> imageDistortRight = RectifyImageOps.rectifyImage(param.getRight(), rect2_F32, BorderType.ZERO, imageType);
    // Fill the image with all black
    GImageMiscOps.fill(rectLeft, 0);
    GImageMiscOps.fill(rectRight, 0);
    // Render the rectified image
    DistortImageOps.distortPL(distLeft, rectLeft, imageDistortLeft);
    DistortImageOps.distortPL(distRight, rectRight, imageDistortRight);
    // convert for output
    final BufferedImage outLeft = ConvertBufferedImage.convertTo(rectLeft, null, true);
    final BufferedImage outRight = ConvertBufferedImage.convertTo(rectRight, null, true);
    // Add this rectified image
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            gui.addItem(new RectifiedPairPanel(true, outLeft, outRight), name);
        }
    });
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) GrayF32(boofcv.struct.image.GrayF32) RectifiedPairPanel(boofcv.gui.stereo.RectifiedPairPanel) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 62 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class CompareConvertedDescriptionsApp method visualize.

public static <TD extends TupleDesc> void visualize(String title, BufferedImage image1, BufferedImage image2, InterestPointDetector<GrayF32> detector, DescribeRegionPoint<GrayF32, TD> describe, ScoreAssociation<TD> scorer) {
    AssociateDescription<TD> assoc = FactoryAssociation.greedy(scorer, Double.MAX_VALUE, false);
    List<Point2D_F64> locationSrc = new ArrayList<>();
    List<Point2D_F64> locationDst = new ArrayList<>();
    GrayF32 input1 = ConvertBufferedImage.convertFrom(image1, (GrayF32) null);
    GrayF32 input2 = ConvertBufferedImage.convertFrom(image2, (GrayF32) null);
    FastQueue<TD> listSrc = describeImage(input1, detector, describe, locationSrc);
    FastQueue<TD> listDst = describeImage(input2, detector, describe, locationDst);
    assoc.setSource(listSrc);
    assoc.setDestination(listDst);
    assoc.associate();
    FastQueue<AssociatedIndex> matches = assoc.getMatches();
    AssociationPanel panel = new AssociationPanel(20);
    panel.setImages(image1, image2);
    panel.setAssociation(locationSrc, locationDst, matches);
    ShowImages.showWindow(panel, title);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) AssociationPanel(boofcv.gui.feature.AssociationPanel) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 63 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class CompareConvertedDescriptionsApp method main.

public static void main(String[] args) {
    String file1 = UtilIO.pathExample("stitch/kayak_01.jpg");
    String file2 = UtilIO.pathExample("stitch/kayak_02.jpg");
    InterestPointDetector<GrayF32> detector = FactoryInterestPoint.fastHessian(new ConfigFastHessian(1, 10, -1, 2, 9, 4, 4));
    DescribeRegionPoint<GrayF32, TupleDesc_F64> describeA = (DescribeRegionPoint) FactoryDescribeRegionPoint.surfStable(null, GrayF32.class);
    ConvertTupleDesc<TupleDesc_F64, TupleDesc_S8> converter = FactoryConvertTupleDesc.real_F64_S8(describeA.createDescription().size());
    DescribeRegionPoint<GrayF32, TupleDesc_S8> describeB = new DescribeRegionPointConvert<>(describeA, converter);
    ScoreAssociation<TupleDesc_F64> scoreA = FactoryAssociation.scoreSad(TupleDesc_F64.class);
    ScoreAssociation<TupleDesc_S8> scoreB = FactoryAssociation.scoreSad(TupleDesc_S8.class);
    BufferedImage image1 = UtilImageIO.loadImage(file1);
    BufferedImage image2 = UtilImageIO.loadImage(file2);
    visualize("Original", image1, image2, detector, describeA, scoreA);
    visualize("Modified", image1, image2, detector, describeB, scoreB);
    System.out.println("Done");
}
Also used : TupleDesc_S8(boofcv.struct.feature.TupleDesc_S8) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) FactoryDescribeRegionPoint(boofcv.factory.feature.describe.FactoryDescribeRegionPoint) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) DescribeRegionPointConvert(boofcv.abst.feature.describe.DescribeRegionPointConvert) GrayF32(boofcv.struct.image.GrayF32)

Example 64 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class DetectLineApp method main.

public static void main(String[] args) {
    Class imageType = GrayF32.class;
    Class derivType = GrayF32.class;
    DetectLineApp app = new DetectLineApp(imageType, derivType);
    java.util.List<PathLabel> inputs = new ArrayList<>();
    inputs.add(new PathLabel("Objects", UtilIO.pathExample("simple_objects.jpg")));
    inputs.add(new PathLabel("Indoors", UtilIO.pathExample("lines_indoors.jpg")));
    app.setInputList(inputs);
    // wait for it to process one image so that the size isn't all screwed up
    while (!app.getHasProcessedImage()) {
        Thread.yield();
    }
    ShowImages.showWindow(app, "Line Detection", true);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) PathLabel(boofcv.io.PathLabel) ArrayList(java.util.ArrayList)

Example 65 with GrayF32

use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.

the class MultiCameraToEquirectangular method addCamera.

/**
 * Adds a camera and attempts to compute the mask from the provided distortion model.  if a pixel is rendered
 * outside the bounds in the input image then it is masked out.  If the forwards/backwards transform is too
 * different then it is masked out.
 *
 * @param cameraToCommon Rigid body transform from this camera to the common frame the equirectangular image
 *                       is in
 * @param factory Distortion model
 * @param width Input image width
 * @param height Input image height
 */
public void addCamera(Se3_F32 cameraToCommon, LensDistortionWideFOV factory, int width, int height) {
    Point2Transform3_F32 p2s = factory.undistortPtoS_F32();
    Point3Transform2_F32 s2p = factory.distortStoP_F32();
    EquiToCamera equiToCamera = new EquiToCamera(cameraToCommon.getR(), s2p);
    GrayF32 equiMask = new GrayF32(equiWidth, equHeight);
    PixelTransform2_F32 transformEquiToCam = new PixelTransformCached_F32(equiWidth, equHeight, new PointToPixelTransform_F32(equiToCamera));
    Point3D_F32 p3b = new Point3D_F32();
    Point2D_F32 p2 = new Point2D_F32();
    for (int row = 0; row < equHeight; row++) {
        for (int col = 0; col < equiWidth; col++) {
            equiToCamera.compute(col, row, p2);
            int camX = (int) (p2.x + 0.5f);
            int camY = (int) (p2.y + 0.5f);
            if (Double.isNaN(p2.x) || Double.isNaN(p2.y) || camX < 0 || camY < 0 || camX >= width || camY >= height)
                continue;
            p2s.compute(p2.x, p2.y, p3b);
            if (Double.isNaN(p3b.x) || Double.isNaN(p3b.y) || Double.isNaN(p3b.z))
                continue;
            double angle = UtilVector3D_F32.acute(equiToCamera.unitCam, p3b);
            if (angle < maskToleranceAngle) {
                equiMask.set(col, row, 1);
            }
        }
    }
    cameras.add(new Camera(equiMask, transformEquiToCam));
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) GrayF32(boofcv.struct.image.GrayF32) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform3_F32(boofcv.struct.distort.Point2Transform3_F32) Point3Transform2_F32(boofcv.struct.distort.Point3Transform2_F32) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32) PixelTransformCached_F32(boofcv.alg.distort.PixelTransformCached_F32)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13