Hey guys,
I tried playing around with this patch to try and figure out what's going on (I don't really do video in Pd, so pdp is pretty foreign to me), so I'll just throw into this conversation a few things I've noticed. First, the problem with [pdp_mgrid] spitting out 1-10 is probably because you're forgetting to send that [50( message to it. Hook a [loadbang] up to it so that it happens automatically when the patch opens.
Also, I messed with this using my webcam, and it seems to jump around somewhat erratically. (This, by the way, is after using some of Arif's most recent suggestions. I didn't implement the specific coordinate thing, though, because I'm not exactly sure what you want to do with it, and it seems the 1-5 and 10-50 thing may be solving that problem for you anyway...?) My guess is that [pdp_mgrid] is sending out information for every cell that's detecting movement, and with a resolution of 50 it makes sense that many cells are detecting movement at once. This is going to make it harder to detect the direction accurately, as it will likely jump back and forth. Raising the threshold helped somewhat. Also, I played around with using cyclone's [mean] to accumulate x-coordinates and compute the average, with the assumption that the most active cells would be spit out more often. I don't know if this is the best way to go about it, but it seemed to help, though it will take some tweaking to figure out a good balance with the threshold and the number of x-coordinates to average. Here's how I set it up:
[inlet x-coordinates]
|
| [r clearit]
| |
| [clear(
|/
[mean] <-left outlet spits out average, right is number of numbers accumulated
| /
| [sel 20] <-set argument to the number of x-coords you want to average
\ /\
X
/ \
[ f ]
|
[outlet x-average]
I had the outlet go to the direction subpatch. Hope that helps at all.