thisisnotlondon
YaBB Newbies
Offline
Posts: 2
passing live video as variable
May 27th , 2005, 7:44am
From: dylan@thisisnotlondon.com Subject: how to i set the video input to equal a variable in processing Date: 27 May 2005 3:04:31 PM To: glen@glenmurphy.com i need to declare the camera input as the video variable but not sure how I have this which grabs my video import processing.video.*; Capture myCapture; void setup() { size(320, 240); String s = "QuickCam"; myCapture = new Capture(this, s, width, height, 30); } void captureEvent(Capture myCapture) { myCapture.read(); } void draw() { image(myCapture, 0, 0); } and this which analyses it import processing.video.*; int video_width = 320; int video_height = 240; int num_pixels = (video_width * video_height); //------------------------------------------- void setup(){ size(320, 240); beginVideo(video_width, video_height, 30); } //------------------------------------------- void loop(){ int black = color(0,0,0); // Declare some constants for colors. int white = color(255,255,255); int threshold = 127; int pix_val; // Declare variables to store a pixel's color. float pix_bri; // Split the image into dark and light areas: for (int i=0; i<num_pixels; i++){ // For each pixel in the video frame, pix_val = video.pixels[i]; // fetch the current color in that location, pix_bri = brightness (pix_val); // and compute the brightness of that pixel. if (pix_bri > threshold){ // Now "binarize" the video into black-and-white, pixels[i] = white; // depending on whether each pixel is brighter } else { // or darker than a threshold value. pixels[i] = black; } } // Test a location to see where it is contained. int test_val = get (mouseX, mouseY); // Fetch the pixel at the test location (the cursor), float test_bri = brightness (test_val); // and compute its brightness. if (test_bri > threshold){ // If the test location is brighter than threshold, fill (255,0,0); // draw a RED ellipse at the test location. ellipse (mouseX-10, mouseY-10, 20,20); } else { // Otherwise, fill (0,255,0); // draw a GREEN ellipse at the test location. ellipse (mouseX-10, mouseY-10, 20,20); } } I just cant figure out how to get the two parts to talk to each other..all help appreciated Dylan