Hi, I'm (really) new with processing. Can anyone help me with this code? please :) I cannot find why I get unexpected token: void() in this code:
import processing.video.*; Capture webcam; int w=400; int h=400; int pixn=w*h; int keyhits; PImage img; int i= 0
void setup() { size(w, h); webcam = new Capture(this, 400, 400); webcam.start(); loadPixels(); }
void captureEvent(Capture webcam) { webcam.read(); } void draw() { image(webcam, 0, 0); }
void keyPressed() {
if ( key == '1' ) { save("capture" + ++keyhits + ".jpg"); }
img = loadImage("capture"+keyhits+".jpg"); int x = int(img.width); int y = int(img.height); float r = red(img.pixels[i]); float g = green(img.pixels[i]); float b = blue(img.pixels[i]);
for (int i=0; i<pixn; i++) { float sumar = sumar + red(img.pixels[i]); float sumag = sumag + green(img.pixels[i]); float sumab = sumab + blue(img.pixels[i]); }
float mediar = sumar / pixn); float mediag = sumag / pixn); float mediab = sumab / pixn);
if ( key == '2' ) { fill(mediar, mediag, mediab, 255); rect(0, 0, 400, 400); save("average_color"+ keyhits + ".jpg"); } }