Search in sources :

Example 16 with DogArray_F64

use of org.ddogleg.struct.DogArray_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewStereoFromKnownSceneStructure method checkCloudPlane.

/**
 * Checks to see if the point cloud is as expected. A 2D square planar object at a known distance and size. This
 * takes in account noise
 */
private void checkCloudPlane(List<Point3D_F64> cloud) {
    assertTrue(cloud.size() > 100);
    DogArray_F64 arrayZ = new DogArray_F64();
    arrayZ.resize(cloud.size());
    arrayZ.reset();
    double error = 0.0;
    double x0 = Double.MAX_VALUE, x1 = -Double.MAX_VALUE;
    double y0 = Double.MAX_VALUE, y1 = -Double.MAX_VALUE;
    for (int i = 0; i < cloud.size(); i++) {
        Point3D_F64 p = cloud.get(i);
        double z = p.z;
        if (// skip points at infinity
        UtilEjml.isUncountable(z))
            continue;
        arrayZ.add(z);
        error += Math.abs(z - planeZ);
        // Only consider points which are very good fits
        if (Math.abs(z - planeZ) > 0.01)
            continue;
        x0 = Math.min(x0, p.x);
        x1 = Math.max(x1, p.x);
        y0 = Math.min(y0, p.y);
        y1 = Math.max(y1, p.y);
    }
    arrayZ.sort();
    error /= cloud.size();
    // Use the median depth to check distance
    assertEquals(planeZ, arrayZ.getFraction(0.5), 0.005);
    assertEquals(0.0, error, 0.04);
    // The accuracy here is largely dependent on the image resolution, which sucks.
    // 800x600 is within 0.04
    assertEquals(-1.5, x0, 0.3);
    assertEquals(1.5, x1, 0.3);
    assertEquals(-1.5, y0, 0.3);
    assertEquals(1.5, y1, 0.3);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) DogArray_F64(org.ddogleg.struct.DogArray_F64)

Aggregations

DogArray_F64 (org.ddogleg.struct.DogArray_F64)16 Test (org.junit.jupiter.api.Test)5 Circle2D_F64 (georegression.struct.trig.Circle2D_F64)4 DogArray_I32 (org.ddogleg.struct.DogArray_I32)4 ScalePoint (boofcv.struct.feature.ScalePoint)3 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)3 GrayF32 (boofcv.struct.image.GrayF32)3 ArrayList (java.util.ArrayList)3 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 SiftDetector (boofcv.alg.feature.detect.interest.SiftDetector)1 SiftPoint (boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint)1 ConfigFiducialImage (boofcv.factory.fiducial.ConfigFiducialImage)1 ConfigThreshold (boofcv.factory.filter.binary.ConfigThreshold)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 GrayU8 (boofcv.struct.image.GrayU8)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 BufferedImage (java.awt.image.BufferedImage)1