Search in sources :

Example 36 with Point3D_F64

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

the class GenericCalibrationGrid method createObservations.

/**
 * Creates a set of observed points in pixel coordinates given zhang parameters and a calibration
 * grid.
 */
public static List<CalibrationObservation> createObservations(Zhang99AllParam config, List<Point2D_F64> grid) {
    List<CalibrationObservation> ret = new ArrayList<>();
    Point3D_F64 cameraPt = new Point3D_F64();
    Point2D_F64 pixelPt = new Point2D_F64();
    Zhang99IntrinsicParam intrinsic = config.getIntrinsic();
    for (Zhang99AllParam.View v : config.views) {
        CalibrationObservation set = new CalibrationObservation();
        Se3_F64 se = new Se3_F64();
        ConvertRotation3D_F64.rodriguesToMatrix(v.rotation, se.getR());
        se.T = v.T;
        for (int i = 0; i < grid.size(); i++) {
            Point2D_F64 grid2D = grid.get(i);
            Point3D_F64 grid3D = new Point3D_F64(grid2D.x, grid2D.y, 0);
            // Put the point in the camera's reference frame
            SePointOps_F64.transform(se, grid3D, cameraPt);
            // project and distort the point
            intrinsic.project(cameraPt, pixelPt);
            set.add(pixelPt, i);
        }
        ret.add(set);
    }
    return ret;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64)

Example 37 with Point3D_F64

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

the class CommonMotionNPoint method generateScene.

protected void generateScene(int N, Se3_F64 motion, boolean planar) {
    this.motion = motion;
    // randomly generate points in space
    if (planar) {
        worldPts = CommonHomographyChecks.createRandomPlane(rand, 3, N);
    } else {
        worldPts = GeoTestingOps.randomPoints_F64(-1, 1, -1, 1, 2, 3, N, rand);
    }
    cameraPts = new ArrayList<>();
    // transform points into second camera's reference frame
    assocPairs = new ArrayList<>();
    pointPose = new ArrayList<>();
    for (Point3D_F64 p1 : worldPts) {
        Point3D_F64 p2 = SePointOps_F64.transform(motion, p1, null);
        AssociatedPair pair = new AssociatedPair();
        pair.p1.set(p1.x / p1.z, p1.y / p1.z);
        pair.p2.set(p2.x / p2.z, p2.y / p2.z);
        assocPairs.add(pair);
        pointPose.add(new Point2D3D(pair.p2, p1));
        cameraPts.add(p2);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point3D_F64(georegression.struct.point.Point3D_F64) Point2D3D(boofcv.struct.geo.Point2D3D)

Example 38 with Point3D_F64

use of georegression.struct.point.Point3D_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 39 with Point3D_F64

use of georegression.struct.point.Point3D_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 40 with Point3D_F64

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

the class TestPnPLepetitEPnP method selectControlPoints.

@Test
public void selectControlPoints() {
    List<Point3D_F64> worldPts = GeoTestingOps.randomPoints_F64(-1, 10, -5, 20, 0.1, 0.5, 30, rand);
    FastQueue<Point3D_F64> controlPts = new FastQueue<>(4, Point3D_F64.class, true);
    PnPLepetitEPnP alg = new PnPLepetitEPnP();
    alg.selectWorldControlPoints(worldPts, controlPts);
    // check that each row is unique
    for (int i = 0; i < 4; i++) {
        Point3D_F64 ci = controlPts.get(i);
        for (int j = i + 1; j < 4; j++) {
            Point3D_F64 cj = controlPts.get(j);
            double dx = ci.x - cj.x;
            double dy = ci.y - cj.y;
            double dz = ci.z - cj.z;
            double sum = Math.abs(dx) + Math.abs(dy) + Math.abs(dz);
            assertTrue(sum > 0.00001);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) FastQueue(org.ddogleg.struct.FastQueue) Test(org.junit.Test)

Aggregations

Point3D_F64 (georegression.struct.point.Point3D_F64)174 Point2D_F64 (georegression.struct.point.Point2D_F64)85 Test (org.junit.Test)77 Se3_F64 (georegression.struct.se.Se3_F64)74 DMatrixRMaj (org.ejml.data.DMatrixRMaj)46 ArrayList (java.util.ArrayList)17 Vector3D_F64 (georegression.struct.point.Vector3D_F64)15 Point2D3D (boofcv.struct.geo.Point2D3D)13 AssociatedPair (boofcv.struct.geo.AssociatedPair)12 GrayU8 (boofcv.struct.image.GrayU8)9 FastQueue (org.ddogleg.struct.FastQueue)9 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)8 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)7 MotionTransformPoint (georegression.fitting.MotionTransformPoint)7 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)7 PointTrack (boofcv.abst.feature.tracker.PointTrack)5 StereoParameters (boofcv.struct.calib.StereoParameters)5 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)5 GrayU16 (boofcv.struct.image.GrayU16)5 Stereo2D3D (boofcv.struct.sfm.Stereo2D3D)5