Findbounds; swap top & bottom in min & max output

Nov 18, 2010 at 1:17pm

Findbounds; swap top & bottom in min & max output

Hi everyone, this might be down noob-alley, but.. ;)

I have a jit.findbounds question I'd be very grateful get help me solve.

I need XY position of two pool-table balls, with the same color. They are tracked using jit.findbounds (see pict, where the yellow balls are tracked).

Normally it gives correct tracking since,
min (left & top) = XY for ball nr 1,
max (right & bottom) = XY for ball nr 2.

In some situations (see pict) min & max needs to swap top & bottom values for XY positions to be correct in my patch.
In this case min should be left & bottom, while max should be right & top.

I do not know how jit.findbounds analyze the colors it outputs through the min & max output, other than it is left/top & right/bottom values.
I would like min to be: left/top or bottom
and max to be: right/top or bottom so I could use the min/max output as XY values.
The swapping gives my color-tracking mirrored results some times.

Unfortunately I am not clever enough to figure out an algorithm (or if I need one) to solve this. I hope someone more intelligent and with more Jitter knowledge can give me some hints or advise.

I thanks you for the help in advance :)

Sturla

[attachment=146439,1411]

Attachments:
  1. Screen_shot_2010-11-18_at_12.54.42.png
#53398
Nov 19, 2010 at 11:54am

(my humble attempt)
This might be an obvious answer…in this patch I simply swapped the values given by [jit.findbounds]. The problem is of course that if you want to use this values in [jit.lcd], [jit.lcd] needs the values in the “normal” way (left top right bottom) in order to draw rectangles.
What do you intend to do with this new swapped coordinates? they will be just data, or you want to draw them on a window for example?

– Pasted Max Patch, click to expand. –
#192099
Nov 20, 2010 at 11:09pm

Thank you for the suggestion Beatriz.

I will use the swapped values to detect what Y-value the left and the right ball has. The jit.findbounds min & max output gives me correct XY-values when the left ball is situated in the matrix with a higher Y-value than the right ball. When the left ball has a lower Y-value than the right ball only the X-values are correct. I need to be able to swap the Y-values then to get the correct XY-values for the balls.

It would be great if someone knows how to prevent this “mirror” min/max y-value view.

#192100

You must be logged in to reply to this topic.