Tracking brightest point to create line

After getting the brightest pixel and the coordinates I intend to draw a line tracing the subsequent brightest point as the light source moves around eg the way we create tracelines using pmouseX and mouseX
is thr a way to do that by putting the brightest points into an array
if so how i do that or any other ways
I am putting the code below

import processing.video.*;
Capture video;

void setup(){
  size(640,480);
  video=new Capture(this,640,480);
  video.start();  
}

void draw(){

  if(video.available()){
    video.read();  
  }

  video.loadPixels();
  image(video,0,0);
  float brighty=0;
  int Ax=0;
  int Ay=0;
  
  for(int x=0;x<video.width;x++){
    for(int y=0;y<video.height;y++){
      int loc=x+y*video.width;
      float cBright=brightness(video.pixels[loc]);
      if(cBright>brighty){
        brighty=cBright;
        Ax=x;
        Ay=y;

      }  
    }  
  }
  println(Ax,Ay);
  
  updatePixels();
}
1 Like

You can try ArrayList<PVector> brights and then each frame save brights.add(new PVector(Ax, Ay));

To draw your line, you can loop over brights starting at 1 and compare to the previous index to get two points for each line segment – or you can just draw the points one at a time using vertex().