Search in sources :

Example 1 with Point2D_F64

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

the class AssociationPanel method setAssociation.

public synchronized void setAssociation(List<AssociatedPair> matches) {
    List<Point2D_F64> leftPts = new ArrayList<>();
    List<Point2D_F64> rightPts = new ArrayList<>();
    for (AssociatedPair p : matches) {
        leftPts.add(p.p1);
        rightPts.add(p.p2);
    }
    setLocation(leftPts, rightPts);
    assocLeft = new int[leftPts.size()];
    assocRight = new int[rightPts.size()];
    for (int i = 0; i < assocLeft.length; i++) {
        assocLeft[i] = i;
        assocRight[i] = i;
    }
    Random rand = new Random(234);
    colors = new Color[leftPts.size()];
    for (int i = 0; i < colors.length; i++) {
        colors[i] = new Color(rand.nextInt() | 0xFF000000);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Random(java.util.Random) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList)

Example 2 with Point2D_F64

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

the class AssociationPanel method drawAllFeatures.

private void drawAllFeatures(Graphics2D g2, double scaleLeft, double scaleRight, int rightX) {
    if (assocLeft == null || rightPts == null || leftPts == null)
        return;
    for (int i = 0; i < assocLeft.length; i++) {
        if (assocLeft[i] == -1)
            continue;
        Point2D_F64 l = leftPts.get(i);
        Point2D_F64 r = rightPts.get(assocLeft[i]);
        Color color = colors[i];
        drawAssociation(g2, scaleLeft, scaleRight, rightX, l, r, color);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 3 with Point2D_F64

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

the class AssociationScorePanel method drawPoints.

private void drawPoints(Graphics2D g2, List<Point2D_F64> points, int startX, int startY, double scale) {
    for (Point2D_F64 p : points) {
        int x1 = (int) (scale * p.x) + startX;
        int y1 = (int) (scale * p.y) + startY;
        VisualizeFeatures.drawPoint(g2, x1, y1, Color.BLUE);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 4 with Point2D_F64

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

the class AssociationScorePanel method drawDistribution.

/**
 * Visualizes score distribution.  Larger circles mean its closer to the best
 * fit score.
 */
private void drawDistribution(Graphics2D g2, List<Point2D_F64> candidates, int offX, int offY, double scale) {
    findStatistics();
    // draw all the features, adjusting their size based on the first score
    g2.setColor(Color.RED);
    g2.setStroke(new BasicStroke(3));
    double normalizer;
    if (scorer.getScoreType().isZeroBest())
        normalizer = best * containmentFraction;
    else
        normalizer = Math.abs(best) * (Math.exp(-1.0 / containmentFraction));
    for (int i = 0; i < candidates.size(); i++) {
        Point2D_F64 p = candidates.get(i);
        double s = associationScore[i];
        // scale the circle based on how bad it is
        double ratio = 1 - Math.abs(s - best) / normalizer;
        if (ratio < 0)
            continue;
        int r = maxCircleRadius - (int) (maxCircleRadius * ratio);
        if (r > 0) {
            int x = (int) (p.x * scale + offX);
            int y = (int) (p.y * scale + offY);
            g2.drawOval(x - r, y - r, r * 2 + 1, r * 2 + 1);
        }
    }
    // draw the best feature
    g2.setColor(Color.GREEN);
    g2.setStroke(new BasicStroke(10));
    int w = maxCircleRadius * 2 + 1;
    Point2D_F64 p = candidates.get(indexBest);
    int x = (int) (p.x * scale + offX);
    int y = (int) (p.y * scale + offY);
    g2.drawOval(x - maxCircleRadius, y - maxCircleRadius, w, w);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 5 with Point2D_F64

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

the class CompareTwoImagePanel method findBestPoints.

private void findBestPoints(int x, int y, List<Point2D_F64> pts, List<Integer> selected) {
    double bestDist = clickDistance * clickDistance;
    GrowQueue_I32 bestIndexes = new GrowQueue_I32(20);
    for (int i = 0; i < pts.size(); i++) {
        if (!isValidPoint(i))
            continue;
        Point2D_F64 p = pts.get(i);
        double d = UtilPoint2D_F64.distanceSq(p.x, p.y, x, y);
        if (d < bestDist) {
            bestDist = d;
            bestIndexes.reset();
            bestIndexes.add(i);
        } else if (Math.abs(d - bestDist) < 0.01) {
            bestIndexes.add(i);
        }
    }
    if (bestIndexes.size() > 0) {
        int indexRight = bestIndexes.get(0);
    }
    for (int i = 0; i < bestIndexes.size(); i++) {
        selected.add(bestIndexes.get(i));
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

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