We are about to switch to a new forum software. Until then we have removed the registration on this forum.
...basically I want to go on with a tutorial I found. My aim is to draw a continous curve by capturing light(brigthness) via the webcam. The problem I have at the moment is that the drawn ellipse is always refreshed, so I don't see a curve but just a circle... Thanks!
import processing.video.*;
Capture cam;
int x,y;
void setup (){
size (640,480);
frameRate (30);
background (0);
printArray (Capture.list()); //choose Webcam, change according the size!
//cam = new Capture (this, 640,480, "Logitech QuickCam Express/Go",30);
cam = new Capture (this, 640,480, "Integrated Camera",30);
cam.start();
}
void draw (){
if (cam.available()){
cam.read();
cam.loadPixels();
float maxBri = 0.0;
int theBrightPixel=0;
for (int i=0; i<cam.pixels.length; i++){
if(brightness(cam.pixels[i]) > maxBri){ //find the brightest
maxBri = brightness (cam.pixels[i]);
theBrightPixel =i; //store id of brightest pixel
}
}
x= theBrightPixel % cam.width; //find x with modolo
y= theBrightPixel /cam.width; //find y with int, row
}
image (cam,0,0);
fill (255,0,0);
ellipse (x,y,20,20);
}
Answers
can't read your code.
edit post, highlight code, press ctrl-o
this will replace the entire contents of the screen with the image from the camera. which isn't what you want.
you can either remember all the positions of the ellipses and redraw them (ArrayList) or blend the camera image with the current image, keeping the bright spots. (blend())
thanks for your answer, and sorry for my messed up code-post... since i am interested in exporting the data to illustrator, i think redrawing with ArrayList would be the better way. but i am really not sure how to do this...