Processing, saveFrame or clear it

Evenin’

I had some success yesterday tracking the red end of the Chaos Engine pendulum, the capture is using tracking software on processing. it is based on Brightness Tracking by Golan Levin that is available in the examples that come with the software

As the pendulum swings, the software tracks the end and joins a line between the redest points in the camera’s field of vision. The actual area that the camera needs to cover is quite large, about a metre squared, so capturing it all may require a fish eye lens. Also fixing the camera to the tripod didn’t really work with my usual solution of loads of packing tape, so today i ordered a gorilla to hold it in place, hopefully.

One of the problems i am facing is the printing of the user generated fractal (fingers crossed). So I have adapted  Ira Greenberg’s sketch. It saves the image generated as a jpeg to the sketch folder, from there i can use the Mac’s automator program to take this image and print it out directly, see here. (Ta to Jon for finding that for me)

And also how to automatically upload to a flickr account, here, more Jon thanks due!

So the sketch below, that you can copy into processing to try if you want, uses the mouse to make lines and some lovely blendy stuff too, when you have a screen you want to save press the UP arrow key and it will be saved to your sketch folder. If you press the DOWN arrow it will just clear the screen to start again.

/*
gary smith’s adjusted version of hairy brush drawing
Ira Greenberg, oct 06.
outputs to jpg in sketch folder
*/

void setup() {
size(800,600);
background(255);
smooth();
String id = str(hour())+”_”+str(minute())+”_”+str(second());

}

void draw() {
stroke(random(255), random(255), random(255));
strokeWeight(4);
if (mousePressed){
line(pmouseX, pmouseY, mouseX, mouseY);
bleed(pmouseX, pmouseY);
}
}

void bleed(float x, float y){
float px = 0, py = 0, angle = 0, radius=10;
float brushDetail = 36;
stroke(random(255), random(255), random(255));
strokeWeight(.5);
for (int i=0; i<brushDetail; i++){
px = x+cos(radians(angle))*random(radius);
py = y+sin(radians(angle))*random(radius);
line (x,y,px,py);
angle+=360/brushDetail;
}
}

//press up key to output as jpg
void keyPressed(){
if (key == CODED){
if (keyCode == UP) {

saveFrame(“jpgce-####.jpg”);
background(255);
}
//press down key to clear screen
else if (keyCode == DOWN) {
background(255);
}
}
}

dont know if that can be copied, give it a go and tell me…

cheers then, gs

 

Advertisements
  1. nope, the code seems to be full of “\” that i cannot see. sorry but i cant make it work but i assure you it does if you type it in yourself.

  2. thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: