+
+/** \defgroup device Initialization and Device Control
+ * Find, open, and control Kinect v2 devices. */
+/**\{
+
+/** Device control. */
+@Namespace("libfreenect2") public static class Freenect2Device extends Pointer {
+ static { Loader.load(); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public Freenect2Device(Pointer p) { super(p); }
+
+ @MemberGetter public static native @Cast("const unsigned int") int VendorId();
+ public static final int VendorId = VendorId();
+ @MemberGetter public static native @Cast("const unsigned int") int ProductId();
+ public static final int ProductId = ProductId();
+ @MemberGetter public static native @Cast("const unsigned int") int ProductIdPreview();
+ public static final int ProductIdPreview = ProductIdPreview();
+
+ /** Color camera calibration parameters.
+ * Kinect v2 includes factory preset values for these parameters. They are used in Registration.
+ */
+ public static class ColorCameraParams extends Pointer {
+ static { Loader.load(); }
+ /** Default native constructor. */
+ public ColorCameraParams() { super((Pointer)null); allocate(); }
+ /** Native array allocator. Access with {@link Pointer#position(long)}. */
+ public ColorCameraParams(long size) { super((Pointer)null); allocateArray(size); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public ColorCameraParams(Pointer p) { super(p); }
+ private native void allocate();
+ private native void allocateArray(long size);
+ @Override public ColorCameraParams position(long position) {
+ return (ColorCameraParams)super.position(position);
+ }
+
+ /** \name Intrinsic parameters */
+ /**\{ */
+ /** Focal length x (pixel) */
+ public native float fx(); public native ColorCameraParams fx(float fx);
+ /** Focal length y (pixel) */
+ public native float fy(); public native ColorCameraParams fy(float fy);
+ /** Principal point x (pixel) */
+ public native float cx(); public native ColorCameraParams cx(float cx);
+ /** Principal point y (pixel) */
+ public native float cy(); public native ColorCameraParams cy(float cy);
+ /**\}
+
+ /** \name Extrinsic parameters
+ * These parameters are used in [a formula](https://github.com/OpenKinect/libfreenect2/issues/41#issuecomment-72022111) to map coordinates in the
+ * depth camera to the color camera.
+ *
+ * They cannot be used for matrix transformation.
+ */
+ /**\{ */
+ public native float shift_d(); public native ColorCameraParams shift_d(float shift_d);
+ public native float shift_m(); public native ColorCameraParams shift_m(float shift_m);
+
+ public native float mx_x3y0(); public native ColorCameraParams mx_x3y0(float mx_x3y0); // xxx
+ public native float mx_x0y3(); public native ColorCameraParams mx_x0y3(float mx_x0y3); // yyy
+ public native float mx_x2y1(); public native ColorCameraParams mx_x2y1(float mx_x2y1); // xxy
+ public native float mx_x1y2(); public native ColorCameraParams mx_x1y2(float mx_x1y2); // yyx
+ public native float mx_x2y0(); public native ColorCameraParams mx_x2y0(float mx_x2y0); // xx
+ public native float mx_x0y2(); public native ColorCameraParams mx_x0y2(float mx_x0y2); // yy
+ public native float mx_x1y1(); public native ColorCameraParams mx_x1y1(float mx_x1y1); // xy
+ public native float mx_x1y0(); public native ColorCameraParams mx_x1y0(float mx_x1y0); // x
+ public native float mx_x0y1(); public native ColorCameraParams mx_x0y1(float mx_x0y1); // y
+ public native float mx_x0y0(); public native ColorCameraParams mx_x0y0(float mx_x0y0); // 1
+
+ public native float my_x3y0(); public native ColorCameraParams my_x3y0(float my_x3y0); // xxx
+ public native float my_x0y3(); public native ColorCameraParams my_x0y3(float my_x0y3); // yyy
+ public native float my_x2y1(); public native ColorCameraParams my_x2y1(float my_x2y1); // xxy
+ public native float my_x1y2(); public native ColorCameraParams my_x1y2(float my_x1y2); // yyx
+ public native float my_x2y0(); public native ColorCameraParams my_x2y0(float my_x2y0); // xx
+ public native float my_x0y2(); public native ColorCameraParams my_x0y2(float my_x0y2); // yy
+ public native float my_x1y1(); public native ColorCameraParams my_x1y1(float my_x1y1); // xy
+ public native float my_x1y0(); public native ColorCameraParams my_x1y0(float my_x1y0); // x
+ public native float my_x0y1(); public native ColorCameraParams my_x0y1(float my_x0y1); // y
+ public native float my_x0y0(); public native ColorCameraParams my_x0y0(float my_x0y0); // 1
+ /**\} */
+ }
+
+ /** IR camera intrinsic calibration parameters.
+ * Kinect v2 includes factory preset values for these parameters. They are used in depth image decoding, and Registration.
+ */
+ public static class IrCameraParams extends Pointer {
+ static { Loader.load(); }
+ /** Default native constructor. */
+ public IrCameraParams() { super((Pointer)null); allocate(); }
+ /** Native array allocator. Access with {@link Pointer#position(long)}. */
+ public IrCameraParams(long size) { super((Pointer)null); allocateArray(size); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public IrCameraParams(Pointer p) { super(p); }
+ private native void allocate();
+ private native void allocateArray(long size);
+ @Override public IrCameraParams position(long position) {
+ return (IrCameraParams)super.position(position);
+ }
+
+ /** Focal length x (pixel) */
+ public native float fx(); public native IrCameraParams fx(float fx);
+ /** Focal length y (pixel) */
+ public native float fy(); public native IrCameraParams fy(float fy);
+ /** Principal point x (pixel) */
+ public native float cx(); public native IrCameraParams cx(float cx);
+ /** Principal point y (pixel) */
+ public native float cy(); public native IrCameraParams cy(float cy);
+ /** Radial distortion coefficient, 1st-order */
+ public native float k1(); public native IrCameraParams k1(float k1);
+ /** Radial distortion coefficient, 2nd-order */
+ public native float k2(); public native IrCameraParams k2(float k2);
+ /** Radial distortion coefficient, 3rd-order */
+ public native float k3(); public native IrCameraParams k3(float k3);
+ /** Tangential distortion coefficient */
+ public native float p1(); public native IrCameraParams p1(float p1);
+ /** Tangential distortion coefficient */
+ public native float p2(); public native IrCameraParams p2(float p2);
+ }
+
+ /** Configuration of depth processing. */
+ public static class Config extends Pointer {
+ static { Loader.load(); }
+ /** Default native constructor. */
+ public Config() { super((Pointer)null); allocate(); }
+ /** Native array allocator. Access with {@link Pointer#position(long)}. */
+ public Config(long size) { super((Pointer)null); allocateArray(size); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public Config(Pointer p) { super(p); }
+ private native void allocate();
+ private native void allocateArray(long size);
+ @Override public Config position(long position) {
+ return (Config)super.position(position);
+ }
+
+ /** Clip at this minimum distance (meter). */
+ public native float MinDepth(); public native Config MinDepth(float MinDepth);
+ /** Clip at this maximum distance (meter). */
+ public native float MaxDepth(); public native Config MaxDepth(float MaxDepth);
+
+ /** Remove some "flying pixels". */
+ public native @Cast("bool") boolean EnableBilateralFilter(); public native Config EnableBilateralFilter(boolean EnableBilateralFilter);
+ /** Remove pixels on edges because ToF cameras produce noisy edges. */
+ public native @Cast("bool") boolean EnableEdgeAwareFilter(); public native Config EnableEdgeAwareFilter(boolean EnableEdgeAwareFilter);
+
+ /** Default is 0.5, 4.5, true, true */
+ }
+
+ public native @StdString BytePointer getSerialNumber();
+ public native @StdString BytePointer getFirmwareVersion();
+
+ /** Get current color parameters.
+ * \copydetails ColorCameraParams
+ */
+ public native @ByVal ColorCameraParams getColorCameraParams();
+
+ /** Get current depth parameters.
+ * \copydetails IrCameraParams
+ */
+ public native @ByVal IrCameraParams getIrCameraParams();
+
+ /** Replace factory preset color camera parameters.
+ * We do not have a clear understanding of the meaning of the parameters right now.
+ * You probably want to leave it as it is.
+ */
+ public native void setColorCameraParams(@Const @ByRef ColorCameraParams params);
+
+ /** Replace factory preset depth camera parameters.
+ * This decides accuracy in depth images. You are recommended to provide calibrated values.
+ */
+ public native void setIrCameraParams(@Const @ByRef IrCameraParams params);
+
+ /** Configure depth processing. */
+ public native void setConfiguration(@Const @ByRef Config config);
+
+ /** Provide your listener to receive color frames. */
+ public native void setColorFrameListener(FrameListener rgb_frame_listener);
+
+ /** Provide your listener to receive IR and depth frames. */
+ public native void setIrAndDepthFrameListener(FrameListener ir_frame_listener);
+
+ /** Start data processing with both RGB and depth streams.
+ * All above configuration must only be called before start() or after stop().
+ *
+ * FrameListener will receive frames when the device is running.
+ *
+ * @return true if ok, false if error.
+ */
+ public native @Cast("bool") boolean start();
+
+ /** Start data processing with or without some streams.
+ * FrameListener will receive enabled frames when the device is running.
+ *
+ * @param rgb Whether to enable RGB stream.
+ * @param depth Whether to enable depth stream.
+ * @return true if ok, false if error.
+ */
+ public native @Cast("bool") boolean startStreams(@Cast("bool") boolean rgb, @Cast("bool") boolean depth);
+
+ /** Stop data processing.
+ *
+ * @return true if ok, false if error.
+ */
+ public native @Cast("bool") boolean stop();
+
+ /** Shut down the device.
+ *
+ * @return true if ok, false if error.
+ */
+ public native @Cast("bool") @Name("close") boolean _close();
+}
+
+@Namespace("libfreenect2") @Opaque public static class Freenect2Impl extends Pointer {
+ /** Empty constructor. Calls {@code super((Pointer)null)}. */
+ public Freenect2Impl() { super((Pointer)null); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public Freenect2Impl(Pointer p) { super(p); }
+}
+
+/**
+ * Library context to find and open devices.
+ *
+ * You will first find existing devices by calling enumerateDevices().
+ *
+ * Then you can openDevice() and control the devices with returned Freenect2Device object.
+ *
+ * You may open devices with custom PacketPipeline.
+ * After passing a PacketPipeline object to libfreenect2 do not use or free the object,
+ * libfreenect2 will take care. If openDevice() fails the PacketPipeline object will get
+ * deleted. A new PacketPipeline object has to be created each time a device is opened.
+ */
+@Namespace("libfreenect2") @NoOffset public static class Freenect2 extends Pointer {
+ static { Loader.load(); }
+ /** Native array allocator. Access with {@link Pointer#position(long)}. */
+ public Freenect2(long size) { super((Pointer)null); allocateArray(size); }
+ private native void allocateArray(long size);
+ @Override public Freenect2 position(long position) {
+ return (Freenect2)super.position(position);
+ }
+
+ /**
+ * @param usb_context If the libusb context is provided,
+ * Freenect2 will use it instead of creating one.
+ */
+ public Freenect2(Pointer usb_context/*=0*/) { super((Pointer)null); allocate(usb_context); }
+ private native void allocate(Pointer usb_context/*=0*/);
+ public Freenect2() { super((Pointer)null); allocate(); }
+ private native void allocate();
+
+ /** Must be called before doing anything else.
+ * @return Number of devices, 0 if none
+ */
+ public native int enumerateDevices();
+
+ /**
+ * @param idx Device index
+ * @return Device serial number, or empty if the index is invalid.
+ */
+ public native @StdString BytePointer getDeviceSerialNumber(int idx);
+
+ /**
+ * @return Device serial number, or empty if no device exists.
+ */
+ public native @StdString BytePointer getDefaultDeviceSerialNumber();
+
+ /** Open device by index with default pipeline.
+ * @param idx Index number. Index numbers are not determinstic during enumeration.
+ * @return New device object, or NULL on failure
+ */
+ public native Freenect2Device openDevice(int idx);
+
+ /** Open device by index.
+ * @param idx Index number. Index numbers are not determinstic during enumeration.
+ * @param factory New PacketPipeline instance. This is always automatically freed.
+ * @return New device object, or NULL on failure
+ */
+ public native Freenect2Device openDevice(int idx, @Const PacketPipeline factory);
+
+ /** Open device by serial number with default pipeline.
+ * @param serial Serial number
+ * @return New device object, or NULL on failure
+ */
+ public native Freenect2Device openDevice(@StdString BytePointer serial);
+ public native Freenect2Device openDevice(@StdString String serial);
+
+ /** Open device by serial number.
+ * @param serial Serial number
+ * @param factory New PacketPipeline instance. This is always automatically freed.
+ * @return New device object, or NULL on failure
+ */
+ public native Freenect2Device openDevice(@StdString BytePointer serial, @Const PacketPipeline factory);
+ public native Freenect2Device openDevice(@StdString String serial, @Const PacketPipeline factory);
+
+ /** Open the first device with default pipeline.
+ * @return New device object, or NULL on failure
+ */
+ public native Freenect2Device openDefaultDevice();
+
+ /** Open the first device.
+ * @param factory New PacketPipeline instance. This is always automatically freed.
+ * @return New device object, or NULL on failure
+ */
+ public native Freenect2Device openDefaultDevice(@Const PacketPipeline factory);
+}
+
+/**\} */
+ /* namespace libfreenect2 */
+// #endif /* LIBFREENECT2_HPP_ */
+
+
+// Parsed from
+
+/*
+ * This file is part of the OpenKinect Project. http://www.openkinect.org
+ *
+ * Copyright (c) 2014 individual OpenKinect contributors. See the CONTRIB file
+ * for details.
+ *
+ * This code is licensed to you under the terms of the Apache License, version
+ * 2.0, or, at your option, the terms of the GNU General Public License,
+ * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
+ * or the following URLs:
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.gnu.org/licenses/gpl-2.0.txt
+ *
+ * If you redistribute this file in source form, modified or unmodified, you
+ * may:
+ * 1) Leave this header intact and distribute it under the same terms,
+ * accompanying it with the APACHE20 and GPL20 files, or
+ * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
+ * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
+ * In all cases you must keep the copyright notice intact and include a copy
+ * of the CONTRIB file.
+ *
+ * Binary distributions must follow the binary distribution requirements of
+ * either License.
+ */
+
+/** \file frame_listener.hpp Classes for frame listeners. */
+
+// #ifndef FRAME_LISTENER_HPP_
+// #define FRAME_LISTENER_HPP_
+
+// #include
+// #include
+// #include
+
+/** \defgroup frame Frame Listeners
+ * Receive decoded image frames, and the frame format.
+ */
+
+/** Frame format and metadata. \ingroup frame */
+@Namespace("libfreenect2") @NoOffset public static class Frame extends Pointer {
+ static { Loader.load(); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public Frame(Pointer p) { super(p); }
+
+ /** Available types of frames. */
+ /** enum libfreenect2::Frame::Type */
+ public static final int
+ /** 1920x1080. BGRX or RGBX. */
+ Color = 1,
+ /** 512x424 float. Range is [0.0, 65535.0]. */
+ Ir = 2,
+ /** 512x424 float, unit: millimeter. Non-positive, NaN, and infinity are invalid or missing data. */
+ Depth = 4;
+
+ /** Pixel format. */
+ /** enum libfreenect2::Frame::Format */
+ public static final int
+ /** Invalid format. */
+ Invalid = 0,
+ /** Raw bitstream. 'bytes_per_pixel' defines the number of bytes */
+ Raw = 1,
+ /** A 4-byte float per pixel */
+ Float = 2,
+ /** 4 bytes of B, G, R, and unused per pixel */
+ BGRX = 4,
+ /** 4 bytes of R, G, B, and unused per pixel */
+ RGBX = 5,
+ /** 1 byte of gray per pixel */
+ Gray = 6;
+
+ /** Length of a line (in pixels). */
+ public native @Cast("size_t") long width(); public native Frame width(long width);
+ /** Number of lines in the frame. */
+ public native @Cast("size_t") long height(); public native Frame height(long height);
+ /** Number of bytes in a pixel. If frame format is 'Raw' this is the buffer size. */
+ public native @Cast("size_t") long bytes_per_pixel(); public native Frame bytes_per_pixel(long bytes_per_pixel);
+ /** Data of the frame (aligned). @see See Frame::Type for pixel format. */
+ public native @Cast("unsigned char*") BytePointer data(); public native Frame data(BytePointer data);
+ /** Unit: roughly or exactly 0.1 millisecond */
+ public native @Cast("uint32_t") int timestamp(); public native Frame timestamp(int timestamp);
+ /** Increasing frame sequence number */
+ public native @Cast("uint32_t") int sequence(); public native Frame sequence(int sequence);
+ /** From 0.5 (very bright) to ~60.0 (fully covered) */
+ public native float exposure(); public native Frame exposure(float exposure);
+ /** From 1.0 (bright) to 1.5 (covered) */
+ public native float gain(); public native Frame gain(float gain);
+ /** From 1.0 (bright) to 6.4 (covered) */
+ public native float gamma(); public native Frame gamma(float gamma);
+ /** zero if ok; non-zero for errors. */
+ public native @Cast("uint32_t") int status(); public native Frame status(int status);
+ /** Byte format. Informative only, doesn't indicate errors. */
+ public native @Cast("libfreenect2::Frame::Format") int format(); public native Frame format(int format);
+
+ /** Construct a new frame.
+ * @param width Width in pixel
+ * @param height Height in pixel
+ * @param bytes_per_pixel Bytes per pixel
+ * @param data_ Memory to store frame data. If {@code NULL}, new memory is allocated.
+ */
+ public Frame(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel, @Cast("unsigned char*") BytePointer data_/*=NULL*/) { super((Pointer)null); allocate(width, height, bytes_per_pixel, data_); }
+ private native void allocate(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel, @Cast("unsigned char*") BytePointer data_/*=NULL*/);
+ public Frame(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel) { super((Pointer)null); allocate(width, height, bytes_per_pixel); }
+ private native void allocate(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel);
+ public Frame(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel, @Cast("unsigned char*") ByteBuffer data_/*=NULL*/) { super((Pointer)null); allocate(width, height, bytes_per_pixel, data_); }
+ private native void allocate(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel, @Cast("unsigned char*") ByteBuffer data_/*=NULL*/);
+ public Frame(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel, @Cast("unsigned char*") byte[] data_/*=NULL*/) { super((Pointer)null); allocate(width, height, bytes_per_pixel, data_); }
+ private native void allocate(@Cast("size_t") long width, @Cast("size_t") long height, @Cast("size_t") long bytes_per_pixel, @Cast("unsigned char*") byte[] data_/*=NULL*/);
+}
+
+/** Callback interface to receive new frames. \ingroup frame
+ * You can inherit from FrameListener and define your own listener.
+ */
+@Namespace("libfreenect2") public static class FrameListener extends Pointer {
+ static { Loader.load(); }
+ /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
+ public FrameListener(Pointer p) { super(p); }
+
+
+ /**
+ * libfreenect2 calls this function when a new frame is decoded.
+ * @param type Type of the new frame.
+ * @param frame Data of the frame.
+ * @return true if you want to take ownership of the frame, i.e. reuse/delete it. Will be reused/deleted by caller otherwise.
+ */
+ public native @Cast("bool") boolean onNewFrame(@Cast("libfreenect2::Frame::Type") int type, Frame frame);
+}
+
+ /* namespace libfreenect2 */
+// #endif /* FRAME_LISTENER_HPP_ */
+
+
+// Parsed from
+
+/*
+ * This file is part of the OpenKinect Project. http://www.openkinect.org
+ *
+ * Copyright (c) 2014 individual OpenKinect contributors. See the CONTRIB file
+ * for details.
+ *
+ * This code is licensed to you under the terms of the Apache License, version
+ * 2.0, or, at your option, the terms of the GNU General Public License,
+ * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
+ * or the following URLs:
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.gnu.org/licenses/gpl-2.0.txt
+ *
+ * If you redistribute this file in source form, modified or unmodified, you
+ * may:
+ * 1) Leave this header intact and distribute it under the same terms,
+ * accompanying it with the APACHE20 and GPL20 files, or
+ * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
+ * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
+ * In all cases you must keep the copyright notice intact and include a copy
+ * of the CONTRIB file.
+ *
+ * Binary distributions must follow the binary distribution requirements of
+ * either License.
+ */
+
+/** \file frame_listener_impl.h Implementation of the frame listener classes. */
+
+// #ifndef FRAME_LISTENER_IMPL_H_
+// #define FRAME_LISTENER_IMPL_H_
+
+// #include