Search in sources :

Example 16 with Point2D_F64

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

the class Zhang99ComputeTargetHomography method computeHomography.

/**
 * Computes the homography from a list of detected grid points in the image.  The
 * order of the grid points is important and must follow the expected row major
 * starting at the top left.
 *
 * @param observedPoints List of ordered detected grid points in image pixels.
 * @return True if it computed a Homography and false if it failed to compute a homography matrix.
 */
public boolean computeHomography(CalibrationObservation observedPoints) {
    if (observedPoints.size() < 4)
        throw new IllegalArgumentException("At least 4 points needed in each set of observations. " + " Filter these first please");
    List<AssociatedPair> pairs = new ArrayList<>();
    for (int i = 0; i < observedPoints.size(); i++) {
        int which = observedPoints.get(i).index;
        Point2D_F64 obs = observedPoints.get(i);
        pairs.add(new AssociatedPair(worldPoints.get(which), obs, true));
    }
    if (!computeHomography.process(pairs, found))
        return false;
    return true;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList)

Example 17 with Point2D_F64

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

the class Zhang99OptimizationFunction method process.

public void process(Zhang99AllParam param, double[] residuals) {
    int index = 0;
    for (int indexView = 0; indexView < param.views.length; indexView++) {
        Zhang99AllParam.View v = param.views[indexView];
        ConvertRotation3D_F64.rodriguesToMatrix(v.rotation, se.getR());
        se.T = v.T;
        CalibrationObservation viewSet = observations.get(indexView);
        for (int i = 0; i < viewSet.size(); i++) {
            int gridIndex = viewSet.get(i).index;
            Point2D_F64 obs = viewSet.get(i);
            // Put the point in the camera's reference frame
            SePointOps_F64.transform(se, grid.get(gridIndex), cameraPt);
            param.getIntrinsic().project(cameraPt, pixelPt);
            residuals[index++] = pixelPt.x - obs.x;
            residuals[index++] = pixelPt.y - obs.y;
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 18 with Point2D_F64

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

the class VisualizeShapes method drawArrowSubPixel.

public static void drawArrowSubPixel(Point2D_F64 p0, Point2D_F64 p1, Line2D.Double line, Graphics2D g2) {
    drawSubPixel(p0, p1, line, g2);
    double x2 = p0.x + (p1.x - p0.x) * 0.9;
    double y2 = p0.y + (p1.y - p0.y) * 0.9;
    double tanX = (p1.y - y2);
    double tanY = (x2 - p1.x);
    drawSubPixel(new Point2D_F64(x2 + tanX, y2 + tanY), p1, line, g2);
    drawSubPixel(new Point2D_F64(x2 - tanX, y2 - tanY), p1, line, g2);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 19 with Point2D_F64

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

the class VisualizeShapes method fillPolygon.

public static void fillPolygon(Polygon2D_F64 polygon, double scale, Graphics2D g2) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Path2D path = new Path2D.Double();
    Point2D_F64 p = polygon.get(0);
    path.moveTo(p.x * scale, p.y * scale);
    for (int i = 1; i <= polygon.size(); i++) {
        p = polygon.get(i % polygon.size());
        path.lineTo(p.x * scale, p.y * scale);
    }
    g2.fill(path);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Path2D(java.awt.geom.Path2D)

Example 20 with Point2D_F64

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

the class GenericTestsDetectDescribeMulti method detectFeatures.

/**
 * Detects features inside the image and checks to see if it is in compliance of its reported capabilities
 */
@Test
public void detectFeatures() {
    DetectDescribeMulti<T, TD> alg = createDetDesc();
    alg.process(image);
    for (int n = 0; n < alg.getNumberOfSets(); n++) {
        PointDescSet<TD> set = alg.getFeatureSet(n);
        int N = set.getNumberOfFeatures();
        assertTrue(N > 5);
        for (int i = 0; i < N; i++) {
            Point2D_F64 p = set.getLocation(i);
            TD desc = set.getDescription(i);
            assertTrue(desc != null);
            assertTrue(p.x != 0 && p.y != 0);
            assertTrue(p.x >= 0 && p.y >= 0 && p.x < image.width && p.y < image.height);
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

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