Search in sources :

Example 1 with ECoCheckFound

use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound 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 ECoCheckFound

use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound 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 3 with ECoCheckFound

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

the class DetectECoCheckApp method processImage.

@Override
public void processImage(int sourceID, long frameID, BufferedImage buffered, ImageBase input) {
    original = ConvertBufferedImage.checkCopy(buffered, original);
    GrayF32 gray = (GrayF32) input;
    double processingTime;
    synchronized (lockAlgorithm) {
        long time0 = System.nanoTime();
        detector.process(gray);
        long time1 = System.nanoTime();
        // milliseconds
        processingTime = (time1 - time0) * 1e-6;
        FastAccess<ECoCheckFound> found = detector.getFound();
        synchronized (lockVisualize) {
            visualizeUtils.update(detector);
            // Copy found chessboard patterns
            this.foundPatterns.resetResize(found.size);
            for (int i = 0; i < found.size; i++) {
                this.foundPatterns.get(i).setTo(found.get(i));
                // Sort so that they have some sane order when visualized
                Collections.sort(foundPatterns.get(i).corners.toList(), Comparator.comparingInt(a -> a.index));
            }
        }
        System.out.println("found.size=" + found.size);
        for (int i = 0; i < found.size; i++) {
            ECoCheckFound c = found.get(i);
            if (!controlPanel.showAnonymous.value && c.markerID < 0)
                continue;
            System.out.println("[" + i + "]");
            System.out.println("  marker=" + c.markerID);
            System.out.println("  rows=" + c.squareRows);
            System.out.println("  cols=" + c.squareCols);
            System.out.println("  decoded=" + c.decodedCells.size);
        }
    }
    SwingUtilities.invokeLater(() -> {
        controlPanel.setImageSize(original.getWidth(), original.getHeight());
        controlPanel.setProcessingTimeMS(processingTime);
        imagePanel.setBufferedImageNoChange(original);
        imagePanel.repaint();
    });
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) GrayF32(boofcv.struct.image.GrayF32) ShapeVisualizePanel(boofcv.demonstrations.shapes.ShapeVisualizePanel) KeyAdapter(java.awt.event.KeyAdapter) ImageBase(boofcv.struct.image.ImageBase) MAX_ZOOM(boofcv.gui.BoofSwingUtil.MAX_ZOOM) ArrayList(java.util.ArrayList) VisualizeChessboardXCornerUtils(boofcv.demonstrations.calibration.VisualizeChessboardXCornerUtils) StandardAlgConfigPanel(boofcv.gui.StandardAlgConfigPanel) FactoryFiducial(boofcv.factory.fiducial.FactoryFiducial) SimpleImageSequence(boofcv.io.image.SimpleImageSequence) BoofMiscOps(boofcv.misc.BoofMiscOps) MouseAdapter(java.awt.event.MouseAdapter) TitledBorder(javax.swing.border.TitledBorder) ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) UtilAngle(georegression.metric.UtilAngle) UtilIO(boofcv.io.UtilIO) ImageType(boofcv.struct.image.ImageType) BufferedImage(java.awt.image.BufferedImage) UtilCalibrationGui(boofcv.gui.calibration.UtilCalibrationGui) ConfigECoCheckDetector(boofcv.abst.fiducial.calib.ConfigECoCheckDetector) DogArray(org.ddogleg.struct.DogArray) ECoCheckDetector(boofcv.alg.fiducial.calib.ecocheck.ECoCheckDetector) PathLabel(boofcv.io.PathLabel) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) KeyEvent(java.awt.event.KeyEvent) AffineTransform(java.awt.geom.AffineTransform) MouseEvent(java.awt.event.MouseEvent) FastAccess(org.ddogleg.struct.FastAccess) java.awt(java.awt) List(java.util.List) JSpinnerNumber(boofcv.gui.controls.JSpinnerNumber) DetectBlackShapePanel(boofcv.demonstrations.shapes.DetectBlackShapePanel) MIN_ZOOM(boofcv.gui.BoofSwingUtil.MIN_ZOOM) BoofSwingUtil(boofcv.gui.BoofSwingUtil) JCheckBoxValue(boofcv.gui.controls.JCheckBoxValue) ConfigECoCheckMarkers(boofcv.abst.fiducial.calib.ConfigECoCheckMarkers) Comparator(java.util.Comparator) DemonstrationBase(boofcv.gui.DemonstrationBase) Collections(java.util.Collections) ECoCheckFound(boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound) javax.swing(javax.swing) GrayF32(boofcv.struct.image.GrayF32) ECoCheckFound(boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound)

Aggregations

ECoCheckFound (boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound)3 ECoCheckUtils (boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils)2 PointIndex2D_F64 (boofcv.struct.geo.PointIndex2D_F64)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 ConfigECoCheckDetector (boofcv.abst.fiducial.calib.ConfigECoCheckDetector)1 ConfigECoCheckMarkers (boofcv.abst.fiducial.calib.ConfigECoCheckMarkers)1 MarkerShape (boofcv.abst.fiducial.calib.ConfigECoCheckMarkers.MarkerShape)1 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)1 ChessboardCorner (boofcv.alg.feature.detect.chess.ChessboardCorner)1 ECoCheckDetector (boofcv.alg.fiducial.calib.ecocheck.ECoCheckDetector)1 VisualizeChessboardXCornerUtils (boofcv.demonstrations.calibration.VisualizeChessboardXCornerUtils)1 DetectBlackShapePanel (boofcv.demonstrations.shapes.DetectBlackShapePanel)1 ShapeVisualizePanel (boofcv.demonstrations.shapes.ShapeVisualizePanel)1 FactoryFiducial (boofcv.factory.fiducial.FactoryFiducial)1 BoofSwingUtil (boofcv.gui.BoofSwingUtil)1 MAX_ZOOM (boofcv.gui.BoofSwingUtil.MAX_ZOOM)1 MIN_ZOOM (boofcv.gui.BoofSwingUtil.MIN_ZOOM)1 DemonstrationBase (boofcv.gui.DemonstrationBase)1 StandardAlgConfigPanel (boofcv.gui.StandardAlgConfigPanel)1 UtilCalibrationGui (boofcv.gui.calibration.UtilCalibrationGui)1