ohmm
Class CvDemo

java.lang.Object
  extended by ohmm.CvBase
      extended by ohmm.CvDemo

public class CvDemo
extends CvBase

Demo of CvBase.

The main action is in process(com.googlecode.javacv.cpp.opencv_core.IplImage). Also shows how to handle custom command line parameters and mouse and key events.

Author:
Marsette A. Vona

Field Summary
protected  boolean allDone
          Time to quit?
static java.lang.String APPNAME
          Application name.
static int DEF_MAX_FPS
          Default max FPS.
protected  int[] dumpXY
          Clicked pixel coords pending RGB dump, or -1 if none.
protected  com.googlecode.javacv.cpp.opencv_core.IplImage procImg
          Processed image buffer, allocated on first call to process(com.googlecode.javacv.cpp.opencv_core.IplImage).
 
Fields inherited from class ohmm.CvBase
appname, brightness, canvasFrame, canvasFrameKeyEvent, cap, CAP_PROP_NAMES, CAP_PROPS, capImage, dbg, DEF_APPNAME, DEF_CAM_H, DEF_CAM_W, DEF_INPUT, 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
CvDemo()
          Sets APPNAME and DEF_MAX_FPS.
 
Method Summary
protected  void cmdHelpExt()
          Help for the extra command line parameter.
protected  java.lang.String cmdHelpExtParams()
          Shows the extra command line parameter.
protected  boolean doneProcessing()
          Are we allDone?
protected  void guiHelpExt()
          Help for the extra GUI keyboard commands.
protected  boolean handleKeyExt(int code)
          Handle our custom keypresses.
protected  void handleMouse(int event, int x, int y, int flags)
          Show pixel color at mouse click.
 int initExt(int argc, java.lang.String[] argv, int ate)
          Handle extra command line parameters.
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)
          Shows how to do image processing.
 void release()
          Releases allocated memory.
 
Methods inherited from class ohmm.CvBase
camIndexOptional, cmdHelp, dumpCaptureProperties, finalize, fmt, getCaptureProperty, getDefAppname, getDefInput, 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

DEF_MAX_FPS

public static final int DEF_MAX_FPS
Default max FPS.

See Also:
Constant Field Values

APPNAME

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

See Also:
Constant Field Values

allDone

protected boolean allDone
Time to quit?


dumpXY

protected int[] dumpXY
Clicked pixel coords pending RGB dump, or -1 if none.


procImg

protected com.googlecode.javacv.cpp.opencv_core.IplImage procImg
Processed image buffer, allocated on first call to process(com.googlecode.javacv.cpp.opencv_core.IplImage).

Constructor Detail

CvDemo

public CvDemo()
Sets APPNAME and DEF_MAX_FPS.

Method Detail

cmdHelpExt

protected void cmdHelpExt()
Help for the extra command line parameter.

Overrides:
cmdHelpExt in class CvBase

cmdHelpExtParams

protected java.lang.String cmdHelpExtParams()
Shows the extra command line parameter.

Overrides:
cmdHelpExtParams in class CvBase

guiHelpExt

protected void guiHelpExt()
Help for the extra GUI keyboard commands.

Overrides:
guiHelpExt in class CvBase

process

protected com.googlecode.javacv.cpp.opencv_core.IplImage process(com.googlecode.javacv.cpp.opencv_core.IplImage frame)
Shows how to do image processing.

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

doneProcessing

protected boolean doneProcessing()
Are we allDone?

Overrides:
doneProcessing in class CvBase
Returns:
true iff main loop should end

Default impl returns false.


handleKeyExt

protected boolean handleKeyExt(int code)
Handle our custom keypresses.

Overrides:
handleKeyExt in class CvBase

handleMouse

protected void handleMouse(int event,
                           int x,
                           int y,
                           int flags)
Show pixel color at mouse click. Chains to default impl to show debug info about mouse events.

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.


release

public void release()
Releases allocated memory.

Overrides:
release in class CvBase

initExt

public int initExt(int argc,
                   java.lang.String[] argv,
                   int ate)
Handle extra command line parameters.

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

main

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