Search in sources :

Example 16 with FastQueue

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

the class CompareConvertedDescriptionsApp method describeImage.

public static <TD extends TupleDesc> FastQueue<TD> describeImage(GrayF32 input, InterestPointDetector<GrayF32> detector, DescribeRegionPoint<GrayF32, TD> describe, List<Point2D_F64> location) {
    FastQueue<TD> list = new FastQueue<>(100, describe.getDescriptionType(), false);
    System.out.println("Detecting");
    detector.detect(input);
    System.out.println("Describing");
    describe.setImage(input);
    for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
        Point2D_F64 p = detector.getLocation(i);
        double radius = detector.getRadius(i);
        double ori = detector.getOrientation(i);
        TD d = describe.createDescription();
        if (describe.process(p.x, p.y, ori, radius, d)) {
            list.add(d);
            location.add(p.copy());
        }
    }
    return list;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) FastQueue(org.ddogleg.struct.FastQueue) FactoryDescribeRegionPoint(boofcv.factory.feature.describe.FactoryDescribeRegionPoint) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) FactoryInterestPoint(boofcv.factory.feature.detect.interest.FactoryInterestPoint)

Example 17 with FastQueue

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

the class ExampleMultiviewSceneReconstruction method detectImageFeatures.

/**
 * Detect image features in all the images.  Save location, description, and color
 */
private void detectImageFeatures(List<BufferedImage> colorImages) {
    System.out.println("Detecting Features in each image.  Total " + colorImages.size());
    for (int i = 0; i < colorImages.size(); i++) {
        System.out.print("*");
        BufferedImage colorImage = colorImages.get(i);
        FastQueue<BrightFeature> features = new SurfFeatureQueue(64);
        FastQueue<Point2D_F64> pixels = new FastQueue<>(Point2D_F64.class, true);
        GrowQueue_I32 colors = new GrowQueue_I32();
        detectFeatures(colorImage, features, pixels, colors);
        imageVisualFeatures.add(features);
        imagePixels.add(pixels);
        imageColors.add(colors);
    }
    System.out.println();
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) SurfFeatureQueue(boofcv.struct.feature.SurfFeatureQueue) Point2D_F64(georegression.struct.point.Point2D_F64) FastQueue(org.ddogleg.struct.FastQueue) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 18 with FastQueue

use of org.ddogleg.struct.FastQueue 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);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) DataOutputStream(java.io.DataOutputStream) FastQueueArray_I32(boofcv.struct.FastQueueArray_I32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) FileOutputStream(java.io.FileOutputStream) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8)

Example 19 with FastQueue

use of org.ddogleg.struct.FastQueue 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);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) DMatrixRMaj(org.ejml.data.DMatrixRMaj) FastQueueArray_I32(boofcv.struct.FastQueueArray_I32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) PointCloudViewer(boofcv.gui.d3.PointCloudViewer) GrayU8(boofcv.struct.image.GrayU8) File(java.io.File)

Example 20 with FastQueue

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

the class TestBinaryEllipseDetectorPixel method undistortContour.

/**
 * Undistort the image when no distoriton is provided
 */
@Test
public void undistortContour() {
    List<Point2D_I32> input = new ArrayList<>();
    FastQueue<Point2D_F64> output = new FastQueue<>(Point2D_F64.class, true);
    for (int i = 0; i < 10; i++) {
        input.add(new Point2D_I32(i, i));
    }
    BinaryEllipseDetectorPixel alg = new BinaryEllipseDetectorPixel();
    alg.undistortContour(input, output);
    assertEquals(input.size(), output.size);
    for (int i = 0; i < input.size(); i++) {
        Point2D_I32 p = input.get(i);
        assertEquals(p.x, output.get(i).x, 1e-8);
        assertEquals(p.y, output.get(i).y, 1e-8);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) FastQueue(org.ddogleg.struct.FastQueue) ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Aggregations

FastQueue (org.ddogleg.struct.FastQueue)27 Test (org.junit.Test)17 Point3D_F64 (georegression.struct.point.Point3D_F64)9 GrayU16 (boofcv.struct.image.GrayU16)5 GrayU8 (boofcv.struct.image.GrayU8)5 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 FastQueueArray_I32 (boofcv.struct.FastQueueArray_I32)4 Point2D_F64 (georegression.struct.point.Point2D_F64)4 Point2D_I32 (georegression.struct.point.Point2D_I32)4 BufferedImage (java.awt.image.BufferedImage)4 ArrayList (java.util.ArrayList)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 BrightFeature (boofcv.struct.feature.BrightFeature)3 GrayS32 (boofcv.struct.image.GrayS32)3 File (java.io.File)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 Edge (boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge)2 PointCloudViewer (boofcv.gui.d3.PointCloudViewer)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2