processing:video_capture
This is an old revision of the document!
Table of Contents
Video Capture Examples
The following have been adapted from the Processing 2.0 library reference and from examples at Learning Processing.
List available capture devices
- list_capture_devices.pde
/** Print out a list of available capture (i.e., video) devices * @author Mithat Konar */ import processing.video.*; Capture cam; void setup() { String[] cameras = Capture.list(); if (cameras.length == 0) { println("There are no cameras available for capture."); exit(); } else { println("Available cameras:"); for (int i = 0; i < cameras.length; i++) { println("camera " + i + ": " + cameras[i]); } } }
Show Video
By requesting capture parameters:
- show_capture_by_parameters.pde
/** Show video using requested capture parameters * @author Mithat Konar */ import processing.video.*; Capture cam; final int CAM_WIDTH = 320; final int CAM_HEIGHT = 240; final int FPS = 15; void setup() { size(CAM_WIDTH, CAM_HEIGHT); if (Capture.list().length == 0) { println("There are no cameras available for capture."); exit(); } // instantiate a new Capture object, reqesting the specs: cam = new Capture(this, CAM_WIDTH, CAM_HEIGHT, FPS); cam.start(); // In Processing 2.0, you need to start the capture device } void draw() { if (cam.available() == true) { cam.read(); } image(cam, 0, 0); }
processing/video_capture.1365725568.txt.gz · Last modified: 2013/04/12 00:12 by mithat