Search in sources :

Example 1 with Context

use of org.openkinect.freenect.Context in project BoofCV by lessthanoptimal.

the class LogKinectDataApp method process.

public void process() throws IOException {
    logFile = new DataOutputStream(new FileOutputStream("log/timestamps.txt"));
    logFile.write("# Time stamps for rgb and depth cameras.\n".getBytes());
    int w = UtilOpenKinect.getWidth(resolution);
    int h = UtilOpenKinect.getHeight(resolution);
    buffRgb = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    if (showImage) {
        gui = ShowImages.showWindow(buffRgb, "Kinect RGB");
    }
    StreamOpenKinectRgbDepth stream = new StreamOpenKinectRgbDepth();
    Context kinect = Freenect.createContext();
    if (kinect.numDevices() < 0)
        throw new RuntimeException("No kinect found!");
    Device device = kinect.openDevice(0);
    stream.start(device, resolution, this);
    if (maxImages > 0) {
        while (frameNumber < maxImages) {
            System.out.printf("Total saved %d\n", frameNumber);
            BoofMiscOps.pause(100);
        }
        stream.stop();
        System.out.println("Exceeded max images");
        System.exit(0);
    }
}
Also used : Context(org.openkinect.freenect.Context) StreamOpenKinectRgbDepth(boofcv.openkinect.StreamOpenKinectRgbDepth) DataOutputStream(java.io.DataOutputStream) Device(org.openkinect.freenect.Device) FileOutputStream(java.io.FileOutputStream) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 2 with Context

use of org.openkinect.freenect.Context in project BoofCV by lessthanoptimal.

the class OverlayRgbDepthStreamsApp method process.

public void process() {
    int w = UtilOpenKinect.getWidth(resolution);
    int h = UtilOpenKinect.getHeight(resolution);
    buffRgb = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    buffDepth = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    gui = ShowImages.showWindow(buffRgb, "Kinect Overlay");
    StreamOpenKinectRgbDepth stream = new StreamOpenKinectRgbDepth();
    Context kinect = Freenect.createContext();
    if (kinect.numDevices() < 0)
        throw new RuntimeException("No kinect found!");
    Device device = kinect.openDevice(0);
    stream.start(device, resolution, this);
}
Also used : Context(org.openkinect.freenect.Context) StreamOpenKinectRgbDepth(boofcv.openkinect.StreamOpenKinectRgbDepth) Device(org.openkinect.freenect.Device) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 3 with Context

use of org.openkinect.freenect.Context in project BoofCV by lessthanoptimal.

the class CaptureCalibrationImagesApp method process.

public void process() throws IOException {
    // make sure there is a "log" directory
    new File("log").mkdir();
    int w = UtilOpenKinect.getWidth(resolution);
    int h = UtilOpenKinect.getHeight(resolution);
    buffRgb = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    savedRgb = new Planar<>(GrayU8.class, w, h, 3);
    savedDepth = new GrayU16(w, h);
    gui = ShowImages.showWindow(buffRgb, "Kinect RGB");
    gui.addKeyListener(this);
    gui.requestFocus();
    StreamOpenKinectRgbDepth stream = new StreamOpenKinectRgbDepth();
    Context kinect = Freenect.createContext();
    if (kinect.numDevices() < 0)
        throw new RuntimeException("No kinect found!");
    Device device = kinect.openDevice(0);
    stream.start(device, resolution, this);
    long targetTime = System.currentTimeMillis() + period;
    updateDisplay = true;
    while (true) {
        BoofMiscOps.pause(100);
        if (targetTime < System.currentTimeMillis()) {
            userChoice = -1;
            savedImages = false;
            updateDisplay = false;
            while (true) {
                if (savedImages && userChoice != -1) {
                    if (userChoice == 1) {
                        UtilImageIO.savePPM(savedRgb, String.format(directory + "rgb%07d.ppm", frameNumber), buffer);
                        UtilOpenKinect.saveDepth(savedDepth, String.format(directory + "depth%07d.depth", frameNumber), buffer);
                        frameNumber++;
                        text = "Image Saved!";
                    } else {
                        text = "Image Discarded!";
                    }
                    timeText = System.currentTimeMillis() + 500;
                    updateDisplay = true;
                    targetTime = System.currentTimeMillis() + period;
                    break;
                }
                BoofMiscOps.pause(50);
            }
        }
    }
}
Also used : Context(org.openkinect.freenect.Context) StreamOpenKinectRgbDepth(boofcv.openkinect.StreamOpenKinectRgbDepth) GrayU16(boofcv.struct.image.GrayU16) Device(org.openkinect.freenect.Device) GrayU8(boofcv.struct.image.GrayU8) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Aggregations

ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 StreamOpenKinectRgbDepth (boofcv.openkinect.StreamOpenKinectRgbDepth)3 BufferedImage (java.awt.image.BufferedImage)3 Context (org.openkinect.freenect.Context)3 Device (org.openkinect.freenect.Device)3 GrayU16 (boofcv.struct.image.GrayU16)1 GrayU8 (boofcv.struct.image.GrayU8)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1