use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class BenchmarkStabilityFundamental method createObservations.
public void createObservations() {
observations = new ArrayList<>();
for (Point3D_F64 p1 : scene) {
Point3D_F64 p2 = SePointOps_F64.transform(motion, p1, null);
if (p1.z < 0 || p2.z < 0)
continue;
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);
observations.add(pair);
// convert to pixels
GeometryMath_F64.mult(K, pair.p1, pair.p1);
GeometryMath_F64.mult(K, pair.p2, pair.p2);
// add noise
pair.p1.x += rand.nextGaussian() * sigmaPixels;
pair.p1.y += rand.nextGaussian() * sigmaPixels;
pair.p2.x += rand.nextGaussian() * sigmaPixels;
pair.p2.y += rand.nextGaussian() * sigmaPixels;
// if needed, convert back into normalized image coordinates
if (!isPixels) {
GeometryMath_F64.mult(K_inv, pair.p1, pair.p1);
GeometryMath_F64.mult(K_inv, pair.p2, pair.p2);
}
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class FunctionSampsonFundamental method process.
@Override
public double process(double[] input) {
param.decode(input, F);
double sum = 0;
for (int i = 0; i < obs.size(); i++) {
AssociatedPair p = obs.get(i);
double top = GeometryMath_F64.innerProd(p.p2, F, p.p1);
top *= top;
double bottom = 0;
GeometryMath_F64.mult(F, p.p1, temp);
bottom += temp.x * temp.x + temp.y * temp.y;
GeometryMath_F64.multTran(F, p.p2, temp);
bottom += temp.x * temp.x + temp.y * temp.y;
if (bottom <= 1e-12)
continue;
sum += top / bottom;
}
return sum;
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class ResidualsEpipolarMatrix method process.
@Override
public void process(double[] input, double[] output) {
param.decode(input, F);
residual.setModel(F);
for (int i = 0; i < obs.size(); i++) {
AssociatedPair p = obs.get(i);
output[i] = residual.computeResidual(p);
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class ResidualsEpipolarMatrixN method process.
@Override
public void process(double[] input, double[] output) {
param.decode(input, F);
residual.setModel(F);
int index = 0;
for (int i = 0; i < obs.size(); i++) {
AssociatedPair p = obs.get(i);
index = residual.computeResiduals(p, output, index);
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class ArtificialStereoScene method addPixelNoise.
public void addPixelNoise(double noiseSigma) {
for (AssociatedPair p : pairs) {
if (!isPixels) {
PerspectiveOps.convertNormToPixel(K, p.p1, p.p1);
PerspectiveOps.convertNormToPixel(K, p.p2, p.p2);
}
p.p2.x += rand.nextGaussian() * noiseSigma;
p.p2.y += rand.nextGaussian() * noiseSigma;
p.p1.x += rand.nextGaussian() * noiseSigma;
p.p1.y += rand.nextGaussian() * noiseSigma;
if (!isPixels) {
PerspectiveOps.convertPixelToNorm(K, p.p1, p.p1);
PerspectiveOps.convertPixelToNorm(K, p.p2, p.p2);
}
}
// observationCurrent simply references the data in pairs
}
Aggregations