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 :)
(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?
----------begin_max5_patcher---------- 647.3oc2X1saaBCEG+ZxSgkuNKxluLz6l1E6EXWjpopIB3l3tfMBLZIqpu6C af1zFBPFKNZQQAKN9f8+yuiOXfmmYAWI1QKff6.eGXY87LKKsIkAqlysfoQ6 h2FUncClRKJhVSgyq6SR2I01sC8.91.GLA3gZ6kWlx3aoR8kZ2X7QAWVv9MU YCiVfdyWQor0YbiUVhdzEqd5SAAsCasex8YzZkCgfGZ5JKRFugwW+ibZrrtW mvp4.Xi8UMXm.cCYA50qQIHdTpdvfegxkk46AeUH2vhgJOdY1L0g4ijPb5up j6Q.JKJ9m.T8uN4i6T4i6eIevZhD3dXS3kiOwhzzpA4H.8M4FJHMJKqRdf8h R.mRStCTQHvxJ66.2OGnaWpscemPDeNPD0ADcf8PJhlMd15ET93qEozv3hD9 jvdBebnmNhw5BpfqZ3u7xj8Q8E9tjCB+56pbUB+K1heRPOgePcx2Vu32w+ZF 8WljOgLbouoh9Jwthl2aXJyYEwQa0yHZQXWAOdgWnGNfzIArOl.tnStCBSkJ .vUQ708tYBNPWWDp2k0UyIazo3zmyYQa+OBO3oiGWrIvS2OARIu8YPFe8yYy H6gXjpYDHxm71wamUPdSdED4Ft9xexzw4Vu7hL0xKGiTc0MgdhIW7HimrRTx SJ9GQImioj2o2GSgH8+gYTy6M1zLdHocCtkw+3KVqmIk82StBQYdbq9ZuGJ. +5rkPKjLdjjI3G5TULBdSRaXIIT9gOYSJKISTsZnQDfG5LOdVZBMjlvFUSpz 7vbx1rbhLFM4YdMMXty274tA0DwrbxeDZR8UVLolPiUSXyoI7X0js4zj2X0j iwzzGVpbBMELgbW0IuL6O349F.E -----------end_max5_patcher-----------
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.