Search in sources :

Example 6 with Point2D_F64

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

the class DisplayFisheyeCalibrationPanel method renderOrder.

public static void renderOrder(Graphics2D g2, double scale, List<Point2D_F64> points) {
    g2.setStroke(new BasicStroke(5));
    Line2D.Double l = new Line2D.Double();
    for (int i = 0, j = 1; j < points.size(); i = j, j++) {
        Point2D_F64 p0 = points.get(i);
        Point2D_F64 p1 = points.get(j);
        double fraction = i / ((double) points.size() - 2);
        // fraction = fraction * 0.8 + 0.1;
        int red = (int) (0xFF * fraction) + (int) (0x00 * (1 - fraction));
        int green = 0x00;
        int blue = (int) (0x00 * fraction) + (int) (0xff * (1 - fraction));
        int lineRGB = red << 16 | green << 8 | blue;
        l.setLine(scale * p0.x, scale * p0.y, scale * p1.x, scale * p1.y);
        g2.setColor(new Color(lineRGB));
        g2.draw(l);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Line2D(java.awt.geom.Line2D)

Example 7 with Point2D_F64

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

the class DisplayPinholeCalibrationPanel method renderOrder.

public static void renderOrder(Graphics2D g2, double scale, List<Point2D_F64> points) {
    g2.setStroke(new BasicStroke(5));
    Line2D.Double l = new Line2D.Double();
    for (int i = 0, j = 1; j < points.size(); i = j, j++) {
        Point2D_F64 p0 = points.get(i);
        Point2D_F64 p1 = points.get(j);
        double fraction = i / ((double) points.size() - 2);
        // fraction = fraction * 0.8 + 0.1;
        int red = (int) (0xFF * fraction) + (int) (0x00 * (1 - fraction));
        int green = 0x00;
        int blue = (int) (0x00 * fraction) + (int) (0xff * (1 - fraction));
        int lineRGB = red << 16 | green << 8 | blue;
        l.setLine(scale * p0.x, scale * p0.y, scale * p1.x, scale * p1.y);
        g2.setColor(new Color(lineRGB));
        g2.draw(l);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Line2D(java.awt.geom.Line2D)

Example 8 with Point2D_F64

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

the class DisplayPinholeCalibrationPanel method drawFeatures.

private void drawFeatures(Graphics2D g2, double scale) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    CalibrationObservation set = features;
    Point2D_F32 adj = new Point2D_F32();
    if (showOrder) {
        List<Point2D_F64> adjusted;
        if (showUndistorted) {
            adjusted = new ArrayList<>();
            for (PointIndex2D_F64 p : set.points) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
                adjusted.add(new Point2D_F64(adj.x, adj.y));
            }
        } else {
            adjusted = (List) set.points;
        }
        renderOrder(g2, scale, adjusted);
    }
    if (showPoints) {
        g2.setColor(Color.BLACK);
        g2.setStroke(new BasicStroke(3));
        for (PointIndex2D_F64 p : set.points) {
            if (showUndistorted) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
            } else {
                adj.set((float) p.x, (float) p.y);
            }
            VisualizeFeatures.drawCross(g2, adj.x * scale, adj.y * scale, 4);
        }
        g2.setStroke(new BasicStroke(1));
        g2.setColor(Color.RED);
        for (PointIndex2D_F64 p : set.points) {
            if (showUndistorted) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
            } else {
                adj.set((float) p.x, (float) p.y);
            }
            VisualizeFeatures.drawCross(g2, adj.x * scale, adj.y * scale, 4);
        }
    }
    if (showAll) {
        for (CalibrationObservation l : allFeatures) {
            for (PointIndex2D_F64 p : l.points) {
                if (showUndistorted) {
                    remove_p_to_p.compute((float) p.x, (float) p.y, adj);
                } else {
                    adj.set((float) p.x, (float) p.y);
                }
                VisualizeFeatures.drawPoint(g2, adj.x * scale, adj.y * scale, 2, Color.BLUE, false);
            }
        }
    }
    if (showNumbers) {
        if (showUndistorted)
            drawNumbers(g2, set, remove_p_to_p, scale);
        else
            drawNumbers(g2, set, null, scale);
    }
    if (showErrors && results != null) {
        for (int i = 0; i < set.size(); i++) {
            PointIndex2D_F64 p = set.get(i);
            if (showUndistorted) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
            } else {
                adj.set((float) p.x, (float) p.y);
            }
            double r = scale * errorScale * results.pointError[i];
            if (r < 1)
                continue;
            g2.setStroke(new BasicStroke(4));
            g2.setColor(Color.BLACK);
            VisualizeFeatures.drawCircle(g2, adj.x * scale, adj.y * scale, r);
            g2.setStroke(new BasicStroke(2.5f));
            g2.setColor(Color.ORANGE);
            VisualizeFeatures.drawCircle(g2, adj.x * scale, adj.y * scale, r);
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) Point2D_F32(georegression.struct.point.Point2D_F32) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 9 with Point2D_F64

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

the class PlaneView2D method paintComponent.

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    int offsetX = getWidth() / 2;
    int offsetY = getHeight() / 2;
    int H = getHeight() - 1;
    int r = 2;
    int w = 2 * r + 1;
    for (Point2D_F64 p : points.toList()) {
        SePointOps_F64.transform(transform, p, a);
        a.x *= scale / pixelToUnit;
        a.y *= scale / pixelToUnit;
        g2.fillOval(offsetX + (int) a.x, H - (offsetY + (int) a.y), w, w);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 10 with Point2D_F64

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

the class Polygon3DSequenceViewer method renderPolygons.

private void renderPolygons(Graphics2D g2) {
    for (Poly poly : polygons) {
        SePointOps_F64.transform(worldToCamera, poly.pts[0], p1);
        GeometryMath_F64.mult(K, p1, x1);
        // don't render what's behind the camera
        if (p1.z < 0)
            continue;
        g2.setColor(poly.color);
        boolean skip = false;
        for (int i = 1; i < poly.pts.length; i++) {
            SePointOps_F64.transform(worldToCamera, poly.pts[i], p2);
            GeometryMath_F64.mult(K, p2, x2);
            if (p2.z < 0) {
                skip = true;
                break;
            }
            line.setLine(x1.x, x1.y, x2.x, x2.y);
            g2.draw(line);
            Point3D_F64 tempP = p1;
            Point2D_F64 tempX = x1;
            p1 = p2;
            p2 = tempP;
            x1 = x2;
            x2 = tempX;
        }
        if (!skip) {
            SePointOps_F64.transform(worldToCamera, poly.pts[0], p2);
            GeometryMath_F64.mult(K, p2, x2);
            line.setLine(x1.x, x1.y, x2.x, x2.y);
            g2.draw(line);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64)

Aggregations

Point2D_F64 (georegression.struct.point.Point2D_F64)360 Test (org.junit.Test)129 Point3D_F64 (georegression.struct.point.Point3D_F64)85 Se3_F64 (georegression.struct.se.Se3_F64)68 ArrayList (java.util.ArrayList)57 DMatrixRMaj (org.ejml.data.DMatrixRMaj)48 AssociatedPair (boofcv.struct.geo.AssociatedPair)28 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)16 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)15 GrayF32 (boofcv.struct.image.GrayF32)13 Vector3D_F64 (georegression.struct.point.Vector3D_F64)13 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)13 Point2D3D (boofcv.struct.geo.Point2D3D)11 GrayU8 (boofcv.struct.image.GrayU8)11 Point2D_I32 (georegression.struct.point.Point2D_I32)11 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)10 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)9 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)8 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 BufferedImage (java.awt.image.BufferedImage)8