def __init__(self): self.pygameWindow = PYGAME_WINDOW() self.x = 300 self.y = 300 self.xMin = 1000.0 self.xMax = -1000.0 self.yMin = 1000.0 self.yMax = -1000.0 self.controller = Leap.Controller() self.previousNumberOfHands = 0 self.currentNumberOfHands = 0 self.gesturedata = np.zeros((5, 4, 6), dtype='f') self.gesturenumber = 0 self.Clear_Data()
def main(): global controller global listener t = Thread(target=getch) t.start() # Create a sample listener and controller listener = SampleListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until Enter is pressed print "Press q to quit" global var while var: pass
def takeFrames(nShots=3, nCountDown=2): lc = leap.Controller() lc.set_policy(leap.Controller.POLICY_IMAGES) frames = [] tStart = dt.now() for i in range(nShots): print "Ready to take a shot", str(i + 1) for j in reversed(range(nCountDown)): print(j + 1) sleep(1) if (lc.is_connected): #controller is a Leap.Controller object print "Flash!" frames.append(lc.frame()) print "Done\n" print "Data capture done in", ( dt.now() - tStart).total_seconds() - nShots * nCountDown, "seconds" return frames
def execute(self, context): # Create a sample listener and controller listener = UndoListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until Enter is pressed print("Press Enter to quit...") sys.stdin.readline() # Remove the sample listener when done controller.remove_listener(listener) return {'FINISHED'}
def main(): # Create a sample listener and controller listener = SampleListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) while True: time.sleep(1.0) # Keep this process running until Enter is pressed print "Press Enter to quit..." sys.stdin.readline() # Remove the sample listener when done controller.remove_listener(listener)
def main(): # Create a sample listener and controller listener = SampleListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until Enter is pressed print ("Press Enter to quit...") try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def init(data): backGroundMusic = thread(music.play, ('darkAmbient.wav', )) backGroundMusic.start() data.controller = Leap.Controller() data.frame = data.controller.frame() data.fingerNames = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky'] data.boneNames = ['Metacarpal', 'Proximal', 'Intermediate', 'Distal'] data.fingerPoints = {} data.dist = 0 data.fingerWidth = [0, 0, 0, 0, 0] data.trigger = 'white' data.intersect = [0, 0] data.intersectR = 5 data.mode = 'Splash' data.scalar = 2.83464566929 #root.winfo_fpixels('1m') is how I came to the number, but I can't use this in the constructor data.gunCounter = 0 data.fireAngle = 0 data.gunsPurchased = [gunGraphics.HandGun(data.width, data.height)] data.gun = data.gunsPurchased[0] data.walls = [] data.gunsInStore = [ gunGraphics.ShotGun(data.width, data.height), gunGraphics.MachineGun(data.width, data.height), gunGraphics.Revolver(data.width, data.height) ] data.batEnemies = {} gameGraphics.initialized(data) data.counter = 0 data.health = 200 data.score = 0 data.gameOver = False data.firing = False data.fontFill = 'white' data.playBox = [(data.width - 140, 15), (data.width - 25, 50)] data.helpBox = [(data.width - 140 + 20, 15 + 40), (data.width - 140 + 115, 50 + 40)] data.pauseBox = [(data.width - 140, 15), (data.width - 25, 50)] data.storeBox = [(data.width - 160 + 25, 15 + 40 + 40), (data.width - 160 + 130, 50 + 40 + 40)] data.timeScale = float(data.timerDelay) / 1000 data.mouseX = 0 data.mouseY = 0 data.intersectListX = [] data.intersectListY = [] with open('currency.txt', 'rt') as f: data.currency = int(f.read())
def __init__(self): super(Player, self).__init__() self.score = 0 self.score_mult = 1 self.health = 100 self.controller = Leap.Controller() self.leftHand = Crosshair() self.rightHand = FlameHand() self.attacking = False self.add(self.leftHand) self.add(self.rightHand)
def main(): listener = SampleListener() controller = Leap.Controller() controller.enable_gesture(Leap.Gesture.TYPE_SWIPE) controller.config.set("Gesture.Swipe.MinLength", 100.0) controller.config.set("Gesture.Swipe.MinVelocity", 750) controller.config.save() controller.add_listener(listener) print "Press Enter to quit..." try: sys.stdin.readline() except KeyboardInterrupt: pass
def main(self): listener = LeapMotionListener() controller = Leap.Controller() controller.add_listener(listener) print "Press enter to quit" try: sys.stdin.readline() except KeyboardInterrupt: pass finally: controller.remove_listener(listener) if __name__ == "__main__": main()
def main(): #print "Press enter to start" begin = raw_input("Press enter to start: ") listener = LeapMotionListener() print('listener') controller = Leap.Controller() controller.add_listener(listener) print "Press q to quit" try: sys.stdin.readline() except KeyboardInterrupt: controller.remove_listener(listener) connection.close() pass finally: controller.remove_listener(listener) connection.close()
def main(): # Create a sample listener and controller listener = Listener() controller = Leap.Controller() controller.set_policy(Leap.Controller.POLICY_OPTIMIZE_HMD) # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until Enter is pressed print "Press Enter to quit...BOIIII" try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def main(stage): global starttime # Create a sample listener and controller listener = SampleListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until 2 seconds have passed while (time.time() - starttime < 2): pass else: controller.remove_listener(listener) # Compute average finger directional vectors avgNorms = [] for vectorList in listener.handlist: avgNorms.append(compute_avg_vector(vectorList)) avgPalm = compute_avg_vector(listener.palm) print('palm', avgPalm) print([vector for vector in avgNorms]) # Compute absolute dot product of palm to finger directional vectors avgDotProds = [] for vector in avgNorms: avgDotProds.append(abs(sum(p * q for p, q in zip(avgPalm, vector)))) # Compute roll avgRoll = sum(listener.roll) / len(listener.roll) avgFingerVectors = [] for vectorList in listener.vectlist: avgFingerVectors.append(compute_avg_vector(vectorList)) # Getting back the objects: with open('objs.pickle') as f: # Python 3: open(..., 'rb') fInt, dInt, rInt = pickle.load(f) for i in range(len(fInt)): print('new finger') for j in range(3): print('actual finger', avgFingerVectors[i][j]) print('coordinate bound', fInt[i][j]) for i in range(len(dInt)): print('actual dot', avgDotProds[i]) print('dot bound', dInt[i]) print('Average roll', avgRoll) print('roll interval', rInt)
def main(): # Create a sample listener and controller listener = LeapListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until Enter is pressed print "Press Enter to quit..." RED = 255, 0, 0 WHITE = 255, 255, 255 pygame.init() screen = pygame.display.set_mode((1000, 1000)) pygame.display.set_caption("Moving Box") clock = pygame.time.Clock() while 1: clock.tick(50) for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() screen.fill(WHITE) if (listener.drawer._image != None): mode = listener.drawer._image.mode size = listener.drawer._image.size data = listener.drawer._image.tobytes() py_image = pygame.image.fromstring(data, size, mode) screen.blit(py_image, (10, 10)) pygame.draw.circle(screen, RED, (listener.x - 5, listener.y - 5), listener.radius) pygame.draw.rect(screen, RED, (0, 0, 50, 50), 5) pygame.draw.rect(screen, RED, (0, 50, 50, 50), 5) pygame.draw.rect(screen, RED, (0, 100, 50, 50), 5) pygame.display.flip() try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def main(): # Create a sample listener and controller controller = Leap.Controller() pygame.init() screen = pygame.display.set_mode((800, 600)) white = (255, 255, 255) black = (0, 0, 0) red = (255, 0, 0) green = (0, 255, 0) blue = (0, 0, 255) leftx, rightx = 400, 400 lefty, righty = 300, 300 while True: #quit cleanly if excape pressed for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() #draw black screen and get next leap frame screen.fill(black) frame = controller.frame() oldleftx, oldrightx = leftx, rightx oldlefty, oldrighty = lefty, righty # Get hands for hand in frame.hands: if hand.is_left: leftx = 400 + int(hand.palm_position[0]) lefty = 500 - int(hand.palm_position[1]) else: rightx = 400 + int(hand.palm_position[0]) righty = 500 - int(hand.palm_position[1]) predx, predy = predict(oldleftx, oldlefty, leftx, lefty) pygame.draw.circle(screen, blue, (predx, predy), 20, 1) pygame.draw.circle(screen, red, (leftx, lefty), 20, 1) predx, predy = predict(oldrightx, oldrighty, rightx, righty) pygame.draw.circle(screen, blue, (predx, predy), 20, 1) pygame.draw.circle(screen, green, (rightx, righty), 20, 1) pygame.display.update()
def main(): pygame.init() pygame.mixer.init() background_colour = (255, 255, 255) (width, height) = (1300, 660) end_colour = (0, 0, 0) screen = pygame.display.set_mode((width, height)) pygame.display.set_caption("Ambient Lighting Colour") screen.fill(background_colour) pygame.draw.rect(screen, (127, 0, 255), pygame.Rect(20, 500, 110, 120)) pygame.draw.rect(screen, (0, 128, 255), pygame.Rect(150, 500, 110, 120)) pygame.draw.rect(screen, (60, 200, 255), pygame.Rect(280, 500, 110, 120)) pygame.draw.rect(screen, (0, 255, 255), pygame.Rect(410, 500, 110, 120)) pygame.draw.rect(screen, (255, 255, 204), pygame.Rect(540, 500, 110, 120)) pygame.draw.rect(screen, (255, 255, 255), pygame.Rect(670, 500, 110, 120)) pygame.draw.rect(screen, (255, 255, 51), pygame.Rect(800, 500, 110, 120)) pygame.draw.rect(screen, (0, 204, 0), pygame.Rect(930, 500, 110, 120)) pygame.draw.rect(screen, (255, 128, 0), pygame.Rect(1060, 500, 110, 120)) pygame.draw.rect(screen, (255, 0, 0), pygame.Rect(1190, 500, 110, 120)) global all_sprites all_sprites = pygame.sprite.Group() game_folder = os.path.dirname(__file__) img_folder = os.path.join(game_folder, 'img') global listener listener = swipeListener() controller = Leap.Controller() running = True while running: controller.add_listener(listener) all_sprites.draw(screen) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: running = False controller.remove_listener(listener)
def __init__(self): self.controller = Leap.Controller() self.pygameWindow = PYGAME_WINDOW_Del03() self.x = 0 self.y = 0 self.xMin = -300 self.xMax = 300 self.yMin = -300 self.yMax = 300 self.debug = False # self.numberOfHands = 0 self.currentNumberOfHands = 0 self.previousNumberOfHands = 0 # self.numberOfFile = 0 self.numberOfGestures = 1000 self.gestureIndex = 0 self.gestureData = np.zeros((5, 4, 6, self.numberOfGestures), dtype='f')
def main(): listener = ThereminListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) # Do pyaudio stuff # Keep this process running until Enter is pressed print "Press Enter to quit..." try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def getLeapData(): # Create a sample listener and controller listener = SampleListener() controller = Leap.Controller() # Have the sample listener receive events from the controller controller.add_listener(listener) try: global data while True: if len(data) >= 20: #Interval break except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener) return data
def start(): leap_context["state"] = "start" listener = LeapListener() controller = Leap.Controller() controller.add_listener(listener) graphiti.create_window("OpenGraphiti : Data Visualization Engine", 0, 0) graphiti.create_entity("graph") graphiti.create_visualizer("space") graphiti.register_script("#started", "leap.on_started()") graphiti.register_script('#idle', 'leap.on_idle()') graphiti.add_job("#idle", delta) graphiti.start() controller.remove_listener(listener)
def __init__(self): self.previousNumberOfHands = 0 self.currentNumberOfHands = 0 self.numberOfGesturesSaved = 0 self.numberOfGestures = 1000 self.gestureIndex = 0 self.controller = Leap.Controller() self.lines = [] matplotlib.interactive(True) self.fig = plt.figure(figsize=(8,6)) self.ax = self.fig.add_subplot ( 111, projection ='3d') self.ax.set_xlim(-1000,1000) self.ax.set_ylim(-1000,1000) self.ax.set_zlim(0,1000) self.ax.view_init(azim=90) self.gestureData = np.zeros((5,4,6,self.numberOfGestures),dtype='f')
def run(context): ui = None try: global _app, _ui _app = adsk.core.Application.get() _ui = _app.userInterface _ui.messageBox('Hello addin') # Create a sample listener and controller global _leap_controller listener = SampleListener() _leap_controller = Leap.Controller() # Have the sample listener receive events from the controller _leap_controller.add_listener(listener) except: if _ui: _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def main(): listener = LeapMotionListener() controller = Leap.Controller() controller.add_listener(listener) frame=controller.frame() hands=frame.id #first_hand=hands() #hand.center=hand.palm_position #print hand_center print "Press enter to quit" try: sys.stdin.readline() except KeyboardInterrupt: pass finally: controller.remove_listener(listener)
def main(): # Keep this process running until Enter is pressed print "Press Enter to quit..." listener = LeapMotionListener() controller = Leap.Controller() #initialize audio pygame.mixer.init() controller.add_listener(listener) print "Press enter on exit" try: sys.stdin.readline() except KeyboardInterrupt: pass finally: controller.remove_listener(listener)
def main(): listener = LeapMotionListener( ) # assegna l'oggetto "listener" alla classe "LeapMotionListener" controller = Leap.Controller( ) # assegna l'oggetto "controller" alla classe "Leap.Controller" controller.add_listener( listener) # invoca il metodo "add_listener()" sull'oggetto controller #listener.on_frame(controller) #print(listener.position) print("Press enter to quit") try: sys.stdin.readline() except KeyboardInterrupt: pass finally: controller.remove_listener(listener)
def main(): # Create a listener and controller #listener = GestureListener() listener = PositionListener() controller = Leap.Controller() # Refer the Listener to the Controller controller.add_listener(listener) # Keep this process running until Enter is pressed print "Press Enter to quit..." try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the listener when done controller.remove_listener(listener)
def main(): # Create listener and controller listener = SampleListener() controller = Leap.Controller() # Add listener event to controller controller.add_listener(listener) # Remove listener at the end print "Press Enter to quit..." try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def main(): rospy.init_node('leap_motion2') pub = rospy.Publisher("leapmotion2/data", Hand) listener = leap_listener.LeapListener() controller = Leap.Controller() controller.add_listener(listener) rate = rospy.Rate(100) while not rospy.is_shutdown(): if controller.is_connected: frame = controller.frame() hands = publish_hands_data(pub, frame) rate.sleep() else: controller.remove_listener(listener)
def main(): # create a sample listener and controller listener = LeapEventListener() controller = Leap.Controller() # controller.add_listener(listener) # keep process running until Enter is pressed print("Press Enter to quit...") try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def main(): listener = SampleListener() controller = Leap.Controller() #####th1 = mythread(1,'Asshat') #####th1.start() controller.add_listener(listener) print("press enter to quit") try: sys.stdin.readline() except KeyboardInterrupt: pass finally: a = 0 #client.write_register(3601,0) controller.remove_listener(listener) sys.exit()