multi-touch-dev team mailing list archive
-
multi-touch-dev team
-
Mailing list archive
-
Message #00146
Re: Touch analysis
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Side note: I put up a new version of hid-ntrig.c
http://ofb.net/~rafi/2010_05_04_hid-ntrig.c
Cleans up the filtering code to fix a faulty state machine design. I did
finally send in the patches and am awaiting feedback. We should probably get
Mark to update as well, if he's trying the previous version (which did improve
sensitivity but didn't give as much control over the filtering as intended).
ok, grab a fresh copy, it should be a lot more interesting.
Added some pretty trivial tracking just using the Rect collision detection.
Inspired by one of the devices that was talked about on the linux-input mailing
list, this version keeps old contacts, so if you put your finger down where you
stopped, it will consider it a continuation. New contacts are given a new
randomly generated color. (er, probably just best to see for yourself).
The evdev.py file is something I found online and updated some of the aging
tables, and added a threaded listener with callbacks. Anyway, that file doesn't
do all that much, its close to equivalent of the c code:
rd = read(fd, ev, sizeof(struct input_event) * 64);
with the addition of converting the event codes to strings, which match the
#defines from input.h. I'm sure its a pretty bloated way to do that, but it was
just there, and this is only intended to be a prototype/toy.
Anyway, that file does have a main, and it acts pretty close to the
"input-event" utility if you run it on an event device.
Most of the code is infrastructure. The interesting bits are actually pretty
small. Once you enter drawing mode, a thread listens for events from the device
and calls mt_event for each.
def mt_event(event):
global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_maj, mt_min,
mt_orient,last_frame, current_frame,last_seen
if event.type == 'EV_ABS':
if event.code == 'ABS_MT_POSITION_X':
mt_x = mt_scale_x * event.value
elif event.code == 'ABS_MT_POSITION_Y':
mt_y = mt_scale_y * event.value
elif event.code == 'ABS_MT_TOUCH_MAJOR':
mt_maj = event.value
elif event.code == 'ABS_MT_TOUCH_MINOR':
mt_min = event.value
elif event.code == 'ABS_MT_ORIENTATION':
mt_orient = event.value
elif event.type == 'EV_SYN':
if event.code == 'SYN_MT_REPORT':
current_frame.append(mt_contact(mt_x,mt_y,mt_maj,mt_min,mt_orient))
elif event.code == 'SYN_REPORT':
track()
mt_x = mt_y = -1
#last_frame = current_frame
for c in current_frame:
ellipse(screen, c.color, c)
last_seen[c.track_id]=c
pygame.display.flip()
current_frame = []
And the tracking code is just:
def track():
global last_frame, current_frame,next_id,last_seen
looking = list(current_frame)
old = list(last_seen.values())
for c in looking:
i = c.collidelist(old)
if i >= 0:
c.track_id = old[i].track_id
c.color = old[i].color
old.__delitem__(i)
looking = filter(lambda x: x.track_id < 0,looking)
for c in looking:
c.track_id = next_id
c.color = Color( randint(0,255), randint(0,255), randint(0,255))
next_id+=1
As I said, just quick and dirty.
Er, so how does one save a drawing from pygame? I feel like I should be posting
some pictures, and give my web pages a bit of that "drawn by a child" look.
Cheers,
Rafi
On 05/07/10 03:02, Bryce Harrington wrote:
> On Sun, Apr 11, 2010 at 07:55:43PM -0400, Rafi Rubin wrote:
>> Added crude mt finger painting.
>>
>> Same url: http://ofb.net/~rafi/ts_test.tgz
>>
>> For multitouch mode run: ./ts_test -mt_dev /dev/input/eventNN
>>
>> Its really nothing fancy (not meant to be), but for some of you, this may be the
>> first time you actually mt do anything.
>
> This is pretty darn sweet.
>
>> Please excuse the sloppy code, I'm still experimenting to decide how to
>> code up a testing framework. In this case I just started from
>> testsprite.py from the pygame examples.
>
> I did some minor tidying (see attached).
>
>> When I get a chance, I'll add tracking and then assign a different color to each
>> finger, and then we can start talking about what the hardware might be good for.
>
> I'd love to see this if you do get a chance. I took a look at doing
> this myself but the evdev.py was a bit beyond me.
>
> Thanks,
> Bryce
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkvkAnAACgkQwuRiAT9o60+GQgCfb9r+8R/5B+K6fYGrFBzWvVbF
lmQAoLY5MwulppO9ii36bDYLhquxTvXm
=26bZ
-----END PGP SIGNATURE-----
Follow ups
References
-
n-trig updates
From: Rafi Rubin, 2010-03-31
-
Re: n-trig updates
From: Stéphane Chatty, 2010-04-01
-
Re: n-trig updates
From: Duncan M. McGreggor, 2010-04-07
-
Re: n-trig updates
From: Stéphane Chatty, 2010-04-07
-
Re: n-trig updates
From: Andy Whitcroft, 2010-04-09
-
Re: n-trig updates
From: Stéphane Chatty, 2010-04-09
-
Re: n-trig updates
From: Andy Whitcroft, 2010-04-10
-
Touch analysis
From: Rafi Rubin, 2010-04-11
-
Re: Touch analysis
From: Rafi Rubin, 2010-04-11
-
Re: Touch analysis
From: Bryce Harrington, 2010-05-07