asquare
YaBB Newbies
Offline
Posts: 36
writing classes
Mar 11th , 2007, 11:18pm
Hello Starting to create a small application in processing which uses video and this is the first time I really need to start splitting things into classes, the first I need being a webcam capture class. Here is the main sketch invoking the class: Webcam_capture v_camimage; void setup() { size(640, 480, P3D); background(255); v_camimage = new Webcam_capture(); } and here is the class: class Webcam_capture { import processing.video.*; PApplet p; Capture v_capture; PImage v_image; int v_width, v_height, v_xpos, v_ypos; Webcam_capture() { //dv video name String webcam = "IIDC FireWire Video"; //width and height stored as a variable v_width = 318; v_height = 256; //capture the camera v_capture = new Capture(p, webcam, v_width, v_height); v_capture.framerate(30); //calculate position for video on screen according to window size and video size v_xpos = (width / 2) - (v_width / 2); v_ypos = (height / 2) - (v_height / 2); } //capture event function void captureEvent(Capture v_capture) { //read the latest image from the capture event v_capture.read(); } //draw function (this loops - like an exitframe in director) void draw() { //set the image to be the latest image from capture event v_image = image(v_capture, v_xpos, v_ypos); return v_image; } } I seem to be mainly getting a problem with the line: v_capture = new Capture(p, webcam, v_width, v_height); in my original webcam capture sketch I have this where p is, here I've copied it from an example I found online but I expect there are several issues, can anyone point me in the right direction? a+ gar