예제 #1
0
def debug(**kw):
    run = [None]
    print(PARAMS)
    kw.update(PARAMS)
    while run[0] != 'QUIT':
        run = [None]
        for data in pupil_iter(debug=True, **kw):
            run[0] = debug_iter(*data)
            if run[0]:
                break
예제 #2
0
def debug(**kw):
    run = [None]
    print(PARAMS)
    kw.update(PARAMS)
    while run[0] != 'QUIT':
        run = [None]
        for data in pupil_iter(debug=True, **kw):
            box = data[0]
            run[0] = debug_iter(*data)
            if run[0]:
                break
예제 #3
0
 def callback(ws, **kw):
     print('Got args[%r]' % (kw,))
     print('Demo callback, prints all inputs and sends nothing')
     run = [None]
     kw.update(PARAMS)
     import servo
     def background():
         alpha = 1
         v = None
         scrollMin = 0
         scrollMax = 1200
         while True:
             data = ws.receive()
             if data[0] == 'blob' and data[1] == 'audio':
                 continue
                 m = .4
                 M = .75
                 d = float(data[2])
                 if not np.isfinite(d):
                     continue
                 d = scale(d, m, M)
                 if v is None:
                     v = d
                 v = (1 - alpha) * v + alpha  * d
                 print((d, v))
                 #servo.mouth(v)
                 #gevent.sleep(.05)
             elif data[0] == 'blob' and data[1] == 'scroll':
                 print(data)
                 #servo.mouth(scale(float(data[2]), scrollMin, scrollMax))
             elif data[0] == 'blob' and data[1] == 'finger' and data[2] == '+':
                 servo.mouth(1)
             elif data[0] == 'blob' and data[1] == 'finger' and data[2] == '-':
                 servo.mouth(0)
             elif data[0] == 'sensors':
                 continue
                 #for sample in data[3].get('MPL Orientation', []):
                 #    servo.mouth(sample[0][0] / 360)
                 print(data)
                 for sample in data[3].get('LTR-506ALS Light sensor', []):
                     d = sample[0][0]
                     d = scale(d, 5, 175)
                     print('Light: ' + str(d))
                     #servo.mouth(d)
                 #for sample in data[3].get('MPL Orientation', []):
                 #    servo.mouth(sample[0][0] / 360)
             else:
                 pass
                 #print(data)
             #gevent.sleep(.01)
     gevent.spawn(background)
     while run[0] != 'QUIT':
         for box, frame, hull, timestamp in pupil_iter(**kw):
             if kw.get('debug'):
                 run[0] = debug_iter(box, frame, hull, timestamp)
             if run[0]:
                 break
             if box is None:
                 continue
             eyex = scale(box[0][0], 170, 440)
             eyey = scale(box[0][1], 95, 278)
             servo.eye_x(eyex)
             servo.eye_y(1 - eyey)