CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-bytedeco--libfreenect2

JavaCPP Presets for libfreenect2 providing Java bindings for Kinect for Windows v2 device drivers

Pending
Overview
Eval results
Files

device-management.mddocs/

Device Management

Core device discovery, initialization, and control functionality for Microsoft Kinect for Windows v2 devices. This module handles device enumeration, opening connections, configuration, and stream control.

Capabilities

Freenect2 Context

Library context for finding and opening Kinect v2 devices. This is the main entry point for device operations.

/**
 * Library context to find and open devices.
 * You will first find existing devices by calling enumerateDevices().
 * Then you can openDevice() and control devices with returned Freenect2Device object.
 */
class Freenect2 {
    /** Constructor using default USB context */
    Freenect2();
    
    /** Constructor with custom USB context */
    Freenect2(Pointer usb_context);
    
    /** Find available devices - must be called before opening devices */
    int enumerateDevices();
    
    /** Get device serial number by index */
    @StdString BytePointer getDeviceSerialNumber(int idx);
    
    /** Get default device serial number */
    @StdString BytePointer getDefaultDeviceSerialNumber();
    
    /** Open device by index with default pipeline */
    Freenect2Device openDevice(int idx);
    
    /** Open device by index with custom pipeline */
    Freenect2Device openDevice(int idx, @Const PacketPipeline factory);
    
    /** Open device by serial number with default pipeline */
    Freenect2Device openDevice(@StdString String serial);
    
    /** Open device by serial number with custom pipeline */
    Freenect2Device openDevice(@StdString String serial, @Const PacketPipeline factory);
    
    /** Open first available device with default pipeline */
    Freenect2Device openDefaultDevice();
    
    /** Open first available device with custom pipeline */
    Freenect2Device openDefaultDevice(@Const PacketPipeline factory);
}

Usage Examples:

import org.bytedeco.libfreenect2.*;
import static org.bytedeco.libfreenect2.global.freenect2.*;

// Initialize library
Loader.load(org.bytedeco.libfreenect2.global.freenect2.class);
Freenect2 freenect2 = new Freenect2();

// Find devices
int deviceCount = freenect2.enumerateDevices();
System.out.println("Found " + deviceCount + " devices");

// Open default device with CPU pipeline
PacketPipeline pipeline = new CpuPacketPipeline();
Freenect2Device device = freenect2.openDefaultDevice(pipeline);

// Or open specific device by serial
String serial = freenect2.getDefaultDeviceSerialNumber().getString();
device = freenect2.openDevice(serial, pipeline);

Freenect2Device Control

Device control interface providing configuration and stream management for individual Kinect v2 devices.

/**
 * Device control for Kinect v2 devices
 */
class Freenect2Device {
    /** Device vendor ID constant */
    static final int VendorId;
    
    /** Device product ID constant */
    static final int ProductId;
    
    /** Preview device product ID constant */
    static final int ProductIdPreview;
    
    /** Get device serial number */
    @StdString BytePointer getSerialNumber();
    
    /** Get device firmware version */
    @StdString BytePointer getFirmwareVersion();
    
    /** Get current color camera parameters */
    @ByVal ColorCameraParams getColorCameraParams();
    
    /** Get current IR camera parameters */
    @ByVal IrCameraParams getIrCameraParams();
    
    /** Set color camera parameters (advanced users only) */
    void setColorCameraParams(@Const @ByRef ColorCameraParams params);
    
    /** Set IR camera parameters for calibrated accuracy */
    void setIrCameraParams(@Const @ByRef IrCameraParams params);
    
    /** Configure depth processing parameters */
    void setConfiguration(@Const @ByRef Config config);
    
    /** Set listener for color frames */
    void setColorFrameListener(FrameListener rgb_frame_listener);
    
    /** Set listener for IR and depth frames */
    void setIrAndDepthFrameListener(FrameListener ir_frame_listener);
    
    /** Start data processing with both RGB and depth streams */
    @Cast("bool") boolean start();
    
    /** Start data processing with selected streams */
    @Cast("bool") boolean startStreams(@Cast("bool") boolean rgb, @Cast("bool") boolean depth);
    
    /** Stop data processing */
    @Cast("bool") boolean stop();
    
    /** Shut down device */
    @Cast("bool") @Name("close") boolean _close();
}

Usage Examples:

// Device information
System.out.println("Serial: " + device.getSerialNumber().getString());
System.out.println("Firmware: " + device.getFirmwareVersion().getString());

// Configure depth processing
Freenect2Device.Config config = new Freenect2Device.Config();
config.MinDepth(0.5f);  // 0.5 meters minimum
config.MaxDepth(4.5f);  // 4.5 meters maximum
config.EnableBilateralFilter(true);
config.EnableEdgeAwareFilter(true);
device.setConfiguration(config);

// Start specific streams
boolean success = device.startStreams(true, true); // RGB + depth
if (!success) {
    System.err.println("Failed to start streams");
}

Device Configuration

Configuration classes for depth processing and camera calibration parameters.

/**
 * Configuration of depth processing
 */
class Freenect2Device.Config {
    /** Clip at this minimum distance (meter) */
    float MinDepth();
    Config MinDepth(float setter);
    
    /** Clip at this maximum distance (meter) */
    float MaxDepth(); 
    Config MaxDepth(float setter);
    
    /** Remove some "flying pixels" */
    @Cast("bool") boolean EnableBilateralFilter();
    Config EnableBilateralFilter(@Cast("bool") boolean setter);
    
    /** Remove pixels on edges because ToF cameras produce noisy edges */
    @Cast("bool") boolean EnableEdgeAwareFilter();
    Config EnableEdgeAwareFilter(@Cast("bool") boolean setter);
}

Color Camera Parameters

Color camera calibration parameters with intrinsic and extrinsic values.

/**
 * Color camera calibration parameters.
 * Kinect v2 includes factory preset values for these parameters.
 * They are used in Registration.
 */
class Freenect2Device.ColorCameraParams {
    // Intrinsic parameters
    /** Focal length x (pixel) */
    float fx(); ColorCameraParams fx(float setter);
    /** Focal length y (pixel) */
    float fy(); ColorCameraParams fy(float setter);
    /** Principal point x (pixel) */
    float cx(); ColorCameraParams cx(float setter);
    /** Principal point y (pixel) */
    float cy(); ColorCameraParams cy(float setter);
    
    // Extrinsic parameters for depth-to-color mapping
    float shift_d(); ColorCameraParams shift_d(float setter);
    float shift_m(); ColorCameraParams shift_m(float setter);
    
    // Distortion coefficients
    float mx_x3y0(); ColorCameraParams mx_x3y0(float setter);
    float mx_x0y3(); ColorCameraParams mx_x0y3(float setter);
    float mx_x2y1(); ColorCameraParams mx_x2y1(float setter);
    float mx_x1y2(); ColorCameraParams mx_x1y2(float setter);
    float mx_x2y0(); ColorCameraParams mx_x2y0(float setter);
    float mx_x0y2(); ColorCameraParams mx_x0y2(float setter);
    float mx_x1y1(); ColorCameraParams mx_x1y1(float setter);
    float mx_x1y0(); ColorCameraParams mx_x1y0(float setter);
    float mx_x0y1(); ColorCameraParams mx_x0y1(float setter);
    float mx_x0y0(); ColorCameraParams mx_x0y0(float setter);
    
    // Y-axis distortion coefficients
    float my_x3y0(); ColorCameraParams my_x3y0(float setter);
    float my_x0y3(); ColorCameraParams my_x0y3(float setter);
    float my_x2y1(); ColorCameraParams my_x2y1(float setter);
    float my_x1y2(); ColorCameraParams my_x1y2(float setter);
    float my_x2y0(); ColorCameraParams my_x2y0(float setter);
    float my_x0y2(); ColorCameraParams my_x0y2(float setter);
    float my_x1y1(); ColorCameraParams my_x1y1(float setter);
    float my_x1y0(); ColorCameraParams my_x1y0(float setter);
    float my_x0y1(); ColorCameraParams my_x0y1(float setter);
    float my_x0y0(); ColorCameraParams my_x0y0(float setter);
}

IR Camera Parameters

IR camera intrinsic calibration parameters for depth processing accuracy.

/**
 * IR camera intrinsic calibration parameters.
 * Kinect v2 includes factory preset values for these parameters.
 * They are used in depth image decoding, and Registration.
 */
class Freenect2Device.IrCameraParams {
    /** Focal length x (pixel) */
    float fx(); IrCameraParams fx(float setter);
    /** Focal length y (pixel) */
    float fy(); IrCameraParams fy(float setter);
    /** Principal point x (pixel) */
    float cx(); IrCameraParams cx(float setter);
    /** Principal point y (pixel) */
    float cy(); IrCameraParams cy(float setter);
    /** Radial distortion coefficient, 1st-order */
    float k1(); IrCameraParams k1(float setter);
    /** Radial distortion coefficient, 2nd-order */
    float k2(); IrCameraParams k2(float setter);
    /** Radial distortion coefficient, 3rd-order */
    float k3(); IrCameraParams k3(float setter);
    /** Tangential distortion coefficient */
    float p1(); IrCameraParams p1(float setter);
    /** Tangential distortion coefficient */
    float p2(); IrCameraParams p2(float setter);
}

Usage Examples:

// Get factory calibration parameters
Freenect2Device.IrCameraParams irParams = device.getIrCameraParams();
Freenect2Device.ColorCameraParams colorParams = device.getColorCameraParams();

System.out.println("IR Camera - fx: " + irParams.fx() + ", fy: " + irParams.fy());
System.out.println("Color Camera - fx: " + colorParams.fx() + ", fy: " + colorParams.fy());

// Use custom calibrated parameters (advanced)
irParams.fx(365.456f);
irParams.fy(365.456f);
device.setIrCameraParams(irParams);

Install with Tessl CLI

npx tessl i tessl/maven-org-bytedeco--libfreenect2

docs

device-management.md

frame-processing.md

index.md

logging.md

pipeline-configuration.md

registration-geometry.md

tile.json