Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
takuya.tatsui
takuya.tatsui's Profile
1
Posts
4
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
I'm sorry in poor English.I want to draw a picture on the trajectory of the light.
[9 Replies]
03-Jul-2013 03:01 AM
Forum:
Core Library Questions
Please Help I'm in trouble if there is no time.
I want to draw a picture on the trajectory of the light. Please tell me how someone.
Drawing, such as a combination of these codes is an ideal.
I want to replace the "brightness tracking" and "mouse tracking".
I do not know what to do this destination.
This is the youtube video of reference.
do want to make the brightness tracking of this.
http://www.youtube.com/watch?v=UmAgE5i8eEY
//////////////////////////////////
/**
* Brightness Tracking
* by Golan Levin.
*
* Tracks the brightest pixel in a live video signal.
*/
import processing.video.*;
Capture video;
void setup() {
size(640, 480);
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height);
video.start();
noStroke();
smooth();
}
void draw() {
if (video.available()) {
video.read();
image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = 0; // X-coordinate of the brightest video pixel
int brightestY = 0; // Y-coordinate of the brightest video pixel
float brightestValue = 0; // Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
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
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float pixelBrightness = brightness(pixelValue);
// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if (pixelBrightness > brightestValue) {
brightestValue = pixelBrightness;
brightestY = y;
brightestX = x;
}
index++;
}
}
// Draw a large, yellow circle at the brightest pixel
fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 200, 200);
}
}
//////////////////////////////////////////////
final int num = 50;
int[] x = new int[num];
int[] y = new int[num];
void setup()
{
size(800, 600);
smooth();
}
void draw()
{
background(0);
// Shadow
// stroke(160);
// for(int i = 0; i < num - 1; i++)
// {
// strokeWeight(i + 1);
// line(x[i] + 10, y[i] + 10, x[i + 1] + 10, y[i + 1] + 10);
// }
// Outline
stroke(0);
for(int i = 0; i < num - 1; i++)
{
strokeWeight(i + 10);
line(x[i], y[i], x[i + 1], y[i + 1]);
}
// Fill
stroke(255);
for(int i = 0; i < num - 1; i++)
{
strokeWeight(i + 1);
line(x[i], y[i], x[i + 1], y[i + 1]);
}
}
void mouseMoved()
{
for(int i = num - 1; i > 0; i--)
{
x[i] = x[i-1];
y[i] = y[i-1];
}
x[0] = mouseX;
y[0] = mouseY;
}
«Prev
Next »
Moderate user : takuya.tatsui
Forum