Processing Library Tutorial: JMyron

import JMyron.*; JMyron theMov; int[] currFrame; int[] prevFrame; int tolerance; boolean revealing; void setup() { size(320, 240); theMov = new JMyron(); theMov.start(width, height); theMov.findGlobs(0); // initialize the pixel arrays to avoid a NullPointerException loadPixels(); currFrame = prevFrame = pixels; tolerance = 15; revealing = true; } void draw() { // erase the previous image background(255); theMov.update(); // save the last frame before updating it prevFrame = currFrame; currFrame = theMov.image(); // draw each pixel to the screen only if its change factor is // higher than the tolerance value loadPixels(); for (int i=0; i < width*height; i++) { if (comparePixels(i)) { pixels[i] = currFrame[i]; } } updatePixels(); } boolean comparePixels(int index) { if (Math.abs(red(currFrame[index])-red(prevFrame[index])) < tolerance) if (Math.abs(green(currFrame[index])-green(prevFrame[index])) < tolerance) if (Math.abs(blue(currFrame[index])-blue(prevFrame[index])) ‘) { // increase tolerance tolerance += 2; } else if (key == ‘,’ || key == ‘<‘) { // decrease tolerance tolerance -= 2; // toggle the revealing mode } else if (key == ‘ ‘) { revealing = !revealing; } } public void stop() { theMov.stop(); super.stop(); }

via Processing Library Tutorial: JMyron.

Advertisements

About ege's press.

Few things. I'm lizard king i can do anything. Let's start this shit. mpla mpla mpla de mas pernei gia polla. (greeklish) System learn greeklish. Learn to use your Keyboard shortcuts makes your life easier.Inside time άλλωστε... εμείς είμαστε ...
This entry was posted in Coding and tagged , . Bookmark the permalink.

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