ohmm
Class CvKinect

java.lang.Object
  extended by ohmm.CvBase
      extended by ohmm.CvKinect
Direct Known Subclasses:
CvKinectDemo

public class CvKinect
extends CvBase

CvBase extensions for Kinect.

Uses either OpenNI via OpenCV or OpenKinect (libfreenect) via JavaCV OpenKinectFrameGrabber (the default). Depth-to-RGB registration is an option for both (see setDepthRegistration(boolean)). Grabbing both depth and color images simultaneously, tilt sensing/actuation, and LED control are only available with OpenKinect.

Author:
Marsette A. Vona

Field Summary
static java.lang.String DEF_APPNAME
          Default application name.
static java.lang.String DEF_INPUT
          Default input device index (OpenKinectFrameGrabber).
static int MAX_DEPTH_11BIT
          Valid range of 11-bit depth values.
static int MAX_DEPTH_MM
          Valid range of depth values in mm.
static int MIN_DEPTH_11BIT
          Valid range of 11-bit depth values.
static int MIN_DEPTH_MM
          Valid range of depth values in mm.
protected  com.googlecode.javacv.OpenKinectFrameGrabber okGrabber
          OpenKinectFrameGrabber instance, if any.
 
Fields inherited from class ohmm.CvBase
appname, brightness, canvasFrame, canvasFrameKeyEvent, cap, CAP_PROP_NAMES, CAP_PROPS, capImage, dbg, DEF_CAM_H, DEF_CAM_W, DEF_MAX_FPS, DEF_MIN_DELAY_MS, DEF_SERVER_FPS, DEF_SERVER_PORT, DEF_USE_CANVAS_FRAME, DEF_USE_CONSOLE, DEF_USE_SERVER, DEF_USE_WINDOW, enableExit, exposure, FMT, frameEndMS, frameN, gain, grabber, height, hue, maxFPS, minDelayMS, mouseCallback, msgStream, msPerTick, paused, procImage, saturation, saveImage, server, serverFPS, serverImage, serverKey, serverPort, streamIndex, useCanvasFrame, useConsole, useServer, useWindow, V4L2_AUTO_PROP_NAMES, V4L2_AUTO_PROP_OFF_VALS, V4L2_AUTO_PROP_ON_VALS, V4L2_AUTO_PROPS, V4L2_CID_AUDIO_BALANCE, V4L2_CID_AUDIO_BASS, V4L2_CID_AUDIO_LOUDNESS, V4L2_CID_AUDIO_MUTE, V4L2_CID_AUDIO_TREBLE, V4L2_CID_AUDIO_VOLUME, V4L2_CID_AUTO_WHITE_BALANCE, V4L2_CID_AUTOGAIN, V4L2_CID_BACKLIGHT_COMPENSATION, V4L2_CID_BASE, V4L2_CID_BLACK_LEVEL, V4L2_CID_BLUE_BALANCE, V4L2_CID_BRIGHTNESS, V4L2_CID_CAMERA_CLASS, V4L2_CID_CAMERA_CLASS_BASE, V4L2_CID_CONTRAST, V4L2_CID_DO_WHITE_BALANCE, V4L2_CID_EXPOSURE, V4L2_CID_EXPOSURE_ABSOLUTE, V4L2_CID_EXPOSURE_AUTO, V4L2_CID_EXPOSURE_AUTO_PRIORITY, V4L2_CID_FOCUS_ABSOLUTE, V4L2_CID_FOCUS_AUTO, V4L2_CID_FOCUS_RELATIVE, V4L2_CID_GAIN, V4L2_CID_GAMMA, V4L2_CID_HCENTER_DEPRECATED, V4L2_CID_HFLIP, V4L2_CID_HUE, V4L2_CID_HUE_AUTO, V4L2_CID_LASTP1, V4L2_CID_PAN_ABSOLUTE, V4L2_CID_PAN_RELATIVE, V4L2_CID_PAN_RESET, V4L2_CID_POWER_LINE_FREQUENCY, V4L2_CID_POWER_LINE_FREQUENCY_50HZ, V4L2_CID_POWER_LINE_FREQUENCY_60HZ, V4L2_CID_POWER_LINE_FREQUENCY_DISABLED, V4L2_CID_PRIVATE_BASE, V4L2_CID_RED_BALANCE, V4L2_CID_SATURATION, V4L2_CID_SHARPNESS, V4L2_CID_TILT_ABSOLUTE, V4L2_CID_TILT_RELATIVE, V4L2_CID_TILT_RESET, V4L2_CID_USER_BASE, V4L2_CID_USER_CLASS, V4L2_CID_VCENTER_DEPRECATED, V4L2_CID_VFLIP, V4L2_CID_WHITE_BALANCE_TEMPERATURE, V4L2_CID_WHITENESS, V4L2_CTRL_CLASS_CAMERA, V4L2_CTRL_CLASS_MPEG, V4L2_CTRL_CLASS_USER, V4L2_EXPOSURE_APERTURE_PRIORITY, V4L2_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL, V4L2_EXPOSURE_SHUTTER_PRIORITY, v4l2Auto, warnStream, width
 
Constructor Summary
CvKinect()
          Sets options for Kinect.
CvKinect(java.lang.String appname)
          Sets options for Kinect.
 
Method Summary
protected  void cmdHelpExt()
          Shows Kinect-specific options.
 com.googlecode.javacv.cpp.opencv_core.IplImage depthToBGR(com.googlecode.javacv.cpp.opencv_core.IplImage depth, com.googlecode.javacv.cpp.opencv_core.IplImage bgr, int max, float scale)
          Convert a depth image to BGR false color.
protected  java.lang.String getDefAppname()
          Gets the default appname, may be overridden.
protected  java.lang.String getDefInput()
          Gets the default input, may be overridden.
 int getTiltDegs()
          Get the tilt motor angle.
 int getTiltState(com.googlecode.javacv.cpp.freenect.freenect_raw_tilt_state state)
          Get the raw tilt state.
 int initExt(int argc, java.lang.String[] argv, int ate)
          Extra initialization, for subclasses.
static void main(java.lang.String[] argv)
          Test program entry point.
 void setDepthRegistration(boolean enable)
          Enable or disable depth registration.
 void setFormat(java.lang.String format)
          Set the frame format.
 int setLED(int led)
          Set the LED.
 int setTiltDegs(int angle)
          Set the tilt motor angle.
 
Methods inherited from class ohmm.CvBase
camIndexOptional, cmdHelp, cmdHelpExtParams, doneProcessing, dumpCaptureProperties, finalize, fmt, getCaptureProperty, guiHelp, guiHelpExt, handleKey, handleKeyExt, handleMouse, handleMouse, init, init, init, init, mainLoop, makeGrabber, makeServer, mouseEventToString, msg, nowMS, process, release, save, setCaptureProperty, updateServerImage, v4l2DisableAuto, v4l2EnableAuto, v4l2GetExposure, v4l2SetExposure, waitForKeypresss, warn
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_APPNAME

public static final java.lang.String DEF_APPNAME
Default application name.

See Also:
Constant Field Values

DEF_INPUT

public static final java.lang.String DEF_INPUT
Default input device index (OpenKinectFrameGrabber).


MIN_DEPTH_MM

public static final int MIN_DEPTH_MM
Valid range of depth values in mm.

See Also:
Constant Field Values

MAX_DEPTH_MM

public static final int MAX_DEPTH_MM
Valid range of depth values in mm.

See Also:
Constant Field Values

MIN_DEPTH_11BIT

public static final int MIN_DEPTH_11BIT
Valid range of 11-bit depth values.

See Also:
Constant Field Values

MAX_DEPTH_11BIT

public static final int MAX_DEPTH_11BIT
Valid range of 11-bit depth values.

See Also:
Constant Field Values

okGrabber

protected com.googlecode.javacv.OpenKinectFrameGrabber okGrabber
OpenKinectFrameGrabber instance, if any.

Constructor Detail

CvKinect

public CvKinect(java.lang.String appname)
Sets options for Kinect.


CvKinect

public CvKinect()
Sets options for Kinect.

Method Detail

getDefAppname

protected java.lang.String getDefAppname()
Gets the default appname, may be overridden.

Overrides:
getDefAppname in class CvBase

getDefInput

protected java.lang.String getDefInput()
Gets the default input, may be overridden.

Overrides:
getDefInput in class CvBase

initExt

public int initExt(int argc,
                   java.lang.String[] argv,
                   int ate)

Extra initialization, for subclasses.

This impl sets okGrabber.

Overrides:
initExt in class CvBase
ate - the number of command line arguments already eaten by CvBase.init(int, String[])
Returns:
the total number of arguments eaten

cmdHelpExt

protected void cmdHelpExt()
Shows Kinect-specific options.

Overrides:
cmdHelpExt in class CvBase

setTiltDegs

public int setTiltDegs(int angle)

Set the tilt motor angle.

Only available when using the OpenKinect backend.

Parameters:
angle - the angle in degrees
Returns:
nonzero on error

getTiltDegs

public int getTiltDegs()

Get the tilt motor angle.

Only available when using the OpenKinect backend.

Returns:
angle the angle in degrees

getTiltState

public int getTiltState(com.googlecode.javacv.cpp.freenect.freenect_raw_tilt_state state)

Get the raw tilt state.

Only available when using the OpenKinect backend.

Parameters:
state - the state structure to be filled in, not null
Returns:
nonzero on error

setLED

public int setLED(int led)

Set the LED.

Only available when using the OpenKinect backend.

Parameters:
led - one of the OpenKinect LED_* constants
Returns:
nonzero on error

setFormat

public void setFormat(java.lang.String format)

Set the frame format.

Only available when using the OpenKinect backend.

Parameters:
format - either "depth" or "video"

setDepthRegistration

public void setDepthRegistration(boolean enable)

Enable or disable depth registration.


depthToBGR

public com.googlecode.javacv.cpp.opencv_core.IplImage depthToBGR(com.googlecode.javacv.cpp.opencv_core.IplImage depth,
                                                                 com.googlecode.javacv.cpp.opencv_core.IplImage bgr,
                                                                 int max,
                                                                 float scale)

Convert a depth image to BGR false color.

Parameters:
depth - the depth image, must be 1 channel IPL_DEPTH_16U
bgr - the BGR image, must be null or 3 channel IPL_DEPTH_8U
max - the max depth value
scale - scale factor applied after gamma
Returns:
the BGR image, consed if needed

Uses the same algorithm as OpenKinect/libfreenect glview.


main

public static void main(java.lang.String[] argv)
Test program entry point.