We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › newbie Brightness Tracking
Page Index Toggle Pages: 1
newbie Brightness Tracking (Read 138 times)
newbie Brightness Tracking
Mar 3rd, 2009, 11:43pm
 
(I'm sure this has been asked and answered before, please forgive the redundancy.)

I need to adapt the brightness tracking example sketch to track more than one point (any past a specified threshold).

As I see it, the key issue is here:

for (int y = 0; y < video.height; y++) {
     for (int x = 0; x < video.width; x++) {
       int pixelValue = video.pixels[index];
       float pixelBrightness = brightness(pixelValue);
       if (pixelBrightness > brightestValue) {
         brightestValue = pixelBrightness;
         brightestY = y;
         brightestX = x;
       }
       index++;
}

I'm guessing that instead of getting a single set of x,y values, I'd declare an array, which creates an ellipse (or whatever) at every pixel past the threshold, and then reference any given ellipse with a for() statement like any array element.

If it's easier, I'm content to limit the tracking to, say, the top 5 brightest points, if it means I can just assign a set list of 5 ellipses to the five brightest points.

As this is just rudimentary blob tracking (I'd rather not go through TUIO and touchlib if I can help it), I'm also curious as to how to include/discount blocks of multiple adjacent pixels.

A free beer for the best answerer if you live in my city!
Page Index Toggle Pages: 1