Search in sources :

Example 1 with PointIndex2D_F64

use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.

the class DisplayPinholeCalibrationPanel method drawFeatures.

private void drawFeatures(Graphics2D g2, double scale) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    CalibrationObservation set = features;
    Point2D_F32 adj = new Point2D_F32();
    if (showOrder) {
        List<Point2D_F64> adjusted;
        if (showUndistorted) {
            adjusted = new ArrayList<>();
            for (PointIndex2D_F64 p : set.points) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
                adjusted.add(new Point2D_F64(adj.x, adj.y));
            }
        } else {
            adjusted = (List) set.points;
        }
        renderOrder(g2, scale, adjusted);
    }
    if (showPoints) {
        g2.setColor(Color.BLACK);
        g2.setStroke(new BasicStroke(3));
        for (PointIndex2D_F64 p : set.points) {
            if (showUndistorted) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
            } else {
                adj.set((float) p.x, (float) p.y);
            }
            VisualizeFeatures.drawCross(g2, adj.x * scale, adj.y * scale, 4);
        }
        g2.setStroke(new BasicStroke(1));
        g2.setColor(Color.RED);
        for (PointIndex2D_F64 p : set.points) {
            if (showUndistorted) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
            } else {
                adj.set((float) p.x, (float) p.y);
            }
            VisualizeFeatures.drawCross(g2, adj.x * scale, adj.y * scale, 4);
        }
    }
    if (showAll) {
        for (CalibrationObservation l : allFeatures) {
            for (PointIndex2D_F64 p : l.points) {
                if (showUndistorted) {
                    remove_p_to_p.compute((float) p.x, (float) p.y, adj);
                } else {
                    adj.set((float) p.x, (float) p.y);
                }
                VisualizeFeatures.drawPoint(g2, adj.x * scale, adj.y * scale, 2, Color.BLUE, false);
            }
        }
    }
    if (showNumbers) {
        if (showUndistorted)
            drawNumbers(g2, set, remove_p_to_p, scale);
        else
            drawNumbers(g2, set, null, scale);
    }
    if (showErrors && results != null) {
        for (int i = 0; i < set.size(); i++) {
            PointIndex2D_F64 p = set.get(i);
            if (showUndistorted) {
                remove_p_to_p.compute((float) p.x, (float) p.y, adj);
            } else {
                adj.set((float) p.x, (float) p.y);
            }
            double r = scale * errorScale * results.pointError[i];
            if (r < 1)
                continue;
            g2.setStroke(new BasicStroke(4));
            g2.setColor(Color.BLACK);
            VisualizeFeatures.drawCircle(g2, adj.x * scale, adj.y * scale, r);
            g2.setStroke(new BasicStroke(2.5f));
            g2.setColor(Color.ORANGE);
            VisualizeFeatures.drawCircle(g2, adj.x * scale, adj.y * scale, r);
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) Point2D_F32(georegression.struct.point.Point2D_F32) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 2 with PointIndex2D_F64

use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.

the class CalibrationObservation method setTo.

public void setTo(CalibrationObservation obs) {
    reset();
    this.width = obs.width;
    this.height = obs.height;
    for (int i = 0; i < obs.size(); i++) {
        PointIndex2D_F64 p = obs.points.get(i);
        points.add(p.copy());
    }
}
Also used : PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64)

Example 3 with PointIndex2D_F64

use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.

the class GenericPlanarCalibrationDetectorChecks method dataNotRecycled.

/**
 * Make sure new instances of calibration points are returned each time
 */
@Test
public void dataNotRecycled() {
    for (Object layout : targetConfigs) {
        DetectorFiducialCalibration detector = createDetector(layout);
        GrayF32 original = renderEasy(layout, null);
        assertTrue(detector.process(original));
        CalibrationObservation found0 = detector.getDetectedPoints();
        assertTrue(detector.process(original));
        CalibrationObservation found1 = detector.getDetectedPoints();
        assertEquals(found0.size(), found1.size());
        assertTrue(found0 != found1);
        for (int i = 0; i < found0.size(); i++) {
            PointIndex2D_F64 p0 = found0.get(i);
            for (int j = 0; j < found1.size(); j++) {
                PointIndex2D_F64 p1 = found1.get(j);
                assertFalse(p0 == p1);
            }
        }
    }
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation) Test(org.junit.Test)

Example 4 with PointIndex2D_F64

use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.

the class ExampleDetectCalibrationPoints method main.

public static void main(String[] args) {
    // load the test image
    // String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Square");
    String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess");
    BufferedImage orig = UtilImageIO.loadImage(directory + "/left01.jpg");
    GrayF32 input = ConvertBufferedImage.convertFrom(orig, (GrayF32) null);
    // To select different types of detectors add or remove comments below
    DetectorFiducialCalibration detector;
    // For chessboard targets, tune RADIUS parameter for your images
    // detector = FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
    detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
    // process the image and check for failure condition
    if (!detector.process(input))
        throw new RuntimeException("Target detection failed!");
    // Ordered observations of calibration points on the target
    CalibrationObservation set = detector.getDetectedPoints();
    // render and display the results
    Graphics2D g2 = orig.createGraphics();
    for (PointIndex2D_F64 p : set.points) VisualizeFeatures.drawPoint(g2, p.x, p.y, 3, Color.RED, true);
    ShowImages.showWindow(orig, "Calibration Points", true);
}
Also used : DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Example 5 with PointIndex2D_F64

use of boofcv.struct.geo.PointIndex2D_F64 in project BoofCV by lessthanoptimal.

the class CalibrationFiducialDetector method getCenter.

/**
 * Returns the detection point average location.  This will NOT be the same as the geometric center.
 *
 * @param which Fiducial's index
 * @param location (output) Storage for the transform. modified.
 */
@Override
public void getCenter(int which, Point2D_F64 location) {
    CalibrationObservation view = detector.getDetectedPoints();
    location.set(0, 0);
    for (int i = 0; i < view.size(); i++) {
        PointIndex2D_F64 p = view.get(i);
        location.x += p.x;
        location.y += p.y;
    }
    location.x /= view.size();
    location.y /= view.size();
}
Also used : PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) CalibrationObservation(boofcv.alg.geo.calibration.CalibrationObservation)

Aggregations

PointIndex2D_F64 (boofcv.struct.geo.PointIndex2D_F64)8 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)5 DetectorFiducialCalibration (boofcv.abst.geo.calibration.DetectorFiducialCalibration)2 GrayF32 (boofcv.struct.image.GrayF32)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 Point2D3D (boofcv.struct.geo.Point2D3D)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1 BufferedImage (java.awt.image.BufferedImage)1 Test (org.junit.Test)1