cv.jit.label reject blobs larger than threshold?

    Nov 01 2010 | 1:09 am
    can someone please share some knowledge to a slight jitter-newbe?
    I would really appreciate all views or suggestions that could help me solve my dilemma.
    I need to track balls on a pool-table, find each balls XY-value and color. Different colors trigger different sounds in the pool-table hole closest to the balls location on the pool-table.
    This is my plan:
    cv.jit.touches track all balls, XY-values are used to cut each blobs matrix (pool-ball size). Matrix sendt to jit.findbounds, color analyzed and given a color-ID connected to cv.jit.touches blob-ID.
    This color-ID stay with the blob-ID until it is lost or a new blob is created, then a new color-check and ID is given.
    This is my problem:
    Pool-cue, players bodies and colors produce problematic blobs in cv.jit.touches. I need a way to remove this "noise" or make less influential.
    jit.qt.grab (320 240, 120 fps matrix) -> jit.rgb2luma ->
    jit.op @op > @val 155 (all balls visible, no noise) ->
    cv.jit.label @charmode 1 @threshold 1 (low setting 2 track all balls) ->
    (here I tried to use jit.op min/max here to remove larger blobs than the pool-balls but could not do it)
    cv.jit.blobs.centroids -> send matrix to cv.jit.touches
    Blobs with smaller area than the "threshold" value will be rejected, how make cv.jit.label reject blobs that are bigger than some threshold value?
    And how should this matrix be sent and accepted by cv.jit.touches to track the blobs > && < than threshold $1 && $2?
    I would be very happy for any information that would help me solve this, I am sorry for not being so intelligent and knowable within jitter.
    Here is an example patch and a screen-shot to use for movie attached.

    • Nov 01 2010 | 8:03 am
      one way to do it would be to look at the third element of the list from cv.jit.blobs.centroid, which is the area. just use split to open and close a gate. I did a quick mockup below.
      Hope I understood correctly and that I am making sense :)
    • Nov 03 2010 | 2:36 am
      Hi MIB and thanks for the answer!
      The mockup-patchs was a great way for me to think correctly,
      it did not help me solve the problem though.
      With an adjusted muchup-patch the list of blobs above a $1 Area-range was rejected. I do not know how to make a single-plane matrix out of the gated float32 list. This, I assume, is what is needed for cv.jit.touches to analyze it correctly?
      I would be very grateful if you could help a Norwegian jitter-newbe understand more MIB!
      Thanks anyway, I love this :)
      Adjusted mockup-patch:
    • Nov 03 2010 | 11:18 pm
      I've never used cv.jit.touches so I can't be too much help there. The problem I see with cv.jit.touches is that the area is always going to be the same. From the helpfile: "The radius is constant and is the same value as specified by the user. It is only provided for convenience."
      So I don't think the two approaches can be combined since once you did the analysis with cv.jit.label, cv.jit.blobs.centroids, you have no more video matrix to work with, you have data about the analysis coming out. unless you take that data and somehow have cv.jit.touches only look at those areas of the video matrix, I don't see how you could do it.
      But I am not overly experienced with Jitter myself. I know a bit, but not enough to say for sure...
      Below is a simplified version of a project I am working on without cv.jit.touches. It's not included here, but I am also looking at the position of each blob and exclude it if it isn't where it is supposed to be (if it is a certain distance from an anchor point, excluded).
      Hope this is still helpful :)
    • Nov 18 2010 | 12:46 pm
      Very interesting patch MIB,
      although I am not capable to see how to use it helpfully in my project,
      I would very much like to thank you for the help you have provided.
      I lack time, so I will get the jit.findbounds based patch to work thoroughly before I work more on the matrix-noise-reduction.
      The next thing might be down noob-alley, but.. ;)
      I have a jit.findbounds question I would be very grateful if you have knowledge to help me solve?
      XY position of two pool-table balls with the same color are tracked using
      jit.findbounds (in this case the Yellow balls):
      min (left & top) = XY for ball nr 1
      max (right & bottom) = XY for ball nr 2
      In some situations (like in the attached pict) min & max has to switch top/bottom values to give correct XY positions in my patch:
      min should be left & bottom,
      max should be right & top.
      I am not clever enough to figure out algorithm or if I need one to solve this. I hope you can give me some hints or advise to lead me in the right direction MIB. I will off course post a Q on the forum too.
      Thanks in advance MIB :)
    • Nov 19 2010 | 12:32 am
      jit.findbounds has no way of knowing whether your pool balls are in their proper places, it'll just output the overall rectangle for where the selected color is. So you'd need to find a way to determine how to make the right changes. one good object for this "inverse mapping" would be [!-] so you can subtract a value from a maximum value and get the difference. In your case you can readily use this to flip the X or Y coordinates from max to min etc.
      Possibly you'll want a different way to track multiple colors/balls than jit.findbounds, like with cv.jit.touches, or by splitting up the matrix and using a jit.findbounds on each.
    • Jan 13 2011 | 4:35 am
      seejayjames: thank you for the info!
      I struggle with this still though, have tried cv.jit.touches, splitting up the matrix in two and still not good enough.
      I wonder if you know a way to differ between to min/max lists following each-other but having values that differ with more than 10?
      n1: [10 10 12 12]
      n2: [40 40 50 50]
      find a way to easily split them when $1 $2 $3 $4 in n1 are +- 10 values
      from $1 $2 $3 $4 in n2. I have tried vexp, div zl objects and if sentences but I am stuck.
      Any suggestions?
    • Jan 13 2011 | 11:29 am
      I can't answer your question but if I had your project I would definitely start with cv.jit.touches into cv,jit,touches.recycle and then unpack iiii from the recycle and then gate #of balls and then unpack i i
      to get the possitions of each blob and map that to sounds
      hope that helps.
      the cv.jit.touches.recycle