Exemplo n.º 1
1
 def on_touch_up(self, touch):
     self.points += [touch.pos]
     gesture = Gesture()
     gesture.add_stroke(self.points)
     gesture.normalize()
     gdb = GestureDatabase()
     print "Gesture:", gdb.gesture_to_str(gesture)
Exemplo n.º 2
0
 def on_touch_up(self, touch):
     self.points += [touch.pos]
     gesture = Gesture()
     gesture.add_stroke(self.points)
     gesture.normalize()
     gdb = GestureDatabase()
     print("Gesture:", gdb.gesture_to_str(gesture).decode(encoding='UTF-8'))
Exemplo n.º 3
0
 def simplegesture(self, name, point_list):
     # Pomocná funkce pro rozpoznávání gesta
     g = Gesture()
     g.add_stroke(point_list)
     g.normalize()
     g.name = name
     return g
Exemplo n.º 4
0
 def on_touch_up(self,touch):
     self.points+=[touch.pos]
     with self.canvas:
         Ellipse(pos=(touch.x-5,touch.y-5),size=(10,10))
     gesture=Gesture()
     gesture.add_stroke(self.points)
     gesture.normalize()
     gdb=GestureDatabase()
Exemplo n.º 5
0
 def on_touch_up(self, touch):
     if 'gesture_path' in touch.ud:
         gesture = Gesture()
         gesture.add_stroke(touch.ud['gesture_path'])
         gesture.normalize()
         match = gestures.find(gesture, minscore=0.6666660)
         if match:
             print("{} happened".format(match[1].name))
     super(GestureBox, self).on_touch_up(touch)
Exemplo n.º 6
0
def simplegesture(name, point_list):
    """
    A simple helper function
    """
    g = Gesture()
    g.add_stroke(point_list)
    g.normalize()
    g.name = name
    return g
Exemplo n.º 7
0
 def on_touch_up(self, touch):
     if 'gesture_path' in touch.ud:
         gesture = Gesture()  # <1>
         gesture.add_stroke(touch.ud['gesture_path'])  # <2>
         gesture.normalize()  # <3>
         match = gestures.find(gesture, minscore=0.90)  # <4>
         if match:
             print("{} happened".format(match[1].name))  # <5>
     super(GestureBox, self).on_touch_up(touch)
Exemplo n.º 8
0
 def on_touch_up(self, touch):
     if "gesture_path" in touch.ud:
         gesture = Gesture()
         gesture.add_stroke(touch.ud["gesture_path"])
         gesture.normalize()
         match = gestures.find(gesture, minscore=0.90)
         if match:
             self.dispatch("on_{}".format(match[1].name))
     super(GestureBox, self).on_touch_up(touch)
Exemplo n.º 9
0
 def on_touch_up(self, touch):
     # print(touch.ud['gesture_path'])
     if 'gesture_path' in touch.ud:
         gesture = Gesture()
         gesture.add_stroke(touch.ud['gesture_path'])
         gesture.normalize()
         match = gestures.find(gesture, minscore=0.9)
         if match:
             print('ha ha:', match[1].name)
     super().on_touch_up(touch)
 def add_gesture(self, name, gesture_path):
     gesture = Gesture()
     gesture.add_stroke(gesture_path)
     gesture.normalize()
     if name in self.str_gestures:
         raise ValueError('Cannot overwrite existing gesture in file.')
     gesture.name = name
     self.str_gestures[name] = self.db.gesture_to_str(gesture).decode(
         'utf-8')
     self.db.add_gesture(gesture)
Exemplo n.º 11
0
def simplegesture(uName: str, point_list) -> Gesture:
    """
    A simple helper function
    Taken from original Kivy examples
    """
    g = Gesture()
    g.add_stroke(list(point_list))
    g.normalize()
    g.name = uName
    return g
Exemplo n.º 12
0
 def on_touch_up(self, touch):
     if 'gesture_path' in touch.ud:
         gesture = Gesture()
         gesture.add_stroke(touch.ud['gesture_path'])
         gesture.normalize()
         match = gesture_db.find(gesture, minscore=0.7)
         if match:
             print(f'on_{match[1].name}')
             self.dispatch(f'on_{match[1].name}')
     super(MyScreenManager, self).on_touch_up(touch)
Exemplo n.º 13
0
 def on_touch_up(self, touch):
     if 'gesture_path' in touch.ud:
         gesture = Gesture()
         gesture.add_stroke(touch.ud['gesture_path'])
         gesture.normalize()
         match = gestures.find(gesture, minscore=0.90)
         # BEGIN FIRE
         if match:
             self.dispatch('on_{}'.format(match[1].name))
         # END FIRE
     super(GestureBox, self).on_touch_up(touch)
Exemplo n.º 14
0
 def on_touch_up(self, touch):
     if 'gesture_path' in touch.ud:
         # create a gesture object
         gesture = Gesture()
         # add the movement coordinates
         gesture.add_stroke(touch.ud['gesture_path'])
         # normalize so thwu willtolerate size variations
         gesture.normalize()
         # minscore to be attained for a match to be true, default 0.3
         g2 = self.gdb.find(gesture, minscore=0.70)
         if g2:
             print 'swipe left'
Exemplo n.º 15
0
    def on_touch_up(self, touch):
        if 'gesture_path' in touch.ud:
            gesture = Gesture()
            gesture.add_stroke(touch.ud['gesture_path'])
            gesture.normalize()
            match = gestures.find(gesture, minscore=0.70)
            if match:
                print("{} gesture occured".format(match[1].name))
            else:
                print("No gesture recognized")

        super(DictScreen, self).on_touch_up(touch)
Exemplo n.º 16
0
 def on_touch_up(self, touch):
     app = App.get_running_app()
     if app.controls == 'button':
         pass
     else:
         if 'gesture_path' in touch.ud:
             gesture = Gesture()
             gesture.add_stroke(touch.ud['gesture_path'])
             gesture.normalize()
             match = gestures.find(gesture, minscore=0.60)
             if match:
                 self.dispatch('on_{}'.format(match[1].name))
         super(Game, self).on_touch_up(touch)
Exemplo n.º 17
0
    def on_touch_up(self, touch):
        super(Box, self).on_touch_up(touch)
        if touch.grab_current is self:
            gesture = Gesture()
            gesture.add_stroke(touch.ud['data points'])
            gesture.normalize()

            match = self.gdb.find(gesture, minscore=0.8)
            if match:
                # print(match[0])
                self.dispatch('on_top_to_button')

            touch.ungrab(self)
Exemplo n.º 18
0
def simplegesture(name, point_list):
    """
    A simple helper function
    Taken from original Kivy examples
    """
    g = Gesture()
    if PY2:
        g.add_stroke(point_list)
    else:
        g.add_stroke(list(point_list))
    g.normalize()
    g.name = name
    return g
Exemplo n.º 19
0
 def on_touch_up(self, touch):
     if 'gesture_path' in touch.ud:
         #create a gesture object
         gesture = Gesture()
         #add the movement coordinates
         gesture.add_stroke(touch.ud['gesture_path'])
         #normalize so thwu willtolerate size variations
         gesture.normalize()
         #minscore to be attained for a match to be true
         match = gestures.find(gesture, minscore=0.3)
         if match:
             print("{} happened".format(match[1].name))
             self.dispatch('on_{}'.format(match[1].name))
     super(GestureBox, self).on_touch_up(touch)
Exemplo n.º 20
0
 def on_touch_up(self, touch):
     # 判断是否匹配
     if 'gesture_path' in touch.ud:
         # 创建一个手势
         gesture = Gesture()
         # 添加移动坐标
         gesture.add_stroke(touch.ud['gesture_path'])
         # 标准化大小
         gesture.normalize()
         # 匹配手势,minscore:手势灵敏度
         match = gestures.find(gesture, minscore=0.5)
         if match:
             print("{} happened".format(match[1].name))
             self.dispatch('on_{}'.format(match[1].name))
     super(GestureBox, self).on_touch_up(touch)
Exemplo n.º 21
0
def check_gesture(points, gdb) -> int or None:
    g = Gesture()

    # convert raw DrawPad output to gesture compatible list
    point_list = list(zip(points[0::2], points[1::2]))
    g.add_stroke(point_list)
    g.normalize()

    # check if new gesture matches a known gesture
    g2 = gdb.find(g, minscore=0.70)

    if g2:
        if g2[1] == cun_1:
            return 1
        if g2[1] == cun_10:
            return 10

    return None
Exemplo n.º 22
0
    def on_touch_up(self, touch):
        # Touch is over
        ret = False
        if touch.grab_current is self:

            # Add gesture to database
            try:
                g = Gesture()
                g.add_stroke(
                    list(
                        zip(touch.ud['line'].points[::2],
                            touch.ud['line'].points[1::2])))
                g.normalize()
                g.name = 'try'

                # Delete trace line
                self.canvas.remove_group(touch.ud['group'])

                # Compare gesture to my_gestures.py
                #print("gesture representation:", self.gdb.gesture_to_str(g))
                #print("check:", g.get_score(check))

                # use database to find the more alike gesture, if any
                g2 = self.gdb.find(g, minscore=0.90)

                #print(g2)
                if g2 and g2[1] == check:
                    self.manager.app.open_settings()

                ret = True

            except KeyError:
                ret = super(LockScreen, self).on_touch_up(touch)

            touch.ungrab(self)

        return ret
Exemplo n.º 23
0
 def gesturize(self):
     gesture = Gesture()
     gesture.add_stroke(self.points)
     gesture.normalize()
     return gesture
Exemplo n.º 24
0
 def __init__(self):
     self.uGestureName:str           =  u''
     self.oGesture:Gesture           =  Gesture()
     self.uGestureString:str         =  u''
Exemplo n.º 25
0
def simplegesture(name, point_list):
    g = Gesture()
    g.add_stroke(point_list)
    g.normalize()
    g.name = name
    return g
Exemplo n.º 26
0
from kivy.gesture import Gesture, GestureDatabase

# Create a gesture
g = Gesture()
g.add_stroke(point_list=[(1, 1), (3, 4), (2, 1)])
g.normalize()
g.name = "triangle"

# Add it to database
gdb = GestureDatabase()
gdb.add_gesture(g)

# And for the next gesture, try to find a match!
g2 = Gesture()
g2.add_stroke(point_list=[(1, 1), (3, 4), (2, 1)])
g2.normalize()
print gdb.find(g2).name  # will print "triangle"