hypermedia.video
Class OpenCV

java.lang.Object
  extended by hypermedia.video.OpenCV

public class OpenCV
extends java.lang.Object

The main object for all computer vision processes.

To use OpenCV library in a PApplet directly in pure Java, start with this small integration sample
for more details about Processing see the home page


        import processing.core.*;
        import hypermedia.video.OpenCV;

        public class OpenCV_PApplet extends PApplet {

                OpenCV cv = null;  // OpenCV object

                // Initialise Objects
                public void setup() {
                    size( 640, 480 );              // set frame size
                    cv = new OpenCV( this );       // link OpenCV process to this PApplet
                    cv.capture( width, height );   // start video stream
                }

                // Display the input camera stream in frame
                public void draw() {
                    cv.read();
                    image( cv.image(), 0, 0 );
                }

                // Call the PApplet main method
                public static void main( String[] args ) {
                    PApplet.main( new String[]{"OpenCV_PApplet"} );
                } 
        }

 

See Also:
processing.core.PApplet

Field Summary
static int BILATERAL
           
static int BLUR
          Blur method
static int BUFFER
           
static java.lang.String CASCADE_FRONTALFACE_ALT
           
static java.lang.String CASCADE_FRONTALFACE_ALT_TREE
          Standard Haar classifier cascade file used for object detection
static java.lang.String CASCADE_FRONTALFACE_ALT2
           
static java.lang.String CASCADE_FRONTALFACE_DEFAULT
           
static java.lang.String CASCADE_FULLBODY
           
static java.lang.String CASCADE_LOWERBODY
           
static java.lang.String CASCADE_PROFILEFACE
           
static java.lang.String CASCADE_UPPERBODY
           
static int FLIP_BOTH
           
static int FLIP_HORIZONTAL
           
static int FLIP_VERTICAL
          Flip mode
static int GAUSSIAN
           
static int GRAY
           
static int HAAR_DO_CANNY_PRUNING
          Haar classifier flag
static int HAAR_DO_ROUGH_SEARCH
           
static int HAAR_FIND_BIGGEST_OBJECT
           
static int HAAR_SCALE_IMAGE
           
 int height
          OpenCV image/buffer height
static int INTER_AREA
           
static int INTER_CUBIC
           
static int INTER_LINEAR
           
static int INTER_NN
          Interpolation method
static int MAX_VERTICES
          The maximum number of contour points available to blob detection (by default)
static int MEDIAN
           
static int MEMORY
           
static int MOVIE_FRAMES
           
static int MOVIE_MILLISECONDS
          Movie info selector (not yet implemented)
static int MOVIE_RATIO
           
static int RGB
          Colorspace of image
static int SOURCE
          Type of Image
static int THRESH_BINARY
          Thresholding method
static int THRESH_BINARY_INV
           
static int THRESH_OTSU
           
static int THRESH_TOZERO
           
static int THRESH_TOZERO_INV
           
static int THRESH_TRUNC
           
 int width
          OpenCV image/buffer width
 
Constructor Summary
OpenCV()
          Create a new OpenCV instance.
OpenCV(processing.core.PApplet parent)
          Create a new OpenCV instance.
 
Method Summary
 void absDiff()
          Calculate the absolute difference between the image in memory and the current image.
 java.lang.String absolutePath(java.lang.String file)
          Prepend the absolute path for the given file name.
 void allocate(int width, int height)
          Allocate required buffer with the given size.
 float arcLength(int index)
          Deprecated.  
 float area(int index)
          Deprecated.  
 int blobCount()
          Deprecated.  
 Blob[] blobs(int minArea, int maxArea, int maxBlobs, boolean findHoles)
          Blob and contour detection.
 Blob[] blobs(int minArea, int maxArea, int maxBlobs, boolean findHoles, int maxVertices)
          Blob and contour detection.
 void blur(int type, int param1)
          Smooth the image in one of several ways.
 void blur(int type, int param1, int param2, float param3, float param4)
          Smooth the image in one of several ways.
 void brightness(int value)
          Adjust the image brightness with the specified value (in range of -128 to 128).
 void capture(int width, int height)
          Allocate and initialize resources for reading a video stream from the default camera.
 void capture(int width, int height, int index)
          Allocate and initialize resources for reading a video stream from the specified camera.
 void cascade(java.lang.String file)
          Load into memory the descriptor file for a trained cascade classifier.
 java.awt.Point centroid(int index)
          Deprecated.  
 void contrast(int value)
          Adjust the image contrast with the specified value (in range of -128 to 128).
 void convert(int type)
          Convert the current image from one colorspace to another.
 void copy(int[] pixels, int step, int sx, int sy, int swidth, int sheight, int dx, int dy, int dwidth, int dheight)
          Copies a region of pixels from an image to the current buffer at the specified position and with the given dimensions.
 void copy(processing.core.PImage image)
          Copy an image into the current OpenCV buffer.
 void copy(processing.core.PImage image, int sx, int sy, int swidth, int sheight, int dx, int dy, int dwidth, int dheight)
          Copy the image (or a part of it) into the current OpenCV buffer (or a part of it).
 void copy(java.lang.String file)
          Copy the specified image file into the current OpenCV buffer.
 void copy(java.lang.String file, int sx, int sy, int swidth, int sheight, int dx, int dy, int dwidth, int dheight)
          Copy the specified image file (or a part of it) into the current OpenCV buffer (or a part of it).
 java.awt.Rectangle[] detect()
           
 java.awt.Rectangle[] detect(float scale, int min_neighbors, int flags, int min_width, int min_height)
          Detect object(s) in the current image depending on the current cascade description.
 void dispose()
          Forget all OpenCV resources.
 void findContours(int minArea, int maxArea, int maxBlobs, boolean findHoles)
          Deprecated.  
 void findContours(int minArea, int maxArea, int maxBlobs, boolean findHoles, int maxVertices)
          Deprecated.  
 void flip(int mode)
          Flip the current image around vertical, horizontal or both axes.
 processing.core.PImage image()
          Return the current OpenCV image.
 processing.core.PImage image(int type)
          Return the specified OpenCV image
 void interpolation(int method)
          Set global interpolation method.
 void invert()
          Invert image.
 boolean isHole(int index)
          Deprecated.  
 void jump(float ratio)
          Jump to a specified movie frame.
 void jump(float value, int type)
          Jump to a specified movie frame.
 void jump(int millis)
          Jump to a specified movie frame.
 void loadImage(java.lang.String file)
          Load an image from the specified file.
 void loadImage(java.lang.String file, int width, int height)
          Load an image from the specified file with the given size dependin of the current scale interpolation method.
 void movie(java.lang.String filename)
          Allocate and initialize resources for reading a video file from the specified file name.
 void movie(java.lang.String filename, int width, int height)
          Allocate and initialize resources for reading a video file from the specified file name, with the given frames dimensions.
 int[] pixels()
           
 int[] pixels(int type)
          Retrieve cuurent (or specified) image data.
 int pointCount(int index)
          Deprecated.  
 java.awt.Point[] points(int index)
          Deprecated.  
 void read()
          Grab a new frame from the input camera or a movie file.
 java.awt.Rectangle rectangle(int index)
          Deprecated.  
 void remember()
          Place the image source in memory.
 void remember(int type)
          Place the specified image in memory.
 void remember(int type, int mode)
          Place the specified image in memory and flip the stored image around the given axis.
 void restore()
          Revert to the original image.
 void restore(int type)
          Restore the current image data from the original image with the given color space.
 void ROI(int x, int y, int width, int height)
          Set image region of interest to the given rectangle.
 void ROI(java.awt.Rectangle rect)
          Set image region of interest to the given rectangle.
 void stop()
          Stop OpenCV process.
 void threshold(float value)
          Applies fixed-level threshold to the current image using the THRESH_BINARY thresholding type and 255 as the maximum value.
 void threshold(float value, float max, int type)
          Apply fixed-level threshold to the current image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE

public static final int SOURCE
Type of Image

See Also:
image(int), remember(int), Constant Field Values

BUFFER

public static final int BUFFER
See Also:
Constant Field Values

MEMORY

public static final int MEMORY
See Also:
Constant Field Values

RGB

public static final int RGB
Colorspace of image

See Also:
convert(int), Constant Field Values

GRAY

public static final int GRAY
See Also:
Constant Field Values

THRESH_BINARY

public static final int THRESH_BINARY
Thresholding method

See Also:
threshold( float ), threshold( float, float, int ), Constant Field Values

THRESH_BINARY_INV

public static final int THRESH_BINARY_INV
See Also:
Constant Field Values

THRESH_TRUNC

public static final int THRESH_TRUNC
See Also:
Constant Field Values

THRESH_TOZERO

public static final int THRESH_TOZERO
See Also:
Constant Field Values

THRESH_TOZERO_INV

public static final int THRESH_TOZERO_INV
See Also:
Constant Field Values

THRESH_OTSU

public static final int THRESH_OTSU
See Also:
Constant Field Values

FLIP_VERTICAL

public static final int FLIP_VERTICAL
Flip mode

See Also:
flip( int ), remember( int, int ), Constant Field Values

FLIP_HORIZONTAL

public static final int FLIP_HORIZONTAL
See Also:
Constant Field Values

FLIP_BOTH

public static final int FLIP_BOTH
See Also:
Constant Field Values

INTER_NN

public static final int INTER_NN
Interpolation method

See Also:
interpolation( int ), Constant Field Values

INTER_LINEAR

public static final int INTER_LINEAR
See Also:
Constant Field Values

INTER_CUBIC

public static final int INTER_CUBIC
See Also:
Constant Field Values

INTER_AREA

public static final int INTER_AREA
See Also:
Constant Field Values

MAX_VERTICES

public static final int MAX_VERTICES
The maximum number of contour points available to blob detection (by default)

See Also:
blobs( int, int, int, boolean ), blobs( int, int, int, boolean, int ), Constant Field Values

BLUR

public static final int BLUR
Blur method

See Also:
blur(int, int), blur(int, int, int, float, float), Constant Field Values

GAUSSIAN

public static final int GAUSSIAN
See Also:
Constant Field Values

MEDIAN

public static final int MEDIAN
See Also:
Constant Field Values

BILATERAL

public static final int BILATERAL
See Also:
Constant Field Values

MOVIE_MILLISECONDS

public static final int MOVIE_MILLISECONDS
Movie info selector (not yet implemented)

See Also:
jump(float, int), Constant Field Values

MOVIE_FRAMES

public static final int MOVIE_FRAMES
See Also:
Constant Field Values

MOVIE_RATIO

public static final int MOVIE_RATIO
See Also:
Constant Field Values

HAAR_DO_CANNY_PRUNING

public static final int HAAR_DO_CANNY_PRUNING
Haar classifier flag

See Also:
detect(float, int, int, int, int), Constant Field Values

HAAR_SCALE_IMAGE

public static final int HAAR_SCALE_IMAGE
See Also:
Constant Field Values

HAAR_FIND_BIGGEST_OBJECT

public static final int HAAR_FIND_BIGGEST_OBJECT
See Also:
Constant Field Values

HAAR_DO_ROUGH_SEARCH

public static final int HAAR_DO_ROUGH_SEARCH
See Also:
Constant Field Values

CASCADE_FRONTALFACE_ALT_TREE

public static final java.lang.String CASCADE_FRONTALFACE_ALT_TREE
Standard Haar classifier cascade file used for object detection

See Also:
cascade(String), Constant Field Values

CASCADE_FRONTALFACE_ALT

public static final java.lang.String CASCADE_FRONTALFACE_ALT
See Also:
Constant Field Values

CASCADE_FRONTALFACE_ALT2

public static final java.lang.String CASCADE_FRONTALFACE_ALT2
See Also:
Constant Field Values

CASCADE_FRONTALFACE_DEFAULT

public static final java.lang.String CASCADE_FRONTALFACE_DEFAULT
See Also:
Constant Field Values

CASCADE_PROFILEFACE

public static final java.lang.String CASCADE_PROFILEFACE
See Also:
Constant Field Values

CASCADE_FULLBODY

public static final java.lang.String CASCADE_FULLBODY
See Also:
Constant Field Values

CASCADE_LOWERBODY

public static final java.lang.String CASCADE_LOWERBODY
See Also:
Constant Field Values

CASCADE_UPPERBODY

public static final java.lang.String CASCADE_UPPERBODY
See Also:
Constant Field Values

width

public int width
OpenCV image/buffer width

See Also:
height

height

public int height
OpenCV image/buffer height

See Also:
width
Constructor Detail

OpenCV

public OpenCV()
Create a new OpenCV instance.


OpenCV

public OpenCV(processing.core.PApplet parent)
Create a new OpenCV instance.

Method Detail

dispose

public void dispose()
Forget all OpenCV resources. This method is automatically called by Processing when the PApplet shuts down.

See Also:
stop()

allocate

public void allocate(int width,
                     int height)
Allocate required buffer with the given size.

This method allows you to create your own (blank) image buffer to work on.

Except for creating an empty buffer, this method should not be directly used.
capture(), movie() and loadImage() methods will automatically re-allocate the current buffer.

See Also:
capture( int, int ), movie( String ), loadImage( String ), copy(PImage), copy(String), copy(PImage, int, int, int, int, int, int, int, int), copy(String, int, int, int, int, int, int, int, int), copy(int[], int, int, int, int, int, int, int, int, int)

stop

public void stop()
Stop OpenCV process.


remember

public void remember()
Place the image source in memory. Used by absDiff() to compare two images (for background extraction, for example).

See Also:
remember( int, int ), remember( int ), absDiff()

remember

public void remember(int type)
Place the specified image in memory. Used by absDiff() to compare two images (for background extraction, for example).

Parameters:
type - which image to be stored: SOURCE or BUFFER
See Also:
remember( int, int ), remember(), absDiff()

remember

public void remember(int type,
                     int mode)
Place the specified image in memory and flip the stored image around the given axis. Used by absDiff() to compare two images (for background extraction, for example).

Parameters:
type - which image to be stored: SOURCE or BUFFER
mode - the used axis: FLIP_HORIZONTAL, FLIP_VERTICAL or FLIP_BOTH
See Also:
remember( int, int ), flip( int ), absDiff()

convert

public void convert(int type)
Convert the current image from one colorspace to another.

Parameters:
type - the target color space : RGB, GRAY

absDiff

public void absDiff()
Calculate the absolute difference between the image in memory and the current image.

See Also:
remember(), remember( int ), remember( int, int )

flip

public void flip(int mode)
Flip the current image around vertical, horizontal or both axes.

Parameters:
mode - the used axis, FLIP_HORIZONTAL, FLIP_VERTICAL or FLIP_BOTH

threshold

public void threshold(float value,
                      float max,
                      int type)
Apply fixed-level threshold to the current image.

This method applies fixed-level thresholding to single-channel array. It is typically used to get bi-level (binary) image out of grayscale image or for removing a noise (filtering out pixels with too small or too large values).

About types of thresholding

Parameters:
value - threshold value
max - the maximum value to use with THRESH_BINARY and THRESH_BINARY_INV thresholding types.
type - Types of thresholding
See Also:
threshold( float )

threshold

public void threshold(float value)
Applies fixed-level threshold to the current image using the THRESH_BINARY thresholding type and 255 as the maximum value.

Parameters:
value - threshold value
See Also:
threshold( float, float, int )

brightness

public void brightness(int value)
Adjust the image brightness with the specified value (in range of -128 to 128).

Parameters:
value - the new brightness value
See Also:
contrast( int )

contrast

public void contrast(int value)
Adjust the image contrast with the specified value (in range of -128 to 128).

Parameters:
value - the new contrast value
See Also:
brightness( int )

invert

public void invert()
Invert image.


blur

public void blur(int type,
                 int param1)
Smooth the image in one of several ways.
CV_BLUR
simple blur
for each pixel the result is a mean of pixel values param1×param2 neighborhood of the pixel.
CV_GAUSSIAN
Gaussian blur
the image is smoothed using the Gaussian kernel of size param1×param2. param3 and param4 may optionally be used to specify shape of the kernel.
CV_MEDIAN
median blur
the image is smoothed using medial filter of size param1×param1. That is, for each pixel the result is the median computed over param1×param1 neighborhood.
CV_BILATERAL
bilateral filter
the image is smoothed using a bilateral 3x3 filter with color sigma=param1 and space sigma=param2. Information about bilateral filtering can be found at Bilateral Filtering

Parameters:
param1 - The first parameter of smoothing operation. It should be odd (1, 3, 5, …), so that a pixel neighborhood used for smoothing operation is symmetrical relative to the pixel.
See Also:
blur( int, int, int, float, float )

blur

public void blur(int type,
                 int param1,
                 int param2,
                 float param3,
                 float param4)
Smooth the image in one of several ways.

Parameters:
param1 - The first parameter of smoothing operation. It should be odd (1, 3, 5, …), so that a pixel neighborhood used for smoothing operation is symmetrical relative to the pixel.
param2 - The second parameter of smoothing operation. In case of simple scaled/non-scaled and Gaussian blur if param2 is zero, it is set to param1. When not 0, it should be odd too.
param3 - In case of Gaussian kernel this parameter may specify Gaussian sigma (standard deviation). If it is zero, it is calculated from the kernel size: sigma = (n/2 - 1)*0.3 + 0.8, where n=param1 for horizontal kernel, n=param2 for vertical kernel. With the standard sigma for small kernels (3×3 to 7×7) the performance is better. If param3 is not zero, while param1 and param2 are zeros, the kernel size is calculated from the sigma (to provide accurate enough operation).
param4 - In case of non-square Gaussian kernel the parameter may be used to specify a different (from param3) sigma in the vertical direction.
See Also:
blur( int, int )

interpolation

public void interpolation(int method)
Set global interpolation method. By default the interpolation method is set to INTER_LINEAR. Used by all methods (ex. copy(), loadImage(), …) that resize the image.
INTER_NN
nearest-neighbor (preserve hard egdes)
INTER_LINEAR
bilinear interpolation
INTER_CUBIC
bicubic interpolation (best for smooth gradients)
INTER_AREA
resampling using pixel area relation

Parameters:
method - INTER_NN, INTER_LINEAR, INTER_CUBIC or INTER_AREA

copy

public void copy(processing.core.PImage image)
Copy an image into the current OpenCV buffer. Note: any alpha channel will be ignored.

Parameters:
image - the image to copy into buffer
See Also:
allocate(int,int), interpolation( int ), copy( String ), copy( PImage, int, int, int, int, int, int, int, int ), copy( String, int, int, int, int, int, int, int, int ), copy( int[], int, int, int, int, int, int, int, int, int )

copy

public void copy(java.lang.String file)
Copy the specified image file into the current OpenCV buffer. Note: any alpha channel will be ignored.

Parameters:
file - the filepath of the image to copy into buffer
See Also:
allocate(int,int), interpolation( int ), copy( PImage ), copy( PImage, int, int, int, int, int, int, int, int ), copy( int[], int, int, int, int, int, int, int, int, int )

copy

public void copy(processing.core.PImage image,
                 int sx,
                 int sy,
                 int swidth,
                 int sheight,
                 int dx,
                 int dy,
                 int dwidth,
                 int dheight)
Copy the image (or a part of it) into the current OpenCV buffer (or a part of it). Resizing allowed. Note: any alpha channel will be ignored.

Parameters:
image - the filepath of the image to copy into buffer
See Also:
allocate(int,int), interpolation( int ), copy( PImage ), copy( String ), copy( String, int, int, int, int, int, int, int, int ), copy( int[], int, int, int, int, int, int, int, int, int ), copy( int[], int, int, int, int, int, int, int, int, int )

copy

public void copy(java.lang.String file,
                 int sx,
                 int sy,
                 int swidth,
                 int sheight,
                 int dx,
                 int dy,
                 int dwidth,
                 int dheight)
Copy the specified image file (or a part of it) into the current OpenCV buffer (or a part of it). Resizing allowed. Note: any alpha channel will be ignored.

Parameters:
image - the filepath of the image to copy into buffer
See Also:
allocate(int,int), interpolation( int ), copy( PImage ), copy( PImage, int, int, int, int, int, int, int, int ), copy( int[], int, int, int, int, int, int, int, int, int ), copy( int[], int, int, int, int, int, int, int, int, int )

copy

public void copy(int[] pixels,
                 int step,
                 int sx,
                 int sy,
                 int swidth,
                 int sheight,
                 int dx,
                 int dy,
                 int dwidth,
                 int dheight)
Copies a region of pixels from an image to the current buffer at the specified position and with the given dimensions. Resizing allowed. Note: any alpha channel will be ignored.

Parameters:
pixels - the image data
step - the width of one horizontal line of pixels
sx - the source x coordinate
sy - the source y coordinate
swidth - the source width
sheight - the source height
dx - the destination x coordinate
dy - the destination y coordinate
dwidth - the destination width
dheight - the destination height
See Also:
allocate(int,int), interpolation( int ), copy( PImage )

restore

public void restore()
Revert to the original image. By default returns to RGB image, or GRAY (if specified).

See Also:
blobs( int, int, int, boolean, int ), blobs( int, int, int, boolean )

restore

public void restore(int type)
Restore the current image data from the original image with the given color space.

Parameters:
type - the target color space : RGB or GRAY
See Also:
blobs( int, int, int, boolean, int ), blobs( int, int, int, boolean )

pixels

public int[] pixels(int type)
Retrieve cuurent (or specified) image data.

Parameters:
type - the type of the image: SOURCE, BUFFER, MEMORY

pixels

public int[] pixels()

loadImage

public void loadImage(java.lang.String file)
Load an image from the specified file.

Currently the following file formats are supported:

note : this method automatically updates previous memory allocation

Currently there is an impressive OpenCV-caused memory leak on Macintosh computers when recalling this method successively. To fix this bug, load the image file from Processing and pass the pixels over using copy().

Parameters:
file - String : the name of file to be loaded
See Also:
loadImage( String, int, int )

loadImage

public void loadImage(java.lang.String file,
                      int width,
                      int height)
Load an image from the specified file with the given size dependin of the current scale interpolation method.

Currently the following file formats are supported:

note : this method automatically updates previous memory allocation

Parameters:
file - the name of file to be loaded
width - the destination image (buffer) width size
height - the destination image (buffer) height size
See Also:
interpolation( int ), loadImage( String )

image

public processing.core.PImage image()
Return the current OpenCV image.

Returns:
PImage
See Also:
image(int)

image

public processing.core.PImage image(int type)
Return the specified OpenCV image

Parameters:
type - the type of the image: SOURCE, BUFFER, MEMORY
Returns:
PImage
See Also:
image()

blobs

public Blob[] blobs(int minArea,
                    int maxArea,
                    int maxBlobs,
                    boolean findHoles)
Blob and contour detection.

This function looks for contours within the image, returning a list of Blob objects.

When searching for blobs, you must define the minimum and maximum size in pixels. This can be calculated by any number of means; for example, if you want to limit blobs to no larger than half the Region Of Interest, pass (width * height) / 2 for the maxArea. Blobs are then ordered from largest to smallest.

Blob objects contain all the relevant information about each contour (area, length, centroid, isHole, …)

Parameters:
minArea - the minimum area to search for (total pixels)
maxArea - the maximum area to search for (total pixels)
maxBlobs - the maximim number of blobs to return
findHoles - accept blobs fully inside of other blobs
Returns:
Blob[]
See Also:
blobs( int, int, int, boolean, int ), Blob, restore(), restore( int ), MAX_VERTICES

blobs

public Blob[] blobs(int minArea,
                    int maxArea,
                    int maxBlobs,
                    boolean findHoles,
                    int maxVertices)
Blob and contour detection.

This function looks for contours within the image, returning a list of Blob objects.

When searching for blobs, you must define the minimum and maximum size in pixels. This can be calculated by any number of means; for example, if you want to limit blobs to no larger than half the Region Of Interest, pass (width * height) / 2 for the maxArea. Blobs are then ordered from largest to smallest.

Blob objects contain all the relevant information about each contour (area, length, centroid, isHole, …)

The optional maxVertices parameter, allows you to increase the overall number of points defining the contour of the blob. Use this parameter if for some reason your blob shapes are incomplete.

Parameters:
minArea - the minimum area to search for (total pixels)
maxArea - the maximum area to search for (total pixels)
maxBlobs - the maximim number of blobs to return
findHoles - accept blobs fully inside of other blobs
maxVertices - the maximum number of points used to define the contour
Returns:
Blob[]
See Also:
blobs( int, int, int, boolean ), Blob, restore(), restore( int ), MAX_VERTICES

findContours

public void findContours(int minArea,
                         int maxArea,
                         int maxBlobs,
                         boolean findHoles)
Deprecated. 

Blob detection

Parameters:
minArea - the minimum area to searched
maxArea - the maximum area to searched

findContours

public void findContours(int minArea,
                         int maxArea,
                         int maxBlobs,
                         boolean findHoles,
                         int maxVertices)
Deprecated. 


blobCount

public int blobCount()
Deprecated. 


area

public float area(int index)
Deprecated. 


arcLength

public float arcLength(int index)
Deprecated. 


centroid

public java.awt.Point centroid(int index)
Deprecated. 


rectangle

public java.awt.Rectangle rectangle(int index)
Deprecated. 


pointCount

public int pointCount(int index)
Deprecated. 


points

public java.awt.Point[] points(int index)
Deprecated. 


isHole

public boolean isHole(int index)
Deprecated. 


capture

public void capture(int width,
                    int height)
Allocate and initialize resources for reading a video stream from the default camera.
note : this method automatically updates previous memory allocation

Parameters:
width - the width of the video stream image
height - the height of the video stream image
See Also:
capture( int, int, int ), movie( String )

capture

public void capture(int width,
                    int height,
                    int index)
Allocate and initialize resources for reading a video stream from the specified camera.
note : this method automatically updates previous memory allocation

Parameters:
width - the width of the video stream image
height - the height of the video stream image
index - the index of the camera to be used
See Also:
capture( int, int ), movie( String )

movie

public void movie(java.lang.String filename)
Allocate and initialize resources for reading a video file from the specified file name.
Movie must be located in the sketch's data directory, otherwise you must specified the full path to access to the movie file without an error.
notes : this method automatically updates previous memory allocation, sound will not be available

Supported codecs and file formats depends on the backend video library :

For more information about video on OpenCV or about reading your video files on all platforms, see VideoCodecs

Parameters:
filename - the filepath of the movie file
See Also:
movie( String, int, int ), capture( int, int ), capture( int, int, int ), jump( int ), jump( float ), jump( float, int )

movie

public void movie(java.lang.String filename,
                  int width,
                  int height)
Allocate and initialize resources for reading a video file from the specified file name, with the given frames dimensions.
Movie must be located in the sketch's data directory, otherwise you must specified the full path to access to the movie file without an error.
notes : this method automatically updates previous memory allocation, sound will not be available

Supported codecs and file formats depends on the backend video library :

For more information about video on OpenCV or about reading your video files on all platforms, see VideoCodecs

Parameters:
filename - the filepath of the movie file
width - the width of the movie image
height - the height of the movie image
See Also:
movie( String ), jump( int ), jump( float ), jump( float, int )

read

public void read()
Grab a new frame from the input camera or a movie file.


jump

public void jump(int millis)
Jump to a specified movie frame.

Parameters:
millis - the time in milliseconds of the desired frame
See Also:
movie( String ), movie( String, int, int ), jump( float ), jump( float, int )

jump

public void jump(float ratio)
Jump to a specified movie frame.

Parameters:
ratio - the time expressed as a ratio (0.0 - 1.0) of the desired frame
See Also:
jump( int ), jump( float, int ), movie( String ), movie( String, int, int )

jump

public void jump(float value,
                 int type)
Jump to a specified movie frame.

Parameters:
value - the time (according to type) of the desired frame
type - use: MOVIE_MILLISECONDS, MOVIE_FRAMES or MOVIE_RATIO
See Also:
jump( float ), jump( int ), movie( String ), movie( String, int, int )

ROI

public void ROI(java.awt.Rectangle rect)
Set image region of interest to the given rectangle. This methods isolates a sub-section of the current image for all subsequent activity. To clear the Region of Interest back to the entire image, call ROI(null);

Parameters:
rect - the new region of interest or null to reset

ROI

public void ROI(int x,
                int y,
                int width,
                int height)
Set image region of interest to the given rectangle. This methods isolates a sub-section of the current image for all subsequent activity. To clear the Region of Interest back to the entire image, call ROI(null);

Parameters:
x - the region x-coordinate
y - the region y-coordinate
width - the region width
height - the region height

absolutePath

public java.lang.String absolutePath(java.lang.String file)
Prepend the absolute path for the given file name.

This method try to return a full path to an item in the sketch/program folder, in the data folder for Processing user, the system OpenCV's resources folder ('data' or 'resources'), in any resources folder for Java user. The search order is the 'data' folder, the current user directory, any resources folder.

Parameters:
file - the filename to be search
Returns:
String

cascade

public void cascade(java.lang.String file)
Load into memory the descriptor file for a trained cascade classifier. Required by the object detection method (see detect()).

While you may use your own cascade description files, this library links as well to a standard family of detection cascades (CASCADE_FRONTALFACE_DEFAULT, CASCADE_FULLBODY, …). These are installed automatically in the Windows installer and most Linux packages. For those using Macs, we have included these files in our opencv-framework-*.*.dmg installer. If you use a different Mac installer, you will have to import these files on your own.

It is recommended that you avoid loading the file at each cycle.

Available detection cascade flags :

Parameters:
file - The filepath, or standard cascade flag (see above) of the Haar classifier cascade file to be used for object detection
See Also:
detect(), detect( float, int, int, int, int )

detect

public java.awt.Rectangle[] detect(float scale,
                                   int min_neighbors,
                                   int flags,
                                   int min_width,
                                   int min_height)
Detect object(s) in the current image depending on the current cascade description.

This method finds rectangular regions in the current image that are likely to contain objects the cascade has been trained to recognize. It returns found regions as a sequence of rectangles.

The default parameters (scale=1.1, min_neighbors=3, flags=0) are tuned for accurate (but slow) object detection. For a faster operation on real-time images, the more preferable settings are: scale=1.2, min_neighbors=2, flags=HAAR_DO_CANNY_PRUNING, min_size= (for example, ~1/4 to 1/16 of the image area in case of video conferencing).

Mode of operation flags:

HAAR_SCALE_IMAGE
for each scale factor used the function will downscale the image rather than "zoom" the feature coordinates in the classifier cascade. Currently, the option can only be used alone, i.e. the flag can not be set together with the others.
HAAR_DO_CANNY_PRUNING
If it is set, the function uses Canny edge detector to reject some image regions that contain too few or too much edges and thus can not contain the searched object. The particular threshold values are tuned for face detection and in this case the pruning speeds up the processing.
HAAR_FIND_BIGGEST_OBJECT
If it is set, the function finds the largest object (if any) in the image. That is, the output sequence will contain one (or zero) element(s).
HAAR_DO_ROUGH_SEARCH
It should be used only when CV_HAAR_FIND_BIGGEST_OBJECT is set and min_neighbors > 0. If the flag is set, the function does not look for candidates of a smaller size as soon as it has found the object (with enough neighbor candidates) at the current scale. Typically, when min_neighbors is fixed, the mode yields less accurate (a bit larger) object rectangle than the regular single-object mode (flags=HAAR_FIND_BIGGEST_OBJECT), but it is much faster, up to an order of magnitude. A greater value of min_neighbors may be specified to improve the accuracy.

Note, that in single-object mode HAAR_DO_CANNY_PRUNING does not improve performance much and can even slow down the processing.

Parameters:
scale - The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%.
min_neighbors - Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure.
flags - Mode of operation. It can be a combination of zero or more of the above flags.
min_width - Minimum window size. By default, it is set to the size of samples the classifier has been trained on (~20×20 for face detection).
min_height - Minimum window size. By default, it is set to the size of samples the classifier has been trained on (~20×20 for face detection).
See Also:
cascade( String )

detect

public java.awt.Rectangle[] detect()