use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class ExampleStereoTwoViewsOneCamera method convertToNormalizedCoordinates.
/**
* Convert a set of associated point features from pixel coordinates into normalized image coordinates.
*/
public static List<AssociatedPair> convertToNormalizedCoordinates(List<AssociatedPair> matchedFeatures, CameraPinholeRadial intrinsic) {
Point2Transform2_F64 p_to_n = LensDistortionOps.narrow(intrinsic).undistort_F64(true, false);
List<AssociatedPair> calibratedFeatures = new ArrayList<>();
for (AssociatedPair p : matchedFeatures) {
AssociatedPair c = new AssociatedPair();
p_to_n.compute(p.p1.x, p.p1.y, c.p1);
p_to_n.compute(p.p2.x, p.p2.y, c.p2);
calibratedFeatures.add(c);
}
return calibratedFeatures;
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class ExampleStereoTwoViewsOneCamera method estimateCameraMotion.
/**
* Estimates the camera motion robustly using RANSAC and a set of associated points.
*
* @param intrinsic Intrinsic camera parameters
* @param matchedNorm set of matched point features in normalized image coordinates
* @param inliers OUTPUT: Set of inlier features from RANSAC
* @return Found camera motion. Note translation has an arbitrary scale
*/
public static Se3_F64 estimateCameraMotion(CameraPinholeRadial intrinsic, List<AssociatedPair> matchedNorm, List<AssociatedPair> inliers) {
ModelMatcher<Se3_F64, AssociatedPair> epipolarMotion = FactoryMultiViewRobust.essentialRansac(new ConfigEssential(intrinsic), new ConfigRansac(200, 0.5));
if (!epipolarMotion.process(matchedNorm))
throw new RuntimeException("Motion estimation failed");
// save inlier set for debugging purposes
inliers.addAll(epipolarMotion.getMatchSet());
return epipolarMotion.getModelParameters();
}
use of boofcv.struct.geo.AssociatedPair 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);
}
}
use of boofcv.struct.geo.AssociatedPair 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();
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestGenerateHomographyLinear method createRandomPointFromModel.
@Override
public AssociatedPair createRandomPointFromModel(Homography2D_F64 transform) {
AssociatedPair ret = new AssociatedPair();
ret.p1.x = rand.nextDouble() * 10;
ret.p1.y = rand.nextDouble() * 10;
HomographyPointOps_F64.transform(transform, ret.p1, ret.p2);
return ret;
}
Aggregations