use of org.ddogleg.struct.DogArray in project BoofCV by lessthanoptimal.
the class ViewPairwiseImageGraphApp method changeSelectedView.
private void changeSelectedView(int viewIdx) {
gui.clear();
if (viewIdx <= -1 || imageFiles == null || viewIdx >= imageFiles.size())
return;
PairwiseImageGraph.View pview = graph.nodes.get(viewIdx);
var features = new DogArray<>(Point2D_F64::new);
BufferedImage original = UtilIO.load(imageFiles.get(viewIdx));
db.lookupPixelFeats(pview.id, features);
gui.setMainImage(pview.id, original, features.toList());
gui.setMainText("Connections: " + pview.connections.size + "\n" + "Features: " + pview.totalObservations + "\n");
for (int i = 0; i < pview.connections.size; i++) {
PairwiseImageGraph.Motion m = pview.connections.get(i);
PairwiseImageGraph.View other = m.other(pview);
BufferedImage otherImage = UtilIO.load(imageFiles.get(other.index));
db.lookupPixelFeats(pview.id, features);
gui.addRelatedImage(other.id, otherImage, features.toList());
gui.setRelatedText(other.id, "3d=" + m.is3D + " inliers=" + m.inliers.size);
}
}
use of org.ddogleg.struct.DogArray in project BoofCV by lessthanoptimal.
the class TestPlyCodec method encode_decode_3D_binary.
@Test
void encode_decode_3D_binary() 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));
}
for (boolean asFloat : new boolean[] { true, false }) {
DogArray<Point3D_F64> found = new DogArray<>(Point3D_F64::new);
ByteArrayOutputStream output = new ByteArrayOutputStream();
PlyCodec.saveBinary(PointCloudReader.wrapF64(expected), ByteOrder.BIG_ENDIAN, false, asFloat, output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
PlyCodec.read(input, PointCloudWriter.wrapF64(found));
assertEquals(expected.size(), found.size);
double tol = asFloat ? UtilEjml.TEST_F32 : UtilEjml.TEST_F64;
for (int i = 0; i < found.size; i++) {
assertEquals(0.0, found.get(i).distance(expected.get(i)), tol);
}
}
}
use of org.ddogleg.struct.DogArray in project BoofCV by lessthanoptimal.
the class TestPlyCodec method encode_decode_3DRGB_ascii.
@Test
void encode_decode_3DRGB_ascii() throws IOException {
List<Point3dRgbI_F64> expected = new ArrayList<>();
for (int i = 0; i < 10; i++) {
int r = (10 * i) & 0xFF;
int g = (28 * i) & 0xFF;
int b = (58 * i) & 0xFF;
int rgb = r << 16 | g << 16 | b;
expected.add(new Point3dRgbI_F64(i * 123.45, i - 1.01, i + 2.34, rgb));
}
DogArray<Point3dRgbI_F64> found = new DogArray<>(Point3dRgbI_F64::new);
Writer output = new StringWriter();
PlyCodec.saveAscii(PointCloudReader.wrapF64RGB(expected), true, output);
InputStream input = new ByteArrayInputStream(output.toString().getBytes(UTF_8));
PlyCodec.read(input, PointCloudWriter.wrapF64RGB(found));
assertEquals(expected.size(), found.size);
for (int i = 0; i < found.size; i++) {
assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F64);
}
}
use of org.ddogleg.struct.DogArray in project BoofCV by lessthanoptimal.
the class TestPlyCodec method encode_decode_3D_ascii.
@Test
void encode_decode_3D_ascii() 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));
}
DogArray<Point3D_F64> found = new DogArray<>(Point3D_F64::new);
Writer output = new StringWriter();
PlyCodec.saveAscii(PointCloudReader.wrapF64(expected), false, output);
InputStream input = new ByteArrayInputStream(output.toString().getBytes(UTF_8));
PlyCodec.read(input, PointCloudWriter.wrapF64(found));
assertEquals(expected.size(), found.size);
for (int i = 0; i < found.size; i++) {
assertEquals(0.0, found.get(i).distance(expected.get(i)), UtilEjml.TEST_F64);
}
}
use of org.ddogleg.struct.DogArray 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);
}
}
}
Aggregations