DirectShow Capture with Dsj
in
Contributed Library Questions
•
9 months ago
Hello I found this class which is an implementation of humatic dsj for processing here
http://www.magicandlove.com/blog/2012/04/10/directshow-for-processing/ and it is very useful to capture my camera with processing. But if i run the sample code after some seconds I will get an "OutofMemory" error.
So has someone an solution for me to fix this Problem ? I'm not very experienced int programming with processing.
Here is the Code
The DCapture class that performs video capture with the available webcam
void setup ( ) {
size ( 640, 480 ) ;
background ( 0 ) ;
cap = new DCapture ( ) ;
}
void draw ( ) {
image (cap. updateImage ( ), 0, 0, cap. width, cap. height ) ;
}
So has someone an solution for me to fix this Problem ? I'm not very experienced int programming with processing.
Here is the Code
The DCapture class that performs video capture with the available webcam
import de.humatic.dsj.*;
import java.awt.image.BufferedImage;
class DCapture implements java.beans.PropertyChangeListener {
private DSCapture capture;
public int width, height;
DCapture()
{ DSFilterInfo[][] dsi = DSCapture.queryDevices();
capture = new DSCapture(DSFiltergraph.DD7, dsi[0][0], false, DSFilterInfo.doNotRender(), this);
width = capture.getDisplaySize().width;
height = capture.getDisplaySize().height;
}
public PImage updateImage()
{
PImage img = createImage(width, height, RGB);
BufferedImage bimg = capture.getImage();
bimg.getRGB(0, 0, img.width, img.height, img.pixels, 0, img.width);
img.updatePixels();
return img;
}
public void propertyChange(java.beans.PropertyChangeEvent e)
{
switch (DSJUtils.getEventType(e)) { }
}
}
Sample code that uses the DCapture class
DCapture cap ;void setup ( ) {
size ( 640, 480 ) ;
background ( 0 ) ;
cap = new DCapture ( ) ;
}
void draw ( ) {
image (cap. updateImage ( ), 0, 0, cap. width, cap. height ) ;
}
1