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);
}
}
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());
}
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));
}
}
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);
}
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;
}
Aggregations