Search in sources :

Example 81 with Point2D_F64

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

the class EssentialNister5 method computeSpan.

/**
 * From the epipolar constraint p2^T*E*p1 = 0 construct a linear system
 * and find its null space.
 */
private void computeSpan(List<AssociatedPair> points) {
    Q.reshape(points.size(), 9);
    int index = 0;
    for (int i = 0; i < points.size(); i++) {
        AssociatedPair p = points.get(i);
        Point2D_F64 a = p.p2;
        Point2D_F64 b = p.p1;
        // The points are assumed to be in homogeneous coordinates.  This means z = 1
        Q.data[index++] = a.x * b.x;
        Q.data[index++] = a.x * b.y;
        Q.data[index++] = a.x;
        Q.data[index++] = a.y * b.x;
        Q.data[index++] = a.y * b.y;
        Q.data[index++] = a.y;
        Q.data[index++] = b.x;
        Q.data[index++] = b.y;
        Q.data[index++] = 1;
    }
    if (!solverNull.process(Q, 4, nullspace))
        throw new RuntimeException("Nullspace solver should never fail, probably bad input");
    // extract the span of solutions for E from the null space
    for (int i = 0; i < 9; i++) {
        X[i] = nullspace.unsafe_get(i, 0);
        Y[i] = nullspace.unsafe_get(i, 1);
        Z[i] = nullspace.unsafe_get(i, 2);
        W[i] = nullspace.unsafe_get(i, 3);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 82 with Point2D_F64

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

the class LowLevelMultiViewOps method computeNormalization.

/**
 * <p>Computes a transform which will normalize the points such that they have zero mean and a standard
 * deviation of one
 * </p>
 *
 * <p>
 * Y. Ma, S. Soatto, J. Kosecka, and S. S. Sastry, "An Invitation to 3-D Vision" Springer-Verlad, 2004
 * </p>
 *
 * @param points Input: List of observed points. Not modified.
 * @param normalize Output: 3x3 normalization matrix for first set of points. Modified.
 */
public static void computeNormalization(List<Point2D_F64> points, NormalizationPoint2D normalize) {
    double meanX = 0;
    double meanY = 0;
    for (Point2D_F64 p : points) {
        meanX += p.x;
        meanY += p.y;
    }
    meanX /= points.size();
    meanY /= points.size();
    double stdX = 0;
    double stdY = 0;
    for (Point2D_F64 p : points) {
        double dx = p.x - meanX;
        double dy = p.y - meanY;
        stdX += dx * dx;
        stdY += dy * dy;
    }
    normalize.meanX = meanX;
    normalize.meanY = meanY;
    normalize.stdX = Math.sqrt(stdX / points.size());
    normalize.stdY = Math.sqrt(stdY / points.size());
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 83 with Point2D_F64

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

the class ExampleMultiviewSceneReconstruction method detectFeatures.

/**
 * Detects image features.  Saves their location, description, and pixel color
 */
private void detectFeatures(BufferedImage colorImage, FastQueue<BrightFeature> features, FastQueue<Point2D_F64> pixels, GrowQueue_I32 colors) {
    GrayF32 image = ConvertBufferedImage.convertFrom(colorImage, (GrayF32) null);
    features.reset();
    pixels.reset();
    colors.reset();
    detDesc.detect(image);
    for (int i = 0; i < detDesc.getNumberOfFeatures(); i++) {
        Point2D_F64 p = detDesc.getLocation(i);
        features.grow().set(detDesc.getDescription(i));
        // store pixels are normalized image coordinates
        pixelToNorm.compute(p.x, p.y, pixels.grow());
        colors.add(colorImage.getRGB((int) p.x, (int) p.y));
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_F64(georegression.struct.point.Point2D_F64) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Example 84 with Point2D_F64

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

the class ExampleMultiviewSceneReconstruction method initialize.

/**
 * Initialize the 3D world given these two images.  imageA is assumed to be the origin of the world.
 */
private void initialize(int imageA, int imageB) {
    System.out.println("Initializing 3D world using " + imageA + " and " + imageB);
    // Compute the 3D pose and find valid image features
    Se3_F64 motionAtoB = new Se3_F64();
    List<AssociatedIndex> inliers = new ArrayList<>();
    if (!estimateStereoPose(imageA, imageB, motionAtoB, inliers))
        throw new RuntimeException("The first image pair is a bad keyframe!");
    motionWorldToCamera[imageB].set(motionAtoB);
    estimatedImage[imageB] = true;
    processedImage[imageB] = true;
    // create tracks for only those features in the inlier list
    FastQueue<Point2D_F64> pixelsA = imagePixels.get(imageA);
    FastQueue<Point2D_F64> pixelsB = imagePixels.get(imageB);
    List<Feature3D> tracksA = imageFeature3D.get(imageA);
    List<Feature3D> tracksB = imageFeature3D.get(imageB);
    GrowQueue_I32 colorsA = imageColors.get(imageA);
    for (int i = 0; i < inliers.size(); i++) {
        AssociatedIndex a = inliers.get(i);
        Feature3D t = new Feature3D();
        t.color = colorsA.get(a.src);
        t.obs.grow().set(pixelsA.get(a.src));
        t.obs.grow().set(pixelsB.get(a.dst));
        t.frame.add(imageA);
        t.frame.add(imageB);
        // compute the 3D coordinate of the feature
        Point2D_F64 pa = pixelsA.get(a.src);
        Point2D_F64 pb = pixelsB.get(a.dst);
        if (!triangulate.triangulate(pa, pb, motionAtoB, t.worldPt))
            continue;
        // the feature has to be in front of the camera
        if (t.worldPt.z > 0) {
            featuresAll.add(t);
            tracksA.add(t);
            tracksB.add(t);
        }
    }
    // adjust the scale so that it's not excessively large or small
    normalizeScale(motionWorldToCamera[imageB], tracksA);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) Se3_F64(georegression.struct.se.Se3_F64) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 85 with Point2D_F64

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

the class GenericCalibrationGrid method observations.

public static List<Point2D_F64> observations(DMatrixRMaj H, List<Point2D_F64> obs2D) {
    List<Point2D_F64> ret = new ArrayList<>();
    for (Point2D_F64 p2 : obs2D) {
        Point2D_F64 t = new Point2D_F64();
        GeometryMath_F64.mult(H, p2, t);
        ret.add(t);
    }
    return ret;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList)

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