Exemplo n.º 1
0
def unlock(controller, options):
    """TODO: Docstring for unlock.

    :controller: TODO
    :returns: TODO

    """
    mark = True
    last_frame_id = 0
    temp = []

    all_tip_position = [[], [], []]
    for index in range(3):
        for item in range(5):
            all_tip_position[index].append([])

    if not options.user_name:
        options.user_name = 'default'

    temp = io.loadmat(WINDOWS_PATH + '\\gestures\\' + options.user_name)['all']

    r = Recognizer()

    r.addTemplate(options.user_name, temp)

    temp = []
    for item in range(5):
        temp.append([])

    while True:
        current_frame = controller.frame()

        if current_frame.id == last_frame_id:
            continue

        last_frame_id = current_frame.id

        process_frame(current_frame, all_tip_position)

        hands_len = len(current_frame.hands)

        checked = check_motion(current_frame, temp)

        if checked == False and mark and hands_len:
            start_time = time.time()
            mark = False
        elif checked == False and mark == False and hands_len:
            interval = time.time() - start_time

            if interval > INTERVAL:
                if verify(r, all_tip_position, options.user_name):
                    return
        elif checked and hands_len:
            start_time = time.time()
            mark = True
Exemplo n.º 2
0
def check_all_file():
    """TODO: Docstring for main.

    :returns: TODO

    """
    controller = Leap.Controller()

    all_files = [
        os.path.splitext(x)[0] for x in os.listdir(WINDOWS_PATH + '\\gestures')
        if x[0] != '.'
    ]

    r = Recognizer()

    for a_file in all_files:
        add_password(r, a_file)

    return unlock(r, controller, a_file)
Exemplo n.º 3
0
def add_password(all_tip_position, user_name):
    """TODO: Docstring for verify.
    :returns: TODO

    """
    r = Recognizer()

    temp = []

    for index in range(3):
        for item in range(5):
            temp = temp + all_tip_position[index][item]

    r.addTemplate(user_name, temp)

    # for index, tip in enumerate(all_tip_position[0]):
    # r.addTemplate(user_name + 'yz' + str(index), tip)
    # for index, tip in enumerate(all_tip_position[1]):
    # r.addTemplate(user_name + 'xz' + str(index), tip)
    # for index, tip in enumerate(all_tip_position[2]):
    # r.addTemplate(user_name + 'xy' + str(index), tip)

    return r
Exemplo n.º 4
0
    def __init__(self, parent, id, title, width, height):
        self.frame = wx.Frame.__init__(self,
                                       parent,
                                       id,
                                       title,
                                       size=wx.Size(width, height))
        self.SetMinSize((width, height))
        self.SetMaxSize((width, height))

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_MOTION, self.OnMouseMove)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)

        self.mouseDown = False
        self.positions = []

        self.recognizer = Recognizer()
        self.recognizer.addTemplate('circle', circlePoints)
        self.recognizer.addTemplate('square', squarePoints)
        self.recognizer.addTemplate('triangle', trianglePoints)

        self.last_name = None
        self.last_accuracy = 0.0