Skip to main content
4 of 6
added 800 characters in body
zmo
  • 121
  • 4

How to correlate a matrix of values to get a coordinated point?

I got a n*m matrix updated in realtime (i.e. about every 10ms) with values between 0 and 1024, and I want to work out from that matrix a multitouch trackpad behaviour, which is:

  • generate one or more points on the surface given the values on the matrix,
  • make this or those point as big as the value can be.

For example here is a few lines of a 9x9 matrix updates, and we can consider the following matrix as an example (with a touch in the middle):

[ [ 12,  7,12 ],
  [ 12,129,19 ],
  [ 12, 11,22 ] ]

The goal is to mimic the behaviour of a common touchpad (like on every smartphone, or laptop). So, I'm getting values from a evenly distributed matrix of capacitive sensors on a physical object, which are processed by a microcontroller into a matrix, and I want to get coordinates and weight of one or several points.

The idea would be to get something like this (of course, I don't expect to have more than 2 or 3 detected points, and that level of precision with a matrix that small).

I actually don't have a clue where to begin with, or what kind of algorithm or theory to look for on Internet. I'd be really glad to have pointers to documentation, theory or anything that could put me on the way.

Here are a few example raw logs:

Thinking about my problematic made me consider this idea: I think I should make some kind of interpolation to augment the definition of the matrix, and in some way make the new values additive.

i.e. imagine we have the following matrix :

[ [ 200, 200, 150 ],
  [ 150, 150,  80 ],
  [  80,  80,  40 ] ]

and we want to interpolate it somehow into something that would look like (I'm inventing the values, but it's to expose the idea):

[ [ 200, 400, 200, 175, 150 ],
  [ 175, 200, 175, 150, 125 ],
  [ 150, 170, 150, 125,  80 ],
  [ 100, 125, 100,  80,  60 ],
  [  80,  80,  80,  60,  40 ] ]

Of course, I'm sure that very smart people have thought about that kind of problematic and there are maths I can use to do that, I just don't know about it...

zmo
  • 121
  • 4