Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
francescoventi3
francescoventi3's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
brightness tracking by golan levin (Restart)
[1 Reply]
23-Sep-2013 02:42 AM
Forum:
Core Library Questions
hello guys I wanted to ask how could I do to restart this program through keyboard or mouse. thanks
this i code:
import processing.video.*;
Capture video;
int threshold = 225 ;
int pixelSize = 1 ;
void setup() {
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 30);
noStroke();
smooth();
fill(0, 0, 0, 255);
rect(0, 0, width, height) ;
}
void draw() {
if (video.available()) {
video.read();
// image(video, 0, 0, width, height); // Draw the webcam video onto the screen
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
// Get the color stored in the pixel
color currColor = video.pixels[index];
int pixelValue = video.pixels[index];
float pixelBrightness = brightness(pixelValue);
if( pixelBrightness > threshold ) {
int currR = (currColor >> 16) & 0xFF; // Like red(), but faster
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
fill(currR, currG, currB, pixelBrightness);
ellipse(x - (pixelSize/2) , y - (pixelSize/2), pixelSize, pixelSize);
}
index++;
}
}
}
}
«Prev
Next »
Moderate user : francescoventi3
Forum