Forums > Jitter

Make similar list trigger and calculate +-

Jan 13 2011 | 4:13 am

Min & max XY-value input lists from jit.findbounds to an object like [zl sect]:

1, right input-> [14 28 20 30]
2, left input -> [10 24 40 100]

I need help by an object like [zl sect] or an algorithm to make this of the lists:

1, [14 28] == [10 24] && 14+10/2 & 28+24/2 -> result left output
2, [20 30] != [40 100] -> output right output

and a way to set the variable +- level.
This is my try to use my low-level math knowledge do something very inefficient:

-- Pasted Max Patch, click to expand. --

Any suggestions would be greatly appreciated!


Jan 14 2011 | 12:59 am

I’m not following your explanation. What are you trying to achieve? In the patch you provided you are doing nothing with the 3rd, 4th, 7th and 8th values in the input list. Also your [if] statement phrases make no sense, you are curently outputting the values when an input is equal to, greater than, or lesser than some number, which will be always regardless of the inputs. Could you clarify a bit.

Jan 14 2011 | 2:27 am

I’m sorry I did not make myself understood Luke.

The input is jit.findbounds (FBs) output. FBs is color-tracking two balls of the same color on a pool-table.

FBs mainly makes a overall rectangle of both balls,
but relativly often makes small rectangles (SRec) on each individual ball.
These small rectangles will indicate where the balls are in the overall rectangle (ORec), two choices…

1. left top (or right bottom)
2: left bottom (or right top)

…in the video-matrix.

The patch is a bad attempt to solve my problem of detecting similarity between two lists.

What I really try to solve is,
if values (XY) in a two-value list is +-3 pixel close to two of the four values in another list.


SRec XY: 50 100 (average)
ORec XY: 53 56 123 103

These two lists should detect if balls are
Left Top Right Bottom
Left Bottom Right Top

In the e.g case the balls are Left Bottom Right Top since SRec-$1==ORec$1 && SRec-$2==ORec-$4.

I am trying to learn how to explain easily and understandable, but I have a tendency to make it to thorough. I am sorry if this makes no sense.

Here is where I am at now, I have chosen not to use cv.jit.touches:

-- Pasted Max Patch, click to expand. --


Jan 14 2011 | 10:59 am

The solution is along these lines:
Permutation of possible pairs out of the long list.
Check for the distance to all of these permutations.

You can simplify the distance object to get the difference in pixels for each coordinate, but I guess what you’re really after is the distance…

The whole task smells for a different problem, and you ask here for a solution to a part of your problem and you envision a solution along a certain line (like I split your quest into permutation and distance). Maybe if you tell us what you need this for, there might come out a much easier solution for the big picture…

-- Pasted Max Patch, click to expand. --

Jan 15 2011 | 6:32 am

vanille béchamel: thank you for the patch, if you compare it to mine I look like an idiot :-)

I agree. I will make the big picture visible.

I need to colortrack either one or two balls of the same color by using jit.findbounds (FBs). The balls XY-position on a pool-table (an interactive sound-installation) is the goal. There are speakers in all the six holes, the ball, or ball(s), XY-position decide which speaker(s) will play sound.

This is a precise description of what I wish this patch to do when dealing with a single black ball, probably not possible since it seems unlikely to me, but..

Black ball detecktion:

One list = average of FBs min XY- and max XY-values $1 $2 when XY-min and XY-max is +- 5 from each other.
OneTwo list = FBs min XY- and max XY-values $1 $2 $3 $4

One list = Left/Right Top/Bottom
OneTwo list = Left Top Right Bottom

If One receives 5 lists in a row, where the X- and Y-values are +- 10 from list 1 to list 2, +- 10 from list 2 to list 3, +- 10 from list 3 to list 4 and so on, it becomes active and starts outputting XY-values to envelope(s) of speaker(s).

If One receive 5 more lists in a row with +- 10 X- and Y-values compared to the last received list, it becomes the One’s valid XY-list.
The One’s valid XY-list can be used to check if, or,
which two XY-values from the next OneTwo list are within correct range.

If One receive a list with X- or Y-values +30, or -30, compared to One’s valid XY list, ignore it.
If the next One list is within the +- 10 XY-value range, it stays valid.
If not, it needs a new 5 lists in a row, within X- and Y-values +- 10 range, compared to the previous list, to become One’s valid XY list again. One outputs XY-values to envelope(s) all the time here.

When OneTwo receives a list, FBs has a rectangle that is larger than the area of one ball. Now the stored One’s valid XY list is used to checks if, or, which of OneTwo’s four X or Y-values are +- 10 from One’s valid XY list.

If One’s valid XY list is similar to two of OneTwo’s four XY-values;
output last One XY-value and keep it valid,

If not two of OneTwo’s four XY-values are +- 10 in range of One’s valid XY list;
check if two of OneTwo’s four XY-values are +- 30 in range of One’s valid XY list
if yes output XY-value,


if One then receives next list and it is +- 10 in range of two of the four XY-values of the OneTwo list, it needs 5 lists in a row, within the +-10 value range, to make a new One’s valid XY list.

If One becomes inactive it must become active again to output XY-values to the envelope(s)

OneTwo list permutations:
1. Left Top $1 $2
2. Right Bottom $3 $4
3. Left Bottom $1 $4
4. Right Top $3 $1

I think this should be a big picture stefantiedje.

The chances of solution this is unlikely. I took it as a test to be able to explain it thorough, I hope I did:)
I will be amazed if someone are able to figure it out though, a real challenge!

Here is some of my further vague tries to solve it:

-- Pasted Max Patch, click to expand. --

Jan 15 2011 | 6:20 pm

Yes, vanille béchamel, I try to compute [x, y] coordinates.

Other objects entering the video matrix, like players clothes or the cue, FBs will now and then output a larger overall rectangle than the rectangle that gives the correct [x, y] coordinates of the black 8Ball.

I must remove this "noise", so the sound of the 8Ball player will be output from the hole closest to the 8Ball.

Anyone capable of helping me solve this problem will be mentioned thanked in my master thesis and get a PDF-copy :-)

Jan 15 2011 | 8:42 pm

Hi again!

The video is live, the example will come soon as a very short video

Jan 15 2011 | 9:47 pm

Did you look at the cv.jit collection of objects?
You can also google for blobs and their detection…
I am not that expert in Jitter, but it seems that there is not much need for reinventing wheels…;-)

Good luck


P.S. if this helps, better mention monsieur Pelletier, he is the real genius…;-)

Viewing 8 posts - 1 through 8 (of 8 total)

Forums > Jitter