# Computer vision brightness or colour tracking

**URL:** <https://discourse.processing.org/t/computer-vision-brightness-or-colour-tracking/19811>\
**Category:** Libraries\
**Created:** [April 15, 2020, 6:54pm UTC](https://discourse.processing.org/t/computer-vision-brightness-or-colour-tracking/19811 "2020-04-15T18:54:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maddyna](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@maddyna](https://discourse.processing.org/u/maddyna)\
**Post date:** [April 15, 2020, 6:54pm UTC](https://discourse.processing.org/t/computer-vision-brightness-or-colour-tracking/19811/1 "2020-04-15T18:54:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 19, 2020, 7:25pm UTC](https://discourse.processing.org/t/computer-vision-brightness-or-colour-tracking/19811/2 "2020-04-19T19:25:09Z")

</div>

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.

```auto
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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![maddyna](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@maddyna](https://discourse.processing.org/u/maddyna)\
**Post date:** [April 20, 2020, 9:26am UTC](https://discourse.processing.org/t/computer-vision-brightness-or-colour-tracking/19811/3 "2020-04-20T09:26:13Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 20, 2020, 9:53am UTC](https://discourse.processing.org/t/computer-vision-brightness-or-colour-tracking/19811/4 "2020-04-20T09:53:31Z")

</div>

Perhaps try:

1. the `pmouseX` reference page [https://processing.org/reference/pmouseX.html](https://processing.org/reference/pmouseX.html)
2. the continuous lines example [https://processing.org/examples/continuouslines.html](https://processing.org/examples/continuouslines.html) and pattern example [https://processing.org/examples/pattern.html](https://processing.org/examples/pattern.html)
3. the interactivity tutorial [https://processing.org/tutorials/interactivity/](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.
