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());
}
Aggregations