Search in sources :

Example 1 with BundleAdjustmentMetricResidualFunction

use of boofcv.alg.geo.bundle.BundleAdjustmentMetricResidualFunction in project BoofCV by lessthanoptimal.

the class CalibrateStereoPlanar method computeErrors.

public List<ImageResults> computeErrors() {
    final SceneStructureMetric structure = bundleUtils.getStructure();
    final SceneObservations observations = bundleUtils.getObservations();
    List<ImageResults> errors = new ArrayList<>();
    double[] parameters = new double[structure.getParameterCount()];
    double[] residuals = new double[observations.getObservationCount() * 2];
    CodecSceneStructureMetric codec = new CodecSceneStructureMetric();
    codec.encode(structure, parameters);
    BundleAdjustmentMetricResidualFunction function = new BundleAdjustmentMetricResidualFunction();
    function.configure(structure, observations);
    function.process(parameters, residuals);
    int idx = 0;
    for (int i = 0; i < observations.viewsRigid.size; i++) {
        SceneObservations.View v = observations.viewsRigid.data[i];
        ImageResults r = new ImageResults(v.size());
        double sumX = 0;
        double sumY = 0;
        double meanErrorMag = 0;
        double maxError = 0;
        for (int j = 0; j < v.size(); j++) {
            double x = residuals[idx++];
            double y = residuals[idx++];
            double nerr = r.pointError[j] = Math.sqrt(x * x + y * y);
            meanErrorMag += nerr;
            maxError = Math.max(maxError, nerr);
            sumX += x;
            sumY += y;
        }
        r.biasX = sumX / v.size();
        r.biasY = sumY / v.size();
        r.meanError = meanErrorMag / v.size();
        r.maxError = maxError;
        errors.add(r);
    }
    return errors;
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) CodecSceneStructureMetric(boofcv.alg.geo.bundle.CodecSceneStructureMetric) SceneObservations(boofcv.abst.geo.bundle.SceneObservations) ArrayList(java.util.ArrayList) BundleAdjustmentMetricResidualFunction(boofcv.alg.geo.bundle.BundleAdjustmentMetricResidualFunction) CodecSceneStructureMetric(boofcv.alg.geo.bundle.CodecSceneStructureMetric) VerbosePrint(org.ddogleg.struct.VerbosePrint)

Example 2 with BundleAdjustmentMetricResidualFunction

use of boofcv.alg.geo.bundle.BundleAdjustmentMetricResidualFunction in project BoofCV by lessthanoptimal.

the class CalibrationPlanarGridZhang99 method computeErrors.

public List<ImageResults> computeErrors() {
    List<ImageResults> errors = new ArrayList<>();
    double[] parameters = new double[structure.getParameterCount()];
    double[] residuals = new double[observations.getObservationCount() * 2];
    CodecSceneStructureMetric codec = new CodecSceneStructureMetric();
    codec.encode(structure, parameters);
    BundleAdjustmentMetricResidualFunction function = new BundleAdjustmentMetricResidualFunction();
    function.configure(structure, observations);
    function.process(parameters, residuals);
    int idx = 0;
    for (int i = 0; i < observations.viewsRigid.size; i++) {
        SceneObservations.View v = observations.viewsRigid.data[i];
        ImageResults r = new ImageResults(v.size());
        double sumX = 0;
        double sumY = 0;
        double meanErrorMag = 0;
        double maxError = 0;
        for (int j = 0; j < v.size(); j++) {
            double x = r.residuals[j * 2] = residuals[idx++];
            double y = r.residuals[j * 2 + 1] = residuals[idx++];
            double nerr = r.pointError[j] = Math.sqrt(x * x + y * y);
            meanErrorMag += nerr;
            maxError = Math.max(maxError, nerr);
            sumX += x;
            sumY += y;
        }
        r.biasX = sumX / v.size();
        r.biasY = sumY / v.size();
        r.meanError = meanErrorMag / v.size();
        r.maxError = maxError;
        errors.add(r);
    }
    return errors;
}
Also used : ImageResults(boofcv.abst.geo.calibration.ImageResults) SceneObservations(boofcv.abst.geo.bundle.SceneObservations) ArrayList(java.util.ArrayList) BundleAdjustmentMetricResidualFunction(boofcv.alg.geo.bundle.BundleAdjustmentMetricResidualFunction) CodecSceneStructureMetric(boofcv.alg.geo.bundle.CodecSceneStructureMetric) VerbosePrint(org.ddogleg.struct.VerbosePrint)

Aggregations

SceneObservations (boofcv.abst.geo.bundle.SceneObservations)2 BundleAdjustmentMetricResidualFunction (boofcv.alg.geo.bundle.BundleAdjustmentMetricResidualFunction)2 CodecSceneStructureMetric (boofcv.alg.geo.bundle.CodecSceneStructureMetric)2 ArrayList (java.util.ArrayList)2 VerbosePrint (org.ddogleg.struct.VerbosePrint)2 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)1 ImageResults (boofcv.abst.geo.calibration.ImageResults)1