Search in sources :

Example 6 with Freenect2

use of org.bytedeco.javacpp.freenect2.Freenect2 in project javacv by bytedeco.

the class OpenKinect2FrameGrabber method start.

@Override
public void start() throws FrameGrabber.Exception {
    if (freenect2Context == null) {
        try {
            OpenKinect2FrameGrabber.tryLoad();
        } catch (Exception e) {
            System.out.println("Exception in the TryLoad !" + e);
            e.printStackTrace();
        }
    }
    if (freenect2Context == null) {
        throw new Exception("FATAL error: OpenKinect2 camera: driver could not load.");
    }
    if (freenect2Context.enumerateDevices() == 0) {
        throw new Exception("FATAL error: OpenKinect2: no device connected!");
    }
    device = null;
    PacketPipeline pipeline = null;
    pipeline = new CpuPacketPipeline();
    // pipeline = new libfreenect2::OpenGLPacketPipeline();
    // pipeline = new libfreenect2::OpenCLPacketPipeline(deviceId);
    // pipeline = new libfreenect2::CudaPacketPipeline(deviceId);
    serial = freenect2Context.getDeviceSerialNumber(deviceNumber).getString();
    device = freenect2Context.openDevice(serial, pipeline);
    frameListener = new freenect2.SyncMultiFrameListener(frameTypes);
    if (colorEnabled) {
        device.setColorFrameListener(frameListener);
    }
    if (depthEnabled || IREnabled) {
        device.setIrAndDepthFrameListener(frameListener);
    }
    rawVideoImage = IplImage.createHeader(1920, 1080, IPL_DEPTH_8U, 4);
    device.start();
    System.out.println("OpenKinect2 device started.");
    System.out.println("Serial: " + device.getSerialNumber().getString());
    System.out.println("Firmware: " + device.getFirmwareVersion().getString());
}
Also used : SyncMultiFrameListener(org.bytedeco.javacpp.freenect2.SyncMultiFrameListener) CpuPacketPipeline(org.bytedeco.javacpp.freenect2.CpuPacketPipeline) org.bytedeco.javacpp.freenect2(org.bytedeco.javacpp.freenect2) PacketPipeline(org.bytedeco.javacpp.freenect2.PacketPipeline) CpuPacketPipeline(org.bytedeco.javacpp.freenect2.CpuPacketPipeline)

Aggregations

org.bytedeco.javacpp.freenect2 (org.bytedeco.javacpp.freenect2)5 BytePointer (org.bytedeco.javacpp.BytePointer)3 Pointer (org.bytedeco.javacpp.Pointer)2 CpuPacketPipeline (org.bytedeco.javacpp.freenect2.CpuPacketPipeline)2 Freenect2 (org.bytedeco.javacpp.freenect2.Freenect2)2 PacketPipeline (org.bytedeco.javacpp.freenect2.PacketPipeline)2 SyncMultiFrameListener (org.bytedeco.javacpp.freenect2.SyncMultiFrameListener)2 FrameMap (org.bytedeco.javacpp.freenect2.FrameMap)1 Freenect2Device (org.bytedeco.javacpp.freenect2.Freenect2Device)1