ohmm
Class CvKinectDemo

java.lang.Object
  extended by ohmm.CvBase
      extended by ohmm.CvKinect
          extended by ohmm.CvKinectDemo

public class CvKinectDemo
extends CvKinect

Demo of CvKinect.

Also see CvDemo.

Author:
Marsette A. Vona

Field Summary
static java.lang.String APPNAME
          Application name.
protected  com.googlecode.javacv.cpp.opencv_core.IplImage depthBGR
          False color depth image.
protected  com.googlecode.javacv.cpp.opencv_core.IplImage depthMask
          Depth mask image.
protected  int[] dumpXY
          State for handleMouse(int, int, int, int).
protected  boolean falseColor
          Whether to show depth in false color if possible.
protected  java.lang.String fmtCycle
          State for handleKeyExt(int).
protected  int ledCycle
          State for handleKeyExt(int).
protected  boolean maskColor
          Whether to mask color by valid depth if possible.
protected  boolean regCycle
          State for handleKeyExt(int).
protected  int tiltCycle
          State for handleKeyExt(int).
 
Fields inherited from class ohmm.CvKinect
DEF_APPNAME, DEF_INPUT, MAX_DEPTH_11BIT, MAX_DEPTH_MM, MIN_DEPTH_11BIT, MIN_DEPTH_MM, okGrabber
 
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
CvKinectDemo()
          Sets APPNAME.
 
Method Summary
protected  void guiHelpExt()
          Display extra GUI help, for subclasses.
protected  boolean handleKeyExt(int code)
          Keypresses not handled by the default implementation of handleKey() are passed here.
protected  void handleMouse(int event, int x, int y, int flags)
          Handle mouse events.
static void main(java.lang.String[] argv)
          Program entry point.
protected  com.googlecode.javacv.cpp.opencv_core.IplImage process(com.googlecode.javacv.cpp.opencv_core.IplImage frame)
          Process the given frame.
 void release()
          Frees memory, closes windows, and releases resources.
 
Methods inherited from class ohmm.CvKinect
cmdHelpExt, depthToBGR, getDefAppname, getDefInput, getTiltDegs, getTiltState, initExt, setDepthRegistration, setFormat, setLED, setTiltDegs
 
Methods inherited from class ohmm.CvBase
camIndexOptional, cmdHelp, cmdHelpExtParams, doneProcessing, dumpCaptureProperties, finalize, fmt, getCaptureProperty, guiHelp, handleKey, handleMouse, init, init, init, init, mainLoop, makeGrabber, makeServer, mouseEventToString, msg, nowMS, 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

APPNAME

public static final java.lang.String APPNAME
Application name.

See Also:
Constant Field Values

tiltCycle

protected int tiltCycle
State for handleKeyExt(int).


ledCycle

protected int ledCycle
State for handleKeyExt(int).


regCycle

protected boolean regCycle
State for handleKeyExt(int).


fmtCycle

protected java.lang.String fmtCycle
State for handleKeyExt(int).


dumpXY

protected int[] dumpXY
State for handleMouse(int, int, int, int).


depthBGR

protected com.googlecode.javacv.cpp.opencv_core.IplImage depthBGR
False color depth image.


depthMask

protected com.googlecode.javacv.cpp.opencv_core.IplImage depthMask
Depth mask image.


falseColor

protected boolean falseColor
Whether to show depth in false color if possible.


maskColor

protected boolean maskColor
Whether to mask color by valid depth if possible.

Constructor Detail

CvKinectDemo

public CvKinectDemo()
Sets APPNAME.

Method Detail

handleKeyExt

protected boolean handleKeyExt(int code)

Keypresses not handled by the default implementation of handleKey() are passed here.

Default impl just prints the keycode.

Overriding this is one way that subclasses can handle extra keypresses.

This impl handles keycodes for Kinect demo functions.

Overrides:
handleKeyExt in class CvBase

guiHelpExt

protected void guiHelpExt()
Display extra GUI help, for subclasses.

This impl handles keycodes for Kinect demo functions.

Overrides:
guiHelpExt in class CvBase

handleMouse

protected void handleMouse(int event,
                           int x,
                           int y,
                           int flags)

Handle mouse events.

This impl triggers RGB/XYZ dump on click.

Overrides:
handleMouse in class CvBase
Parameters:
event - one of the CV_EVENT_* constants (see opencv_highgui.java in the JavaCV sources for a list)
x - the x pixel coordinate of the mouse event
y - the y pixel coordinate of the mouse event
flags - bitmask of the CV_EVENT_FLAG_* constants (see opencv_highgui.java in the JavaCV sources for a list)

Default impl prints a message using CvBase.mouseEventToString(int, int, int, int) except for CV_EVENT_MOUSEMOVE.

Overriding this is one way that subclasses can handle mouse events.


process

protected com.googlecode.javacv.cpp.opencv_core.IplImage process(com.googlecode.javacv.cpp.opencv_core.IplImage frame)

Process the given frame.

Default impl is identity.

Note that the passed image may not be mutated. So to do any significant processing, you will need to allocate your own return image. It is typically best to do this once for the first frame, store the results in subclass instance variables, and then deallocate any allocated space in the subclass destructor.

All frames are guaranteed to have the same dimensions and pixel format.

This will be called for every iteration of CvBase.mainLoop(), even while paused. You may use the various instance fields (CvBase.frameN, CvBase.capImage, CvBase.paused, CvBase.dbg, etc) to determine what operations to perform. Of course, when writing a subclass, you may also add your own fields.

This impl handles Kinect demo functions.

Overrides:
process in class CvBase
Returns:
the processed image, null will cause image display to be skipped for this frame

release

public void release()
Frees memory, closes windows, and releases resources.

This impl also releases depthBGR.

Overrides:
release in class CvBase

main

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