/* * LibCV example: analyzing difference frames * * Here we compute an avarage change factor using the autogenerated difference frames * the window will flash red if there's at least 5% change between 2 consecutive frames * * Make sure you edit the CAPTURE_DEVICE string and frame sizes to match your camera/input * LibCV currently requires the Sun Java Media Framework installed * * If your device description is correct but you're receiving an error message, please * re-run the JMFRegistry application and choose "Detect Capture devices" to revalidate * * If you're unsure where to get the device descriptor from, uncomment the line containing * listDevices() in the setup() method to print out information about all currently * recognized capture devices. * * Please consult the javadoc of this library for more information * http://toxi.co.uk/p5/libcv/ * * @author: Karsten Schmidt < i n f o -[ a t ]- t o x i . c o . u k > */ import toxi.video.capture.*; String CAPTURE_DEVICE = "vfw:Microsoft WDM Image Capture (Win32):1"; int CAPTURE_WIDTH = 160; int CAPTURE_HEIGHT = 120; SimpleCapture capture; LibCV libcv; float indicator; void setup() { size(100,100); capture = new JMFSimpleCapture(); //JMFSimpleCapture.listDevices(System.out,true); if (!capture .initVideo(CAPTURE_DEVICE, CAPTURE_WIDTH, CAPTURE_HEIGHT, 0)) { println(capture.getError()); // you might have to (re-)run the JMFRegistry application // devices sometimes are unrecognized System.exit(0); } libcv = new LibCV(this, capture); } void draw() { try { libcv.processFrame(libcv.getFrame()); PImage dbuf=libcv.getDeltaBuffer(); // compute an average change factor of the current delta buffer float sum=0; for(int i=0; i 0.05) { indicator=255; } else { indicator*=0.995; } fill(indicator,0,0); rect(0,0,width,height); } catch (IncompatibleSizeException e) { e.printStackTrace(); } } public void stop() { libcv.stop(); // automatically takes care of capture object too super.stop(); }