use of georegression.struct.homography.Homography2D_F64 in project BoofCV by lessthanoptimal.
the class FactoryMultiViewRobust method homographyLMedS.
/**
* Robust solution for estimating {@link Homography2D_F64} with {@link LeastMedianOfSquares LMedS}. Input
* observations are in pixel coordinates.
*
* <ul>
* <li>Four point linear is used internally</p>
* <li>inlierThreshold is in pixels</p>
* </ul>
*
* <p>See code for all the details.</p>
*
* @param homography Homography estimation parameters. If null default is used.
* @param configLMedS Parameters for LMedS. Can't be null.
* @return Homography estimator
*/
public static LeastMedianOfSquares<Homography2D_F64, AssociatedPair> homographyLMedS(ConfigHomography homography, ConfigLMedS configLMedS) {
if (homography == null)
homography = new ConfigHomography();
ModelManager<Homography2D_F64> manager = new ModelManagerHomography2D_F64();
GenerateHomographyLinear modelFitter = new GenerateHomographyLinear(homography.normalize);
DistanceHomographySq distance = new DistanceHomographySq();
LeastMedianOfSquares<Homography2D_F64, AssociatedPair> lmeds = new LeastMedianOfSquares<>(configLMedS.randSeed, configLMedS.totalCycles, manager, modelFitter, distance);
lmeds.setErrorFraction(configLMedS.errorFraction);
return lmeds;
}
use of georegression.struct.homography.Homography2D_F64 in project BoofCV by lessthanoptimal.
the class FactoryMultiViewRobust method homographyRansac.
/**
* Robust solution for estimating {@link Homography2D_F64} with {@link Ransac}. Input
* observations are in pixel coordinates.
*
* <ul>
* <li>Four point linear is used internally</p>
* <li>inlierThreshold is in pixels</p>
* </ul>
*
* <p>See code for all the details.</p>
*
* @param homography Homography estimation parameters. If null default is used.
* @param ransac Parameters for RANSAC. Can't be null.
* @return Homography estimator
*/
public static Ransac<Homography2D_F64, AssociatedPair> homographyRansac(ConfigHomography homography, ConfigRansac ransac) {
if (homography == null)
homography = new ConfigHomography();
ModelManager<Homography2D_F64> manager = new ModelManagerHomography2D_F64();
GenerateHomographyLinear modelFitter = new GenerateHomographyLinear(homography.normalize);
DistanceHomographySq distance = new DistanceHomographySq();
double ransacTol = ransac.inlierThreshold * ransac.inlierThreshold;
return new Ransac<>(ransac.randSeed, manager, modelFitter, distance, ransac.maxIterations, ransacTol);
}
use of georegression.struct.homography.Homography2D_F64 in project BoofCV by lessthanoptimal.
the class TestDistanceHomographyPixelSq method distance.
@Override
public double distance(Homography2D_F64 h, AssociatedPair associatedPair) {
Point2D_F64 result = new Point2D_F64();
Point2D_F64 pixel1 = new Point2D_F64();
Point2D_F64 pixel2 = new Point2D_F64();
// convert points into pixel coordinates
PerspectiveOps.convertNormToPixel(K, associatedPair.p1, pixel1);
PerspectiveOps.convertNormToPixel(K, associatedPair.p2, pixel2);
// compute error in pixels, which is what it should be in
Homography2D_F64 h_pixel = new Homography2D_F64();
UtilHomography_F64.convert(H_pixel, h_pixel);
HomographyPointOps_F64.transform(h_pixel, pixel1, result);
return result.distance2(pixel2);
}
use of georegression.struct.homography.Homography2D_F64 in project BoofCV by lessthanoptimal.
the class TestDistanceHomographyPixelSq method createRandomModel.
@Override
public Homography2D_F64 createRandomModel() {
double rotX = rand.nextGaussian();
double rotY = rand.nextGaussian();
double rotZ = rand.nextGaussian();
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, rotX, rotY, rotZ, null);
Vector3D_F64 T = new Vector3D_F64(0.2, -0.5, 3);
Vector3D_F64 N = new Vector3D_F64(-0.5, 1, 3);
// compute the Homography in normalized image coordinates and pixel coordinates
H = MultiViewOps.createHomography(R, T, 1.0, N);
H_pixel = MultiViewOps.createHomography(R, T, 1.0, N, K);
Homography2D_F64 h = new Homography2D_F64();
UtilHomography_F64.convert(H, h);
return h;
}
use of georegression.struct.homography.Homography2D_F64 in project BoofCV by lessthanoptimal.
the class VideoStitchBaseApp method updateAlgGUI.
@Override
protected void updateAlgGUI(I frame, BufferedImage imageGUI, final double fps) {
if (!hasProcessedImage)
return;
corners = alg.getImageCorners(frame.width, frame.height, null);
ConvertBufferedImage.convertTo(alg.getStitchedImage(), stitchOut, true);
if (checkLocation(corners)) {
// the change will only be visible in the next update
alg.setOriginToCurrent();
}
AccessPointTracks access = (AccessPointTracks) alg.getMotion();
List<Point2D_F64> tracks = access.getAllTracks();
List<Point2D_F64> inliers = new ArrayList<>();
for (int i = 0; i < tracks.size(); i++) {
if (access.isInlier(i))
inliers.add(tracks.get(i));
}
final int numInliers = inliers.size();
final int numFeatures = tracks.size();
showImageView = infoPanel.getShowView();
gui.setImages(imageGUI, stitchOut);
gui.setShowImageView(infoPanel.getShowView());
gui.setCorners(corners);
// toggle on and off showing the active tracks
if (infoPanel.getShowInliers())
gui.setInliers(inliers);
else
gui.setInliers(null);
if (infoPanel.getShowAll())
gui.setAllTracks(tracks);
else
gui.setAllTracks(null);
Homography2D_F64 H = alg.getWorldToCurr(null).invert(null);
gui.setCurrToWorld(H);
// update GUI
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// update GUI
infoPanel.setFPS(fps);
infoPanel.setNumInliers(numInliers);
infoPanel.setNumTracks(numFeatures);
infoPanel.setKeyFrames(totalResets);
infoPanel.repaint();
gui.repaint();
}
});
}
Aggregations