Search in sources :

Example 11 with CalibrationObservation

use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.

the class AssistedCalibration method handleDetermineSize.

private void handleDetermineSize(boolean detected) {
    String message = "Determine Scale: Hold target in view and center";
    if (detected) {
        double stationaryTime = actions.getStationaryTime();
        CalibrationObservation points = detector.getDetectedPoints();
        view.getQuadFocus(points, focusQuad);
        double top = focusQuad.get(0).distance(focusQuad.get(1));
        double right = focusQuad.get(1).distance(focusQuad.get(2));
        double bottom = focusQuad.get(2).distance(focusQuad.get(3));
        double left = focusQuad.get(3).distance(focusQuad.get(0));
        double ratioHorizontal = Math.min(top, bottom) / Math.max(top, bottom);
        double ratioVertical = Math.min(left, right) / Math.max(left, right);
        boolean skewed = false;
        if (ratioHorizontal <= CENTER_SKEW || ratioVertical <= CENTER_SKEW) {
            actions.resetStationary();
            skewed = true;
            ratioHorizontal *= 100.0;
            ratioVertical *= 100.0;
            message = String.format("Straighten out.  H %3d   V %3d", (int) ratioHorizontal, (int) ratioVertical);
        } else {
            if (stationaryTime > STILL_THRESHOLD) {
                actions.resetStationary();
                saver.setTemplate(input, focusQuad);
                gui.getInfoPanel().updateTemplate(saver.getTemplate());
                actions.resetStationary();
                state = State.REMOVE_DOTS;
                canonicalWidth = Math.max(top, bottom);
                padding = (int) (view.getBufferWidth(canonicalWidth) * 1.1);
                selectMagnetLocations();
            }
            if (stationaryTime > DISPLAY_TIME) {
                message = String.format("Hold still:  %6.1f", stationaryTime);
            }
        }
        int r = 6;
        int w = 2 * r + 1;
        if (skewed) {
            g2.setColor(Color.BLUE);
            for (int i = 0; i < points.size(); i++) {
                Point2D_F64 p = points.points.get(i);
                ellipse.setFrame(p.x - r, p.y - r, w, w);
                g2.draw(ellipse);
            }
        } else {
            renderCalibrationPoints(stationaryTime, points.points);
        }
    }
    gui.setMessage(message);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) UtilPoint2D_F64(georegression.geometry.UtilPoint2D_F64) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 12 with CalibrationObservation

use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.

the class GenericPlanarCalibrationDetectorChecks method checkPointIndexIncreasingOrder.

/**
 * Observations points should always be in increasing order
 */
@Test
public void checkPointIndexIncreasingOrder() {
    for (Object layout : targetConfigs) {
        DetectorFiducialCalibration detector = createDetector(layout);
        GrayF32 original = renderEasy(layout, null);
        assertTrue(detector.process(original));
        CalibrationObservation found = detector.getDetectedPoints();
        assertEquals(detector.getLayout().size(), found.size());
        for (int i = 0; i < found.size(); i++) {
            assertEquals(i, found.get(i).index);
        }
    }
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation) Test(org.junit.Test)

Example 13 with CalibrationObservation

use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.

the class AssistedCalibration method handleFillScreen.

private void handleFillScreen(boolean detected) {
    String message = "Tint the screen!";
    drawPadding();
    if (detected) {
        gui.getInfoPanel().updateView(saver.getCurrentView());
        gui.getInfoPanel().updateFocusScore(saver.getFocusScore());
        double stationaryTime = actions.getStationaryTime();
        CalibrationObservation points = detector.getDetectedPoints();
        view.getSidesCollision(points, sidesCollision);
        view.getQuadFocus(points, focusQuad);
        saver.process(input, focusQuad);
        boolean resetImageSelector = true;
        if (pictureTaken) {
            if (stationaryTime >= STILL_THRESHOLD) {
                message = "Move somewhere else";
            } else {
                pictureTaken = false;
            }
        } else if (stationaryTime >= STILL_THRESHOLD) {
            saver.save();
            pictureTaken = true;
            message = "Move somewhere else";
            captureFiducialPoints();
        } else if (stationaryTime > DISPLAY_TIME) {
            resetImageSelector = false;
            message = String.format("Hold still:  %6.1f", stationaryTime);
        }
        // save the images if the fiducial is being held still prior to capture
        if (resetImageSelector) {
            saver.clearHistory();
        } else {
            saver.process(input, focusQuad);
        }
        renderCalibrationPoints(stationaryTime, points.points);
    }
    renderFillPolygons();
    gui.setMessage(message);
}
Also used : CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 14 with CalibrationObservation

use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.

the class TestCalibrateMonoPlanar method createFakeObservations.

private CalibrationObservation createFakeObservations(int which) {
    Se3_F64 t2c = targetToCamera.get(which);
    CalibrationObservation set = new CalibrationObservation(intrinsic.width, intrinsic.height);
    for (int i = 0; i < layout.size(); i++) {
        Point2D_F64 p2 = layout.get(i);
        // location of calibration point on the target
        Point3D_F64 p3 = new Point3D_F64(p2.x, p2.y, 0);
        Point3D_F64 a = SePointOps_F64.transform(t2c, p3, null);
        Point2D_F64 pixel = new Point2D_F64();
        normToPixel.compute(a.x / a.z, a.y / a.z, pixel);
        if (pixel.x < 0 || pixel.x >= intrinsic.width - 1 || pixel.y < 0 || pixel.y >= intrinsic.height - 1)
            throw new RuntimeException("Adjust test setup, bad observation");
        set.add(pixel, i);
    }
    return set;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Se3_F64(georegression.struct.se.Se3_F64) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 15 with CalibrationObservation

use of boofcv.alg.geo.calibration.CalibrationObservation in project BoofCV by lessthanoptimal.

the class TestCalibrateStereoPlanar method createFakeObservations.

private CalibrationObservation createFakeObservations(int which, boolean left) {
    Se3_F64 t2l = targetToLeft.get(which);
    Se3_F64 t2c;
    if (left) {
        t2c = t2l;
    } else {
        t2c = new Se3_F64();
        t2l.concat(leftToRight, t2c);
    }
    CalibrationObservation set = new CalibrationObservation(intrinsic.width, intrinsic.height);
    for (int i = 0; i < layout.size(); i++) {
        Point2D_F64 p2 = layout.get(i);
        // location of calibration point on the target
        Point3D_F64 p3 = new Point3D_F64(p2.x, p2.y, 0);
        Point3D_F64 a = SePointOps_F64.transform(t2c, p3, null);
        Point2D_F64 pixel = new Point2D_F64();
        normToPixel.compute(a.x / a.z, a.y / a.z, pixel);
        if (pixel.x < 0 || pixel.x >= intrinsic.width - 1 || pixel.y < 0 || pixel.y >= intrinsic.height - 1)
            throw new RuntimeException("Adjust test setup, bad observation");
        set.add(pixel, i);
    }
    return set;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Se3_F64(georegression.struct.se.Se3_F64) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Aggregations

CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)16 Point2D_F64 (georegression.struct.point.Point2D_F64)6 PointIndex2D_F64 (boofcv.struct.geo.PointIndex2D_F64)5 GrayF32 (boofcv.struct.image.GrayF32)5 DetectorFiducialCalibration (boofcv.abst.geo.calibration.DetectorFiducialCalibration)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 BufferedImage (java.awt.image.BufferedImage)3 Grid (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)2 StereoParameters (boofcv.struct.calib.StereoParameters)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 Test (org.junit.Test)2 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)1 CalibrateStereoPlanar (boofcv.abst.geo.calibration.CalibrateStereoPlanar)1 DetectFiducialSquareGrid (boofcv.alg.fiducial.calib.DetectFiducialSquareGrid)1 DetectCircleHexagonalGrid (boofcv.alg.fiducial.calib.circle.DetectCircleHexagonalGrid)1 DetectCircleRegularGrid (boofcv.alg.fiducial.calib.circle.DetectCircleRegularGrid)1 KeyPointsCircleHexagonalGrid (boofcv.alg.fiducial.calib.circle.KeyPointsCircleHexagonalGrid)1 KeyPointsCircleRegularGrid (boofcv.alg.fiducial.calib.circle.KeyPointsCircleRegularGrid)1