Computer vision brightness or colour tracking

while doing color tracking using the camera as a sensor is thr a way to get a continuous line as you move the tracker around
the way i am doing is using an ellipse to follow the tracker but am not getting a continuous line

Would be very obliged if somebody can suggest
thanks

1 Like

Sharing code will help you get better advice.

If your tracker is giving you x,y each frame, then create a px, py from the previous frame. Let’s say the tracker is jumping around at random, and we want a line.

void setup() {
  size(400,400);
  strokeWeight(3);
  frameRate(3);
}
void draw() {
  float x = random(width);
  float y = random(height);
  ellipse(x, y, 10, 10);
}

Save the previous point at the end of each frame. Now each frame draw a line between previous and current point.

float px;
float py;
void setup() {
  size(400,400);
  strokeWeight(3);
  frameRate(3);
}
void draw() {
  float x = random(width);
  float y = random(height);
  line(px, py, x, y);
  px = x;
  py = y;
}

For the mouse, this is actually why pmouseX and pmouseY are built into Processing.

Thank you so very much
The solution was so simple and the very idea depended on the flow of the program in the loop
I think I got clarity of something which I often overlooked.
Is thr some tutorial (with detailed discussion) that deals with these basics in a very thorough manner more so as my knowledge of java is pretty limited on which processing is built .

1 Like

Perhaps try:

  1. the pmouseX reference page https://processing.org/reference/pmouseX.html
  2. the continuous lines example https://processing.org/examples/continuouslines.html and pattern example https://processing.org/examples/pattern.html
  3. the interactivity tutorial https://processing.org/tutorials/interactivity/

These assume pmousex is implemented – but, as you’ve seen, implementing a previous value is just saving it at the end of the loop. You can do something similar with previous time, previous color, previous click, et cetera.