Search in sources :

Example 1 with AccessPointTracks

use of boofcv.abst.sfm.AccessPointTracks in project BoofCV by lessthanoptimal.

the class MonoOverhead_to_MonocularPlaneVisualOdometry method computeTracks.

private void computeTracks() {
    if (computed)
        return;
    if (!(alg.getMotion2D() instanceof AccessPointTracks))
        return;
    AccessPointTracks accessPlane = (AccessPointTracks) alg.getMotion2D();
    List<Point2D_F64> tracksPlane = accessPlane.getAllTracks();
    OverheadView<T> map = alg.getOverhead();
    points3D.reset();
    pixels.reset();
    for (Point2D_F64 worldPt : tracksPlane) {
        // 2D to 3D
        Point3D_F64 p = points3D.grow();
        p.z = worldPt.x * map.cellSize - map.centerX;
        p.x = -(worldPt.y * map.cellSize - map.centerY);
        p.y = 0;
        // 3D world to camera
        SePointOps_F64.transform(planeToCamera, p, p);
        // normalized image coordinates
        normToPixel.compute(p.x / p.z, p.y / p.z, pixels.grow());
    }
    computed = true;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) AccessPointTracks(boofcv.abst.sfm.AccessPointTracks)

Example 2 with AccessPointTracks

use of boofcv.abst.sfm.AccessPointTracks 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();
        }
    });
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) AccessPointTracks(boofcv.abst.sfm.AccessPointTracks) Homography2D_F64(georegression.struct.homography.Homography2D_F64)

Aggregations

AccessPointTracks (boofcv.abst.sfm.AccessPointTracks)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 ArrayList (java.util.ArrayList)1