Search in sources :

Example 91 with Point2D_F64

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

the class HoughTransformLinePolar method extractLines.

/**
 * Searches for local maximas and converts into lines.
 *
 * @return Found lines in the image.
 */
public FastQueue<LineParametric2D_F32> extractLines() {
    lines.reset();
    foundLines.reset();
    foundIntensity.reset();
    extractor.process(transform, null, null, null, foundLines);
    int w2 = transform.width / 2;
    for (int i = 0; i < foundLines.size(); i++) {
        Point2D_I16 p = foundLines.get(i);
        float r = (float) (r_max * (p.x - w2) / w2);
        float c = tableTrig.c[p.y];
        float s = tableTrig.s[p.y];
        float x0 = r * c + originX;
        float y0 = r * s + originY;
        foundIntensity.push(transform.get(p.x, p.y));
        LineParametric2D_F32 l = lines.grow();
        l.p.set(x0, y0);
        l.slope.set(-s, c);
        Point2D_F64 p2 = new Point2D_F64();
        lineToCoordinate(l, p2);
    }
    return lines;
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) Point2D_F64(georegression.struct.point.Point2D_F64) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Example 92 with Point2D_F64

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

the class CommonP3PSideChecks method pathological1.

/**
 * Check a pathological case where everything is zero
 */
@Test
public void pathological1() {
    Point3D_F64 P1 = new Point3D_F64();
    Point3D_F64 P2 = new Point3D_F64();
    Point3D_F64 P3 = new Point3D_F64();
    Point2D_F64 p1 = new Point2D_F64();
    Point2D_F64 p2 = new Point2D_F64();
    Point2D_F64 p3 = new Point2D_F64();
    double length12 = P1.distance(P2);
    double length23 = P2.distance(P3);
    double length13 = P1.distance(P3);
    List<PointDistance3> solutions = computeSolutions(p1, p2, p3, length23, length13, length12, false);
    assertEquals(0, solutions.size());
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 93 with Point2D_F64

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

the class TestPnPDistanceReprojectionSq method checkErrorSingle.

/**
 * Provide an observation with a known solution and see if it is computed correctly
 */
@Test
public void checkErrorSingle() {
    DMatrixRMaj K = new DMatrixRMaj(3, 3, true, 100, 0.01, 200, 0, 150, 200, 0, 0, 1);
    Se3_F64 worldToCamera = new Se3_F64();
    worldToCamera.getT().set(0.1, -0.1, 0.2);
    // Point location in world frame
    Point3D_F64 X = new Point3D_F64(0.1, -0.04, 2.3);
    double deltaX = 0.1;
    double deltaY = -0.2;
    // create a noisy observed
    Point2D_F64 observed = PerspectiveOps.renderPixel(worldToCamera, K, X);
    observed.x += deltaX;
    observed.y += deltaY;
    // convert to normalized image coordinates
    PerspectiveOps.convertPixelToNorm(K, observed, observed);
    PnPDistanceReprojectionSq alg = new PnPDistanceReprojectionSq(K.get(0, 0), K.get(1, 1), K.get(0, 1));
    alg.setModel(worldToCamera);
    double found = alg.computeDistance(new Point2D3D(observed, X));
    double expected = deltaX * deltaX + deltaY * deltaY;
    assertEquals(expected, found, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D3D(boofcv.struct.geo.Point2D3D) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 94 with Point2D_F64

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

the class TestPnPLepetitEPnP method standardTest.

private void standardTest(final int numIterations) {
    ChecksMotionNPoint test = new ChecksMotionNPoint() {

        @Override
        public Se3_F64 compute(List<AssociatedPair> obs, List<Point3D_F64> locations) {
            PnPLepetitEPnP alg = new PnPLepetitEPnP();
            List<Point2D_F64> currObs = new ArrayList<>();
            for (AssociatedPair a : obs) {
                currObs.add(a.p2);
            }
            Se3_F64 solution = new Se3_F64();
            alg.setNumIterations(numIterations);
            alg.process(locations, currObs, solution);
            return solution;
        }
    };
    for (int i = 0; i < 20; i++) {
        // the minimal case is not tested here since its too unstable
        for (int N = 5; N < 10; N++) {
            test.testNoMotion(N);
            test.standardTest(N);
            test.planarTest(N - 1);
        }
    // System.out.println();
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Se3_F64(georegression.struct.se.Se3_F64)

Example 95 with Point2D_F64

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

the class TestPnPResidualReprojection method basicTest.

@Test
public void basicTest() {
    Se3_F64 motion = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, 1, -0.2, motion.getR());
    motion.getT().set(-0.3, 0.4, 1);
    Point3D_F64 world = new Point3D_F64(0.5, -0.5, 3);
    Point2D_F64 obs = new Point2D_F64();
    Point3D_F64 temp = SePointOps_F64.transform(motion, world, null);
    obs.x = temp.x / temp.z;
    obs.y = temp.y / temp.z;
    PnPResidualReprojection alg = new PnPResidualReprojection();
    // compute errors with perfect model
    double[] error = new double[alg.getN()];
    alg.setModel(motion);
    int index = alg.computeResiduals(new Point2D3D(obs, world), error, 0);
    assertEquals(alg.getN(), index);
    assertEquals(0, error[0], 1e-8);
    assertEquals(0, error[1], 1e-8);
    // compute errors with an incorrect model
    motion.getR().set(2, 1, 2);
    alg.setModel(motion);
    index = alg.computeResiduals(new Point2D3D(obs, world), error, 0);
    assertEquals(alg.getN(), index);
    assertTrue(Math.abs(error[0]) > 1e-8);
    assertTrue(Math.abs(error[1]) > 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D3D(boofcv.struct.geo.Point2D3D) Point2D_F64(georegression.struct.point.Point2D_F64) Se3_F64(georegression.struct.se.Se3_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