def sensor2midi(self):
# Read initial state until it's not empty
initialState = []
while initialState == []:
initialState = self.sensor.getAllImages()
sleep(0.2)
# Observe touch events
while True:
sleep(0.01)
state = self.sensor.getAllImages()
if state:
# Diff the initial state with the new state
diff = np.subtract(initialState[-1]['image'], state[-1]['image'])
self.activeRegions = np.unique(np.where(diff > 100)[1] // self.modulo)
评论列表
文章目录