Search in sources :

Example 1 with ECoCheckUtils

use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.

the class ECoCheck_to_FiducialDetector method getControl3D.

@Override
protected List<Point2D3D> getControl3D(int which) {
    Objects.requireNonNull(pixelToNorm);
    ECoCheckFound found = foundIndexToFound(which);
    MarkerShape marker = markerShapes.get(found.markerID);
    points2D3D.resetResize(found.corners.size);
    ECoCheckUtils utils = detector.getUtils();
    // length of the longest side on the marker
    double markerLength = Math.max(marker.getWidth(), marker.getHeight());
    for (int i = 0; i < found.corners.size; i++) {
        PointIndex2D_F64 corner = found.corners.get(i);
        Point2D3D p23 = points2D3D.get(i);
        utils.cornerToMarker3D(found.markerID, corner.index, p23.location);
        pixelToNorm.compute(corner.p.x, corner.p.y, p23.observation);
        // Convert the units
        p23.location.scale(markerLength);
    }
    return points2D3D.toList();
}
Also used : Point2D3D(boofcv.struct.geo.Point2D3D) MarkerShape(boofcv.abst.fiducial.calib.ConfigECoCheckMarkers.MarkerShape) ECoCheckUtils(boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) ECoCheckFound(boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound)

Example 2 with ECoCheckUtils

use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.

the class CalibrationDetectorMultiECoCheck method getLayout.

@Override
public List<Point2D_F64> getLayout(int markerID) {
    List<Point2D_F64> layout = cacheLayouts.get(markerID);
    if (layout != null)
        return layout;
    ECoCheckUtils utils = detector.getUtils();
    ConfigECoCheckMarkers.MarkerShape shape = markers.get(markerID);
    // Create a list of points that defines the layout
    Point3D_F64 p = new Point3D_F64();
    layout = new ArrayList<>();
    int numCorners = shape.getNumCorners();
    for (int cornerID = 0; cornerID < numCorners; cornerID++) {
        utils.cornerToMarker3D(markerID, cornerID, shape.squareSize, p);
        layout.add(cornerID, new Point2D_F64(p.x, p.y));
    }
    cacheLayouts.put(markerID, layout);
    return layout;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) ECoCheckUtils(boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 3 with ECoCheckUtils

use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.

the class ECoCheck_to_FiducialDetector method detect.

@Override
public void detect(T input) {
    detector.process(input);
    // Find all the known detections
    foundToDetection.reset();
    for (int detectionID = 0; detectionID < detector.getFound().size; detectionID++) {
        ECoCheckFound found = detector.found.get(detectionID);
        if (found.markerID < 0)
            continue;
        foundToDetection.add(detectionID);
    }
    ECoCheckUtils utils = detector.getUtils();
    Estimate1ofEpipolar computeHomography = FactoryMultiView.homographyTLS();
    // Compute homographies for each marker
    listMarkerToPixels.reset();
    for (int knownIdx = 0; knownIdx < foundToDetection.size; knownIdx++) {
        int detectionID = foundToDetection.get(knownIdx);
        ECoCheckFound found = detector.found.get(detectionID);
        int markerID = found.markerID;
        // create a list of pairs from marker coordinates to pixels
        pairs.resetResize(found.corners.size);
        for (int i = 0; i < found.corners.size; i++) {
            PointIndex2D_F64 foundCorner = found.corners.get(i);
            // Get location of corner on marker in marker units
            utils.cornerToMarker3D(markerID, foundCorner.index, point3);
            // Observed pixel coordinate of corner
            Point2D_F64 p = found.corners.get(i).p;
            pairs.get(i).setTo(point3.x, point3.y, p.x, p.y);
        }
        // Find the homography that relates the coordinate systems
        Homography2D_F64 h = listMarkerToPixels.grow();
        if (!computeHomography.process(pairs.toList(), tmp)) {
            // well this is unexpected. Let's just silently fail.
            CommonOps_DDF3.fill(h, 0);
        } else {
            DConvertMatrixStruct.convert(tmp, h);
        }
    }
}
Also used : ECoCheckUtils(boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils) Estimate1ofEpipolar(boofcv.abst.geo.Estimate1ofEpipolar) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) ECoCheckFound(boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound) Homography2D_F64(georegression.struct.homography.Homography2D_F64)

Example 4 with ECoCheckUtils

use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils in project BoofCV by lessthanoptimal.

the class UtilCalibrationGui method renderTargetBuffered.

public static BufferedImage renderTargetBuffered(CalibrationPatterns type, Object config, int squareWidth) {
    int circle = squareWidth / 2;
    if (type == CalibrationPatterns.ECOCHECK) {
        ConfigECoCheckMarkers c = (ConfigECoCheckMarkers) config;
        ECoCheckUtils utils = new ECoCheckUtils();
        utils.codec.setErrorCorrectionLevel(c.errorCorrectionLevel);
        utils.codec.setChecksumBitCount(c.checksumBits);
        c.convertToGridList(utils.markers);
        utils.fixate();
        ConfigECoCheckMarkers.MarkerShape shape = c.markerShapes.get(0);
        int markerWidth = squareWidth * (shape.numCols - 1);
        int markerHeight = squareWidth * (shape.numRows - 1);
        FiducialRenderEngineGraphics2D render = configureRenderGraphics2D(markerWidth, markerHeight, squareWidth / 2);
        ECoCheckGenerator generator = new ECoCheckGenerator(utils);
        generator.squareWidth = squareWidth;
        generator.setRender(render);
        generator.render(0);
        return render.getImage();
    } else if (type == CalibrationPatterns.HAMMING_CHESSBOARD) {
        ConfigHammingChessboard c = (ConfigHammingChessboard) config;
        int markerWidth = squareWidth * c.numCols;
        int markerHeight = squareWidth * c.numRows;
        FiducialRenderEngineGraphics2D render = configureRenderGraphics2D(markerWidth, markerHeight, squareWidth / 2);
        HammingChessboardGenerator generator = new HammingChessboardGenerator(c);
        generator.squareWidth = squareWidth;
        generator.setRender(render);
        generator.render();
        return render.getImage();
    } else if (type == CalibrationPatterns.HAMMING_GRID) {
        ConfigHammingGrid c = (ConfigHammingGrid) config;
        int markerWidth = (int) Math.round(squareWidth * c.getMarkerWidth() / c.squareSize);
        int markerHeight = (int) Math.round(squareWidth * c.getMarkerHeight() / c.squareSize);
        FiducialRenderEngineGraphics2D render = configureRenderGraphics2D(markerWidth, markerHeight, squareWidth / 2);
        var generator = new HammingGridGenerator(c);
        generator.squareWidth = squareWidth;
        generator.setRender(render);
        generator.render();
        return render.getImage();
    }
    final RenderCalibrationTargetsGraphics2D renderer = new RenderCalibrationTargetsGraphics2D(20, 1);
    if (type == CalibrationPatterns.CHESSBOARD) {
        ConfigGridDimen c = (ConfigGridDimen) config;
        renderer.chessboard(c.numRows, c.numCols, squareWidth);
    } else if (type == CalibrationPatterns.SQUARE_GRID) {
        ConfigGridDimen c = (ConfigGridDimen) config;
        double space = squareWidth * c.shapeDistance / c.shapeSize;
        renderer.squareGrid(c.numRows, c.numCols, squareWidth, space);
    } else if (type == CalibrationPatterns.CIRCLE_GRID) {
        ConfigGridDimen c = (ConfigGridDimen) config;
        double space = circle * c.shapeDistance / c.shapeSize;
        renderer.circleRegular(c.numRows, c.numCols, circle, space);
    } else if (type == CalibrationPatterns.CIRCLE_HEXAGONAL) {
        ConfigGridDimen c = (ConfigGridDimen) config;
        double space = circle * c.shapeDistance / c.shapeSize;
        renderer.circleHex(c.numRows, c.numCols, circle, space);
    }
    return renderer.getBuffered();
}
Also used : ConfigGridDimen(boofcv.abst.fiducial.calib.ConfigGridDimen) FiducialRenderEngineGraphics2D(boofcv.gui.FiducialRenderEngineGraphics2D) ECoCheckUtils(boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils) ConfigHammingGrid(boofcv.factory.fiducial.ConfigHammingGrid) ConfigHammingChessboard(boofcv.factory.fiducial.ConfigHammingChessboard) HammingChessboardGenerator(boofcv.alg.fiducial.calib.hammingchess.HammingChessboardGenerator) RenderCalibrationTargetsGraphics2D(boofcv.gui.RenderCalibrationTargetsGraphics2D) ConfigECoCheckMarkers(boofcv.abst.fiducial.calib.ConfigECoCheckMarkers) ECoCheckGenerator(boofcv.alg.fiducial.calib.ecocheck.ECoCheckGenerator) HammingGridGenerator(boofcv.alg.fiducial.calib.hamminggrids.HammingGridGenerator)

Aggregations

ECoCheckUtils (boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils)4 ECoCheckFound (boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound)2 PointIndex2D_F64 (boofcv.struct.geo.PointIndex2D_F64)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 ConfigECoCheckMarkers (boofcv.abst.fiducial.calib.ConfigECoCheckMarkers)1 MarkerShape (boofcv.abst.fiducial.calib.ConfigECoCheckMarkers.MarkerShape)1 ConfigGridDimen (boofcv.abst.fiducial.calib.ConfigGridDimen)1 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)1 ECoCheckGenerator (boofcv.alg.fiducial.calib.ecocheck.ECoCheckGenerator)1 HammingChessboardGenerator (boofcv.alg.fiducial.calib.hammingchess.HammingChessboardGenerator)1 HammingGridGenerator (boofcv.alg.fiducial.calib.hamminggrids.HammingGridGenerator)1 ConfigHammingChessboard (boofcv.factory.fiducial.ConfigHammingChessboard)1 ConfigHammingGrid (boofcv.factory.fiducial.ConfigHammingGrid)1 FiducialRenderEngineGraphics2D (boofcv.gui.FiducialRenderEngineGraphics2D)1 RenderCalibrationTargetsGraphics2D (boofcv.gui.RenderCalibrationTargetsGraphics2D)1 Point2D3D (boofcv.struct.geo.Point2D3D)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1