RGB video meter

source code:
// Lina Maria Giraldo
// homework week 7 based on example 16.1 15.7 17.1
// http://www.linamariagiraldo.com
// Declare PFont variable
PFont f;
// Step 1. Import the video library
import processing.video.*;
// Step 2. Declare a Capture object
Capture video;
void setup() {
size(320,240);
smooth();
// Step 3. Initialize Capture object via Constructor
// video is 320 x 240, @15 fps
video = new Capture(this,320,240,15);
//Load Font
f = loadFont( "font.vlw" );
}
void draw() {
// Check to see if a new frame is available
if (video.available()) {
// If so, Step 4. Read the image from the camera.
video.read();
}
// Display the video image.
image(video,0,0);
int loc = (width/2)+((height/2)*width);//find the pixel in the middle of the scree
video.loadPixels();//we can modifie the pixels
float r = red (video.pixels [loc]);//find the values of red green and blue
float g = green (video.pixels [loc]);
float b =blue(video.pixels [loc]);
textFont(f,32); // Specify font to be used
fill(255,0,0); //Specify font colora
text ( "R=" + r ,10,40); // Display Text
fill(0,255,0); //Specify font color
text ( "G="+ g ,10,100); // Display Text
fill(0,0,255); //Specify font color
text ( "B="+ b ,10,160); // Display Text
noFill();
stroke(0);
ellipse(width/2,height/2,10,10);
stroke(255);
ellipse(width/2,height/2,13,13);
}
Leave a Reply
You must be logged in to post a comment.