The steps for this recipe are as follows:
- Import the libraries:
#Gather.py
import numpy as np
from sense_hat import SenseHat
import json
import time
- Initialize the variables:
sense = SenseHat()
sense.set_imu_config(True, True, True)
readings = 1000
gyro,accel = sense.gyro_raw, sense.accel_raw
actions = ['normal', 'anomolous']
dat = np.array([gyro['x'], gyro['y'], gyro['z'], accel['x'],
accel['y'], accel['z']])
x = 1
- Wait for the user input to start:
for user_input in actions:
activity = input('Hit enter to record '+user_input + \
' activity')
- Gather the data:
x = 1
while x < readings:
x = x + 1
time.sleep(0.1)
gyro,accel = sense.gyro_raw, sense.accel_raw
dat = np.vstack([dat, [[gyro['x'], gyro['y'], gyro['z'],
accel['x'], accel...