-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prova.py
58 lines (49 loc) · 1.82 KB
/
Prova.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
try:
import user
sys.path.append('gesture-agents/')
sys.path.append('gesture-agents-SL/')
except ImportError:
sys.path.append('../../../cpython_modules/')
sys.path.append('../../../gesture-agents/')
sys.path.append('../../../gesture-agents-SL/')
from GestureAgents.AppRecognizer import AppRecognizer
import GestureAgents.Reactor as Reactor
import GestureAgentsTUIO2.Tuio2 as Tuio2
def my_import(name):
__import__(name)
return sys.modules[name]
class NetGestures(object):
def __init__(self):
self.running = True
self.tuio2agentgenerator = Tuio2.Tuio2AgentGenerator((1024,768))
self.sensors = (self.tuio2agentgenerator,)
def main_loop(self):
try:
for s in self.sensors:
if hasattr(s,'updte'): s.update()
Reactor.run_all_now()
except Exception as ex:
import traceback
import sys
traceback.print_exc(file=sys.stdout)
raise ex
@staticmethod
def RegisterHelper(event,delegate):
class T(object):
def f(self,*args):
delegate(*args)
event.register(T.f,T())
def RegisterHelperAppRecognizer(self,fullname, delegate):
module = my_import(fullname)
recognizer = fullname.split('.')[-1]
recognizerKlass = getattr(module,recognizer)
self.RegisterHelper(AppRecognizer(recognizerKlass).newAgent,delegate)
@staticmethod
def injectFunctionRelPos(funct):
import GestureAgentsTUIO2.Gestures2D.RecognizerCursorOnPad
GestureAgentsTUIO2.Gestures2D.RecognizerCursorOnPad.CRelPos = funct
@staticmethod
def injectFunctionInvRelPos(funct):
import GestureAgentsTUIO2.Gestures2D.RecognizerPad
GestureAgentsTUIO2.Gestures2D.RecognizerPad.tablePos = funct