def run_example(*args, **kwargs): # Create the SerialDataReader sdr = SerialDataReader(kwargs['port'], expected_axis=6, verbose=False) # Create the SampleManager manager = DiscreteSampleManager() # Attach the manager sdr.attach_manager(manager) # Create a classifier classifier = SVMClassifier(model_path=args[0]) # Load the model classifier.load() # Create a ClassifierPredictor predictor = ClassifierPredictor(classifier) # Attach the classifier predictor manager.attach_receiver(predictor) # Create a CallbackManager callback_mg = CallbackManager(verbose=True) # Attach the callback manager predictor.attach_callback_manager(callback_mg) # Open the serial connection sdr.open() print("Opened!") # Start the main loop sdr.mainloop()
def run_example(*args, **kwargs): # Create the SerialDataReader sdr = SerialDataReader(kwargs['port'], expected_axis=6, verbose=False) # Create the SampleManager manager = StreamSampleManager(window=10, step=5) # Attach the manager sdr.attach_manager(manager) # Create the VerboseMiddleware that prints the received sample middleware = VerboseMiddleware(verbose=False) # Attach the middleware manager.attach_receiver(middleware) # Create a predictor predictor = HighestAxisPredictor(absolute_values=True) # Attach the predictor middleware.attach_receiver(predictor) # Create a callback manager callback_mg = CallbackManager(verbose=True) # Attach the callback manager predictor.attach_callback_manager(callback_mg) # Open the serial connection sdr.open() print("Opened!") # Start the main loop sdr.mainloop()
def run_example(*args, **kwargs): # Create the SerialDataReader sdr = SerialDataReader(kwargs['port'], expected_axis=6, verbose=False) # Create the SampleManager manager = StreamSampleManager(step=20, window=20) # Attach the manager sdr.attach_manager(manager) # Create a threshold middleware middleware = GradientThresholdMiddleware(verbose=False, threshold=40, sample_group_delay=5, group=True) # Attach the middleware manager.attach_receiver(middleware) # Create a classifier classifier = SVMClassifier(model_path=args[0]) # Load the model classifier.load() # Print classifier info classifier.print_info() # Create a ClassifierPredictor predictor = ClassifierPredictor(classifier) # Filter the samples that are too short or too long lfmiddleware = LengthThresholdMiddleware(verbose=True, min_len=180, max_len=600) middleware.attach_receiver(lfmiddleware) # Attach the classifier predictor lfmiddleware.attach_receiver(predictor) # Create a CallbackManager callback_mg = CallbackManager(verbose=True) # Attach the callback manager predictor.attach_callback_manager(callback_mg) # Attach the callbacks callback_mg.attach_callback("knock", receive_gesture) callback_mg.attach_callback("doubleknock", receive_gesture) # Open the serial connection sdr.open() print("Opened!") # Start the main loop sdr.mainloop()
def receive_character(number): pyautogui.doubleClick(155, 69) if number != "1": pyautogui.typewrite(number) else: pyautogui.keyDown('backspace') pyautogui.keyUp('backspace') # Create the SerialDataReader sdr = SerialDataReader(PORT, expected_axis=6, verbose=False) # Create the SampleManager manager = StreamSampleManager() # Attach the manager sdr.attach_manager(manager) # Create a classifier classifier = SVMClassifier(model_path=MODEL_PATH) # Load the model classifier.load() # Print classifier info classifier.print_info() # Create a ClassifierPredictor predictor = ClassifierPredictor(classifier) # Attach the classifier predictor manager.attach_receiver(predictor) # Create a CallbackManager callback_mg = CallbackManager(verbose=True) # Attach the callback manager predictor.attach_callback_manager(callback_mg) # Bind all the numbers callback_mg.attach_callback(" ", receive_character) for c in ["1", "2", "3", "4"]: callback_mg.attach_callback(c, receive_character) # Open the serial connection sdr.open() print("Opened!") # Start the main loop sdr.mainloop()
classifier = SVMClassifier(model_path=MODEL_PATH) # Load the model classifier.load() # Print classifier info classifier.print_info() # Create a ClassifierPredictor predictor = ClassifierPredictor(classifier) # Attach the classifier predictor manager.attach_receiver(predictor) # Create a CallbackManager callback_mg = CallbackManager(verbose=True) # Attach the callback manager predictor.attach_callback_manager(callback_mg) # Bind all the numbers for c in ["1","2","3","4","Bow;ing","Push","Pull","Bye-Bye","Drinking"]: callback_mg.attach_callback(c, receive_character) # Open the serial connection sdr.open() print("Opened!") # Start the main loop sdr.mainloop()
# Print classifier info classifier.print_info() # Create a ClassifierPredictor predictor = ClassifierPredictor(classifier) # Filter the samples that are too short or too long lfmiddleware = LengthThresholdMiddleware(verbose=False, min_len=180, max_len=600) middleware.attach_receiver(lfmiddleware) # Attach the classifier predictor lfmiddleware.attach_receiver(predictor) # Create a CallbackManager callback_mg = CallbackManager(verbose=False) # Attach the callback manager predictor.attach_callback_manager(callback_mg) # Attach the callbacks callback_mg.attach_callback("tap", receive_gesture) callback_mg.attach_callback("doubletap", receive_gesture) callback_mg.attach_callback("left", receive_gesture) callback_mg.attach_callback("right", receive_gesture) callback_mg.attach_callback("tapclockwise", receive_gesture) callback_mg.attach_callback("tapanticlockwise", receive_gesture) callback_mg.attach_callback("pull", receive_gesture) callback_mg.attach_callback("push", receive_gesture) # Open the serial connection