Search in sources :

Example 1 with Format

use of boofcv.io.points.PointCloudIO.Format in project BoofCV by lessthanoptimal.

the class TestPointCloudIO method encode_decode_3D64F.

@Test
void encode_decode_3D64F() throws IOException {
    List<Point3D_F64> expected = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        expected.add(new Point3D_F64(i * 123.45, i - 1.01, i + 2.34));
    }
    Format[] formats = new Format[] { Format.PLY };
    for (Format f : formats) {
        DogArray<Point3D_F64> found = new DogArray<>(Point3D_F64::new);
        found.grow().setTo(1, 1, 1);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        PointCloudIO.save3D(f, PointCloudReader.wrapF64(expected), false, stream);
        InputStream input = new ByteArrayInputStream(stream.toByteArray());
        PointCloudIO.load3D64F(f, input, found);
        // make sure it cleared the points
        assertEquals(expected.size(), found.size);
        for (int i = 0; i < expected.size(); i++) {
            assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F64);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Format(boofcv.io.points.PointCloudIO.Format) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 2 with Format

use of boofcv.io.points.PointCloudIO.Format in project BoofCV by lessthanoptimal.

the class TestPointCloudIO method encode_decode_3D32F.

@Test
void encode_decode_3D32F() throws IOException {
    List<Point3D_F32> expected = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        expected.add(new Point3D_F32(i * 123.45f, i - 1.01f, i + 2.34f));
    }
    Format[] formats = new Format[] { Format.PLY };
    for (Format f : formats) {
        DogArray<Point3D_F32> found = new DogArray<>(Point3D_F32::new);
        found.grow().setTo(1, 1, 1);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        PointCloudIO.save3D(f, PointCloudReader.wrapF32(expected), false, stream);
        InputStream input = new ByteArrayInputStream(stream.toByteArray());
        PointCloudIO.load3D32F(f, input, found);
        // make sure it cleared the points
        assertEquals(expected.size(), found.size);
        for (int i = 0; i < expected.size(); i++) {
            assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F32);
        }
    }
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Format(boofcv.io.points.PointCloudIO.Format) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Aggregations

Format (boofcv.io.points.PointCloudIO.Format)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 DogArray (org.ddogleg.struct.DogArray)2 Test (org.junit.jupiter.api.Test)2 Point3D_F32 (georegression.struct.point.Point3D_F32)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1