Skip to content
Snippets Groups Projects
Commit fa0c789f authored by Vincent Wall's avatar Vincent Wall
Browse files

added options for simple font resizing (for other display sizes)

parent b9f4038c
No related branches found
No related tags found
No related merge requests found
...@@ -35,9 +35,9 @@ from glob import glob ...@@ -35,9 +35,9 @@ from glob import glob
# ================== # ==================
BASE_DIR = "." BASE_DIR = "."
SOUND_NAME = "sweep" # sound to use SOUND_NAME = "sweep" # sound to use
CLASS_LABELS = ["tip", "middle", "base", "back", "left", "right", "none"] # classes to train CLASS_LABELS = ["back", "left", "right", "none"] # classes to train
SAMPLES_PER_CLASS = 20 SAMPLES_PER_CLASS = 10
MODEL_NAME = "berlinsummit_sweep_1s" MODEL_NAME = "berlinsummit_plus_sweep_1s"
SHUFFLE_RECORDING_ORDER = False SHUFFLE_RECORDING_ORDER = False
APPEND_TO_EXISTING_FILES = True APPEND_TO_EXISTING_FILES = True
# ================== # ==================
......
...@@ -35,7 +35,7 @@ from A_record import MODEL_NAME ...@@ -35,7 +35,7 @@ from A_record import MODEL_NAME
# USER SETTINGS # USER SETTINGS
# ================== # ==================
BASE_DIR = "." BASE_DIR = "."
SENSORMODEL_FILENAME = "sensor_model_berlinsummit_AAS016_svc.pkl" SENSORMODEL_FILENAME = "sensor_model_berlinsummit_plus_AAS016_svc.pkl"
TEST_SIZE = 0 # percentage of samples left out of training and used for reporting test score TEST_SIZE = 0 # percentage of samples left out of training and used for reporting test score
SHOW_PLOTS = True SHOW_PLOTS = True
# ================== # ==================
......
...@@ -42,6 +42,15 @@ CONTINUOUSLY = True # chose between continuous sensing or manually triggered ...@@ -42,6 +42,15 @@ CONTINUOUSLY = True # chose between continuous sensing or manually triggered
SHOW_CLASS_IMAGES = True SHOW_CLASS_IMAGES = True
# ================== # ==================
font_sizes = {
"suptitle": 15,
"axtitle": 10,
"axlabel": 9,
"ticksize": 7,
"measuredlabel": 20,
"prediciton": 50
}
label_renamer_lndw2022 = { label_renamer_lndw2022 = {
"tip": "Vorne", "tip": "Vorne",
"middle": "Mitte", "middle": "Mitte",
...@@ -82,7 +91,7 @@ class LiveAcousticSensor(object): ...@@ -82,7 +91,7 @@ class LiveAcousticSensor(object):
self.setup_jack() self.setup_jack()
self.setup_model() self.setup_model()
self.setup_window() self.setup_window()
self.pause_time = 0.01 self.pause_time = 0
def setup_jack(self): def setup_jack(self):
self.J = JackSignal("JS") self.J = JackSignal("JS")
...@@ -116,15 +125,17 @@ class LiveAcousticSensor(object): ...@@ -116,15 +125,17 @@ class LiveAcousticSensor(object):
def setup_window(self): def setup_window(self):
f = plt.figure(1) f = plt.figure(1)
f.clear() f.clear()
f.suptitle("Acoustic Contact Sensing", size=30) f.suptitle("Acoustic Contact Sensing", size=font_sizes["suptitle"])
ax1 = f.add_subplot(2, 2, 1) ax1 = f.add_subplot(2, 2, 1)
ax1.set_title("Recorded sound (waveform)", size=20) ax1.set_title("Recorded sound (waveform)", size=font_sizes["axtitle"])
ax1.set_xlabel("Time [samples]") ax1.set_xlabel("Time [samples]", size=font_sizes["axlabel"])
ax1.set_ylim([-1, 1]) ax1.set_ylim([-1, 1])
ax1.tick_params(axis='both', which='major', labelsize=font_sizes["ticksize"])
ax2 = f.add_subplot(2, 2, 2) ax2 = f.add_subplot(2, 2, 2)
ax2.set_title("Amplitude spectrum", size=20) ax2.set_title("Amplitude spectrum", size=font_sizes["axtitle"])
ax2.set_xlabel("Frequency [Hz]") ax2.set_xlabel("Frequency [Hz]", size=font_sizes["axlabel"])
ax2.tick_params(axis='both', which='major', labelsize=font_sizes["ticksize"])
self.wavelines, = ax1.plot(self.Ains[0]) self.wavelines, = ax1.plot(self.Ains[0])
self.spectrumlines, = ax2.plot(sound_to_spectrum_stft(self.Ains[0])+1e-16) self.spectrumlines, = ax2.plot(sound_to_spectrum_stft(self.Ains[0])+1e-16)
ax2.set_ylim([1e-1, 1000]) ax2.set_ylim([1e-1, 1000])
...@@ -132,8 +143,8 @@ class LiveAcousticSensor(object): ...@@ -132,8 +143,8 @@ class LiveAcousticSensor(object):
ax3a = f.add_subplot(2, 2, 3) ax3a = f.add_subplot(2, 2, 3)
ax3a.text(0.0, 0.8, "Measured contact:", dict(size=40)) ax3a.text(0.5, 0.75, "Measured contact:", dict(size=font_sizes["measuredlabel"], ha='center'))
self.predictiontext = ax3a.text(0.25, 0.25, "", dict(size=70)) self.predictiontext = ax3a.text(0.5, 0.25, "", dict(size=font_sizes["prediciton"], ha='center'))
ax3a.set_xticklabels([]) ax3a.set_xticklabels([])
ax3a.set_yticklabels([]) ax3a.set_yticklabels([])
# ax3.set_title("Contact location") # ax3.set_title("Contact location")
...@@ -152,6 +163,8 @@ class LiveAcousticSensor(object): ...@@ -152,6 +163,8 @@ class LiveAcousticSensor(object):
self.b_pause.on_clicked(toggle_pause) self.b_pause.on_clicked(toggle_pause)
cid = f.canvas.mpl_connect('key_press_event', on_key) cid = f.canvas.mpl_connect('key_press_event', on_key)
plt.tight_layout(w_pad=0.25)
plt.subplots_adjust(top=0.85)
f.show() f.show()
plt.draw() plt.draw()
plt.pause(0.00001) plt.pause(0.00001)
...@@ -182,7 +195,7 @@ class LiveAcousticSensor(object): ...@@ -182,7 +195,7 @@ class LiveAcousticSensor(object):
self.J.process() self.J.process()
self.J.wait() self.J.wait()
self.predict() self.predict()
plt.pause(self.pause_time) plt.pause(self.pause_time+0.01)
else: else:
key = input("Press <Enter> to sense! ('q' to abort)") key = input("Press <Enter> to sense! ('q' to abort)")
while key == '': while key == '':
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment