use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.
the class TestVisualDepthOps method depthTo3D_with_rgb.
@Test
public void depthTo3D_with_rgb() {
GrayU16 depth = new GrayU16(width, height);
depth.set(200, 80, 3400);
depth.set(600, 420, 50);
Planar<GrayU8> rgb = new Planar<>(GrayU8.class, width, height, 3);
GImageMiscOps.fillUniform(rgb, rand, 0, 200);
FastQueue<Point3D_F64> pts = new FastQueue<>(Point3D_F64.class, true);
FastQueueArray_I32 color = new FastQueueArray_I32(3);
VisualDepthOps.depthTo3D(param, rgb, depth, pts, color);
assertEquals(2, pts.size());
assertEquals(2, color.size());
assertEquals(0, compute(200, 80, 3400).distance(pts.get(0)), 1e-8);
assertEquals(0, compute(600, 420, 50).distance(pts.get(1)), 1e-8);
color(200, 80, rgb, color.get(0));
color(600, 420, rgb, color.get(1));
}
use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.
the class CreateRgbPointCloudFileApp method main.
public static void main(String[] args) throws IOException {
String baseDir = "log/";
String nameRgb = baseDir + "rgb0000000.ppm";
String nameDepth = baseDir + "depth0000000.depth";
String nameCalib = baseDir + "intrinsic.yaml";
CameraPinholeRadial param = CalibrationIO.load(nameCalib);
GrayU16 depth = new GrayU16(1, 1);
Planar<GrayU8> rgb = new Planar<>(GrayU8.class, 1, 1, 3);
UtilImageIO.loadPPM_U8(nameRgb, rgb, null);
UtilOpenKinect.parseDepth(nameDepth, depth, null);
FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class, true);
FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);
VisualDepthOps.depthTo3D(param, rgb, depth, cloud, cloudColor);
DataOutputStream file = new DataOutputStream(new FileOutputStream("kinect_pointcloud.txt"));
file.write("# Kinect RGB Point cloud. Units: millimeters. Format: X Y Z R G B\n".getBytes());
for (int i = 0; i < cloud.size; i++) {
Point3D_F64 p = cloud.get(i);
int[] color = cloudColor.get(i);
String line = String.format("%.10f %.10f %.10f %d %d %d\n", p.x, p.y, p.z, color[0], color[1], color[2]);
file.write(line.getBytes());
}
file.close();
System.out.println("Total points = " + cloud.size);
}
use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.
the class DisplayKinectPointCloudApp method main.
public static void main(String[] args) throws IOException {
String baseDir = UtilIO.pathExample("kinect/basket");
String nameRgb = "basket_rgb.png";
String nameDepth = "basket_depth.png";
String nameCalib = "intrinsic.yaml";
CameraPinholeRadial param = CalibrationIO.load(new File(baseDir, nameCalib));
GrayU16 depth = UtilImageIO.loadImage(new File(baseDir, nameDepth), false, ImageType.single(GrayU16.class));
Planar<GrayU8> rgb = UtilImageIO.loadImage(new File(baseDir, nameRgb), true, ImageType.pl(3, GrayU8.class));
FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class, true);
FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);
VisualDepthOps.depthTo3D(param, rgb, depth, cloud, cloudColor);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
PointCloudViewer viewer = new PointCloudViewer(K, 10.0);
viewer.setPreferredSize(new Dimension(rgb.width, rgb.height));
for (int i = 0; i < cloud.size; i++) {
Point3D_F64 p = cloud.get(i);
int[] color = cloudColor.get(i);
int c = (color[0] << 16) | (color[1] << 8) | color[2];
viewer.addPoint(p.x, p.y, p.z, c);
}
ShowImages.showWindow(viewer, "Point Cloud", true);
System.out.println("Total points = " + cloud.size);
// BufferedImage depthOut = VisualizeImageData.disparity(depth, null, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE, 0);
// ShowImages.showWindow(depthOut,"Depth Image", true);
}
use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.
the class ExampleDepthPointCloud method main.
public static void main(String[] args) throws IOException {
String nameRgb = UtilIO.pathExample("kinect/basket/basket_rgb.png");
String nameDepth = UtilIO.pathExample("kinect/basket/basket_depth.png");
String nameCalib = UtilIO.pathExample("kinect/basket/visualdepth.yaml");
VisualDepthParameters param = CalibrationIO.load(nameCalib);
BufferedImage buffered = UtilImageIO.loadImage(nameRgb);
Planar<GrayU8> rgb = ConvertBufferedImage.convertFromPlanar(buffered, null, true, GrayU8.class);
GrayU16 depth = ConvertBufferedImage.convertFrom(UtilImageIO.loadImage(nameDepth), null, GrayU16.class);
FastQueue<Point3D_F64> cloud = new FastQueue<>(Point3D_F64.class, true);
FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);
VisualDepthOps.depthTo3D(param.visualParam, rgb, depth, cloud, cloudColor);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param.visualParam, (DMatrixRMaj) null);
PointCloudViewer viewer = new PointCloudViewer(K, 15);
viewer.setPreferredSize(new Dimension(rgb.width, rgb.height));
for (int i = 0; i < cloud.size; i++) {
Point3D_F64 p = cloud.get(i);
int[] color = cloudColor.get(i);
int c = (color[0] << 16) | (color[1] << 8) | color[2];
viewer.addPoint(p.x, p.y, p.z, c);
}
// ---------- Display depth image
// use the actual max value in the image to maximize its appearance
int maxValue = ImageStatistics.max(depth);
BufferedImage depthOut = VisualizeImageData.disparity(depth, null, 0, maxValue, 0);
ShowImages.showWindow(depthOut, "Depth Image");
// ---------- Display colorized point cloud
ShowImages.showWindow(viewer, "Point Cloud");
System.out.println("Total points = " + cloud.size);
}
Aggregations