i was wondering if someone can help me to transform this piece of code. I´m pretty new to coding, so i don´t even know yet if it´s a very difficult question what i´ll ask now....
I found the code for tracking the brightest pixel in a video image, and now i would like to draw a 3d object on that brightest pixel instead of the ellipse.
i imagine the solution like that
maybe i would need a 3d set with the 3d object, then i need a layer and on that layer the video should run searhing for example for the brightest point and then i need a special point of my 3d object to be connected with that brightest point
just i have now clue where to start...
If any of u you has a suggestion it would be wonderful.
thanks a lot Tanja*
import processing.video.*;
Capture video;
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();
}
void draw() {
if (video.available()) {
video.read();
//video.filter(INVERT); // makes the light in the image inverted
image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = 255; // X-coordinate of the brightest video pixel
int brightestY = 255; // 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