Search in sources :

Example 26 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class PinholeRadialToEquirectangular_F32 method setPinhole.

/**
 * Specifies the pinhole camera
 * @param pinhole intrinsic parameters of pinhole camera
 */
public void setPinhole(CameraPinholeRadial pinhole) {
    this.pinhole = pinhole;
    declareVectors(pinhole.width, pinhole.height);
    // computing the 3D ray through each pixel in the pinhole camera at it's canonical
    // location
    Point2Transform2_F32 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F32(true, false);
    Point2D_F32 norm = new Point2D_F32();
    for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
        for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
            pixelToNormalized.compute(pixelX, pixelY, norm);
            Point3D_F32 v = vectors[pixelY * pinhole.width + pixelX];
            v.set(norm.x, norm.y, 1);
        }
    }
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 27 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class PinholeToEquirectangular_F32 method setPinhole.

/**
 * Specifies the pinhole camera
 * @param pinhole intrinsic parameters of pinhole camera
 */
public void setPinhole(CameraPinhole pinhole) {
    this.pinhole = pinhole;
    declareVectors(pinhole.width, pinhole.height);
    // computing the 3D ray through each pixel in the pinhole camera at it's canonical
    // location
    PinholePtoN_F32 pixelToNormalized = new PinholePtoN_F32();
    pixelToNormalized.set(pinhole.fx, pinhole.fy, pinhole.skew, pinhole.cx, pinhole.cy);
    Point2D_F32 norm = new Point2D_F32();
    for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
        for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
            pixelToNormalized.compute(pixelX, pixelY, norm);
            Point3D_F32 v = vectors[pixelY * pinhole.width + pixelX];
            v.set(norm.x, norm.y, 1);
        }
    }
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) PinholePtoN_F32(boofcv.alg.distort.pinhole.PinholePtoN_F32) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 28 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class ExamplePointDeformKeyPoints method main.

public static void main(String[] args) {
    BufferedImage orig = UtilImageIO.loadImage(UtilIO.pathExample("standard/man_mls.jpg"));
    BufferedImage bufferedOut = new BufferedImage(orig.getWidth(), orig.getHeight(), BufferedImage.TYPE_INT_RGB);
    Planar<GrayF32> input = ConvertBufferedImage.convertFrom(orig, true, ImageType.pl(3, GrayF32.class));
    Planar<GrayF32> output = input.createSameShape();
    List<Point2D_F32> src = new ArrayList<>();
    List<Point2D_F32> dst = new ArrayList<>();
    src.add(new Point2D_F32(64, 241));
    src.add(new Point2D_F32(266, 119));
    src.add(new Point2D_F32(265, 240));
    src.add(new Point2D_F32(208, 410));
    src.add(new Point2D_F32(181, 536));
    src.add(new Point2D_F32(335, 409));
    src.add(new Point2D_F32(375, 531));
    src.add(new Point2D_F32(473, 238));
    for (Point2D_F32 p : src) {
        dst.add(p.copy());
    }
    ConfigDeformPointMLS config = new ConfigDeformPointMLS();
    PointDeformKeyPoints deform = FactoryDistort.deformMls(config);
    deform.setImageShape(input.width, input.height);
    ImageDistort<Planar<GrayF32>, Planar<GrayF32>> distorter = FactoryDistort.distort(true, InterpolationType.BILINEAR, BorderType.ZERO, input.getImageType(), input.getImageType());
    deform.setImageShape(input.width, input.height);
    deform.setSource(src);
    deform.setDestination(dst);
    ConvertBufferedImage.convertTo(output, bufferedOut, true);
    ImagePanel panel = ShowImages.showWindow(bufferedOut, "Point Based Distortion Animation", true);
    int count = 0;
    while (true) {
        // specify new locations of key points
        double theta = count++ * Math.PI / 30;
        // right arm
        dst.get(7).y = (float) (238 + Math.sin(theta) * 30);
        // left arm
        dst.get(0).y = (float) (241 - Math.sin(theta * 2.0) * 20);
        // head
        dst.get(1).x = (float) (266 + Math.sin(theta * 0.25) * 10);
        // tell the deformation algorithm that destination points have changed
        deform.setDestination(dst);
        // Tell the distorter that the model has changed. If cached is set to false you can ignore this step
        distorter.setModel(new PointToPixelTransform_F32(deform));
        // distort the image
        distorter.apply(input, output);
        // Show the results
        ConvertBufferedImage.convertTo(output, bufferedOut, true);
        panel.repaint();
        BoofMiscOps.sleep(30);
    }
}
Also used : ArrayList(java.util.ArrayList) PointDeformKeyPoints(boofcv.abst.distort.PointDeformKeyPoints) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ConfigDeformPointMLS(boofcv.abst.distort.ConfigDeformPointMLS) GrayF32(boofcv.struct.image.GrayF32) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) Planar(boofcv.struct.image.Planar) Point2D_F32(georegression.struct.point.Point2D_F32) ImagePanel(boofcv.gui.image.ImagePanel)

Example 29 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class PointDeform_MLS method setDestination.

@Override
public void setDestination(List<Point2D_F32> locations) {
    for (int i = 0; i < locations.size(); i++) {
        Point2D_F32 p = locations.get(i);
        alg.setDistorted(i, p.x, p.y);
    }
    alg.fixateDistorted();
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 30 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class ConnectLinesGrid method connectInSameElement.

/**
 * Search for lines in the same region for it to be connected to.
 *
 * @param lines All the lines in the region.
 */
private void connectInSameElement(List<LineSegment2D_F32> lines) {
    for (int i = 0; i < lines.size(); i++) {
        LineSegment2D_F32 a = lines.get(i);
        int index = findBestCompatible(a, lines, i + 1);
        if (index == -1)
            continue;
        // remove the line from the index which it is being connected to
        LineSegment2D_F32 b = lines.remove(index);
        // join the two lines by connecting the farthest points from each other
        Point2D_F32 pt0 = farthestIndex < 2 ? a.a : a.b;
        Point2D_F32 pt1 = (farthestIndex % 2) == 0 ? b.a : b.b;
        a.a.set(pt0);
        a.b.set(pt1);
    }
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) Point2D_F32(georegression.struct.point.Point2D_F32)

Aggregations

Point2D_F32 (georegression.struct.point.Point2D_F32)98 Test (org.junit.Test)36 Point3D_F32 (georegression.struct.point.Point3D_F32)10 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)9 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)8 ArrayList (java.util.ArrayList)8 Point2D_F64 (georegression.struct.point.Point2D_F64)7 FMatrixRMaj (org.ejml.data.FMatrixRMaj)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)5 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)4 GrayF32 (boofcv.struct.image.GrayF32)4 ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2