|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objecttoxi.video.capture.LibCV
public class LibCV
LibCV is a basic video capture wrapper and computer vision library for Processing. Internally it is only working with 8 bit images, but can be used with any Java based capture approach implementing the SimpleCapture interface via an wrapper.
LibCV automatically handles basic computer vision tasks like background subtraction and the computation of difference frames for obtaining motion data. You can choose to only analyze parts of the camera image by defining a quad outlining the area to be examined.
All image buffers used internally and exposed via getBackground(),
getBuffer() and getDeltaBuffer() will only contain 8bit
data, but will be displayed in colour by Processing's image() method. In
order to display these images correctly, the alpha channel is set to 100%. So
you'll have to make sure to mask the blue channel where the real data is
stored when doing any further analysis:
PImage buf=libcvInstance.getBuffer();
for(int i=0; i < buf.pixels.length; i++) {
int val=buf.pixels[i] & 0xff;
...
}
The SimpleCapture interface is used to ensure a relative independence from various capture backends. It should be very straightforward to write a wrapper for the existing Processing Capture object making use of this interface and to enable its use with this library.
| Nested Class Summary | |
|---|---|
class |
LibCV.Quad
Utility datatype for storing a set of four 2D coordinates |
| Constructor Summary | |
|---|---|
LibCV(processing.core.PApplet a,
SimpleCapture c)
Constructor for the library |
|
| Method Summary | |
|---|---|
void |
accumulateBackground(processing.core.PImage img)
Mixes the passed image with the currently used background. |
processing.core.PImage |
getBackground()
Retrieves the currently used background buffer. |
processing.core.PImage |
getBuffer()
Returns the buffer containing the most recent frame (depending on when this method has been called, in either processed or unprocessed form) |
LibCV.Quad |
getCorrectionQuad()
Returns the currently used quad for stretching/correcting images. |
processing.core.PImage |
getDeltaBuffer()
Returns the buffer containing the difference to the previous frame |
java.lang.String |
getError()
String description of a capture error occured previously. |
processing.core.PImage |
getFrame()
Calling this method will trigge reading a new frame and to return it. |
int |
getHeight()
Retrieves the pixel height of the buffers |
int |
getWidth()
Retrieves the pixel width of the buffers |
boolean |
hasBackground()
Returns status of the library's background processing setting. |
void |
hasBackground(boolean s)
Tells the library if background subtraction should be used when processing frames |
boolean |
isCorrected()
Returns the status of the library's pixel correction setting |
void |
processFrame(processing.core.PImage img)
Performs background subtraction on the passed image (if enabled) and updates the delta buffer containing movement information. |
void |
setBackground(processing.core.PImage img)
Uses the passed in image as background. |
void |
setCorrectionPointID(int id,
int x,
int y)
Updates the coordinate of one of the points of the correction quad. |
void |
stop()
|
void |
useCorrection(boolean state)
Enables/disable the trapezoid correction of incoming frames based on the quad defined via setCorrectionPointID(int, int, int) |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LibCV(processing.core.PApplet a,
SimpleCapture c)
a - host Processing applet/applicationc - capture object| Method Detail |
|---|
public void accumulateBackground(processing.core.PImage img)
throws toxi.video.capture.IncompatibleSizeException
img - image to be mixed with existing background
IncompatibleSizeException, - if image has different size than buffers.
toxi.video.capture.IncompatibleSizeExceptionpublic processing.core.PImage getBackground()
public processing.core.PImage getBuffer()
public LibCV.Quad getCorrectionQuad()
public processing.core.PImage getDeltaBuffer()
public java.lang.String getError()
public processing.core.PImage getFrame()
public int getHeight()
public int getWidth()
public boolean hasBackground()
public void hasBackground(boolean s)
s - true, if background is usedpublic boolean isCorrected()
public void processFrame(processing.core.PImage img)
throws toxi.video.capture.IncompatibleSizeException
img - image to be processed as frame
IncompatibleSizeException, - if image size differs from buffer's
toxi.video.capture.IncompatibleSizeException
public void setBackground(processing.core.PImage img)
throws toxi.video.capture.IncompatibleSizeException
processFrame(PImage)
img - image to be used as background buffer
toxi.video.capture.IncompatibleSizeException - if image has different size than buffers.
public void setCorrectionPointID(int id,
int x,
int y)
id - index of the point to be set (0 = top-left, 1 = top-right, 2 =
bottom - right, 3 = bottom - left)x - point's x coordinatey - point's y coordinatepublic void stop()
public void useCorrection(boolean state)
setCorrectionPointID(int, int, int)
state - true, if frames are to be stretched
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||