1

I'm tracking various colored balls in OpenCV (Python) in real-time. The tracking is very stable. i.e. when stationary the values do not change with more then 1 / 2 pixels for the center of the circle.

However i'm running into what must surely be a well researched issue: I need to now place the positions of the balls into an rougher grid - essentially simply dividing (+ rounding) the x,y positions.

e.g.

input range is 0 -> 9 
target range is 0 -> 1  (two buckets)

so i do: floor(input / 5)

input:  [0 1 2 3 4 5 6 7 8 9] 
output: [0 0 0 0 0 1 1 1 1 1]

This is fine, but the problem occurs when just a small change in the initial value might result it to be either in quickly changes output single I.e. at the 'edge' of the divisions -or a 'sensitive' area.

input: [4 5 4 5 4 5 5 4 ...]
output:[0 1 0 1 0 1 1 0 ...]

i.e. values 4 and 5 (which falls withing the 1 pixel error/'noisy' margin) cause rapid changes in output.

What are some of the strategems / algorithms that deal with these so help me further?

I searched but it seems i do not how to express the issue correctly for Google (or StackOverflow).

I tried adding 'deadzones'. i.e. rather then purely dividing i leave 'gaps' in my ouput range which means a value sometimes has no output (i.e. between 'buckets'). This somewhat works but means i have a lot (i.e. the range of the fluctuation) of the screen that is not used...

i.e.

input =  [0 1 2 3 4 5 6 7 8 9]
output = [0 0 0 0 x x 1 1 1 1]

Temporal averaging is not ideal (and doesn't work too well either) - and increases the latency.

I just have a 'hunch' there is a whole set of Computer / Signal science about this.

hobbit_be
  • 196
  • 1
  • 5
  • 4
    I guess the term you're looking for is [hysteresis](https://en.wikipedia.org/wiki/Hysteresis) – Dan Mašek Oct 25 '17 at 15:41
  • In your example of `[4, 5, 4, 5, ...]` => `[0, 1, 0, 1, ...]`, what is the output that you'd want? – alkasm Oct 25 '17 at 16:45
  • Implement the "dead zone" concept with three possible outputs: 0, 1, and "no change". – Prune Oct 25 '17 at 16:56
  • 1
    @Dan: indeed hysteresis - the magic word. Alexander: indeed there is no 'correct' way to get the 'output' - i was looking for a technique dealing with this situation (i.e. proven examples). i.e. not a 'pure function' solution. Prune: that is a much cleaner explanation and very easy to implemented while still providing an output... will implement this and together with Dan's key wording look for the best way. – hobbit_be Oct 26 '17 at 13:59
  • 1
    Thx to Dan quickly found more depth: in https://stackoverflow.com/questions/10404676/hysteresis-round-to-solve-flickering-values-due-to-noise and https://stackoverflow.com/questions/13990583/how-to-prevent-series-of-integers-to-have-the-same-value-to-often – hobbit_be Oct 26 '17 at 14:07

0 Answers0