コード例 #1
1
ファイル: gesturerecorder.py プロジェクト: simon0729/Test
 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)
コード例 #2
0
ファイル: gesturerecorder.py プロジェクト: MancaManca/Kivy
 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'))
コード例 #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
コード例 #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()
コード例 #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)
コード例 #6
0
ファイル: gesture_board.py プロジェクト: Magzister/crud
def simplegesture(name, point_list):
    """
    A simple helper function
    """
    g = Gesture()
    g.add_stroke(point_list)
    g.normalize()
    g.name = name
    return g
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #10
0
 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)
コード例 #11
0
ファイル: ButtonBehaviour.py プロジェクト: thica/ORCA-Remote
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
コード例 #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)
コード例 #13
0
ファイル: gesture_box.py プロジェクト: simon0729/Test
 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)
コード例 #14
0
ファイル: screens.py プロジェクト: AndreMPCosta/CellCount
 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'
コード例 #15
0
ファイル: screens.py プロジェクト: vanbear/Sownik
    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)
コード例 #16
0
ファイル: main.py プロジェクト: xinmingzhang/IrregularTetris
 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)
コード例 #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)
コード例 #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
コード例 #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)
コード例 #20
0
ファイル: gesture_box.py プロジェクト: cocpy/mrword
 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)
コード例 #21
0
ファイル: gesture.py プロジェクト: trinoculars/code-jam-6
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
コード例 #22
0
ファイル: display.py プロジェクト: istvanzk/WStation
    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
コード例 #23
0
 def gesturize(self):
     gesture = Gesture()
     gesture.add_stroke(self.points)
     gesture.normalize()
     return gesture
コード例 #24
0
 def __init__(self):
     self.uGestureName:str           =  u''
     self.oGesture:Gesture           =  Gesture()
     self.uGestureString:str         =  u''
コード例 #25
0
ファイル: e9.py プロジェクト: MancaManca/Kivy
def simplegesture(name, point_list):
    g = Gesture()
    g.add_stroke(point_list)
    g.normalize()
    g.name = name
    return g
コード例 #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"