-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfretboard.py
504 lines (441 loc) · 22.7 KB
/
fretboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
import os
import pudb
import glob
import skimage.io as io
import numpy as np
import cv2
import logging
from collections import OrderedDict
from utils import logger_init
class FretBoard():
def __init__(self, output_dir):
self.output_dir = output_dir
os.makedirs(output_dir, exist_ok=True)
filehandler, consolehandler = logger_init(output_dir, logging.DEBUG)
self.setup_fretboard()
self.tab_got()
def overlay_image_alpha(self, img, img_overlay, pos, alpha_mask):
"""Overlay img_overlay on top of img at the position specified by
pos and blend using alpha_mask.
Alpha mask must contain values within the range [0, 1] and be the
same size as img_overlay.
"""
x, y = pos
# Image ranges
y1, y2 = max(0, y), min(img.shape[0], y + img_overlay.shape[0])
x1, x2 = max(0, x), min(img.shape[1], x + img_overlay.shape[1])
# Overlay ranges
y1o, y2o = max(0, -y), min(img_overlay.shape[0], img.shape[0] - y)
x1o, x2o = max(0, -x), min(img_overlay.shape[1], img.shape[1] - x)
# Exit if nothing to do
if y1 >= y2 or x1 >= x2 or y1o >= y2o or x1o >= x2o:
return
channels = img.shape[2]
alpha = alpha_mask[y1o:y2o, x1o:x2o]
alpha_inv = 1.0 - alpha
for c in range(channels):
img[y1:y2, x1:x2, c] = (alpha * img_overlay[y1o:y2o, x1o:x2o, c] +
alpha_inv * img[y1:y2, x1:x2, c])
def setup_fretboard(self):
# Measurement in mm
self.fb_scale = 1.0
self.fb_h = 42.0
# self.fb_w = 323.85 # 12th fret
self.fb_w = 455.138 # 21st fret
# self.fb_w = 465.945 # 22st fret
### Strings
fb_num_string = 6
fb_string_dist = self.fb_h/fb_num_string
fb_string_dist_offset = fb_string_dist/2
self.fb_string_dict = {}
self.fb_string_dict['s1'] = fb_string_dist*6.0 - fb_string_dist_offset
self.fb_string_dict['s2'] = fb_string_dist*5.0 - fb_string_dist_offset
self.fb_string_dict['s3'] = fb_string_dist*4.0 - fb_string_dist_offset
self.fb_string_dict['s4'] = fb_string_dist*3.0 - fb_string_dist_offset
self.fb_string_dict['s5'] = fb_string_dist*2.0 - fb_string_dist_offset
self.fb_string_dict['s6'] = fb_string_dist*1.0 - fb_string_dist_offset
### Frets (Standard Fender Stratocaster)
# fb_fret_dict = {}
# fb_fret_dict['f0'] = 0.0
# fb_fret_dict['f1'] = 36.353
# fb_fret_dict['f2'] = 70.665
# fb_fret_dict['f3'] = 103.051
# fb_fret_dict['f4'] = 133.620
# fb_fret_dict['f5'] = 162.473
# fb_fret_dict['f6'] = 189.707
# fb_fret_dict['f7'] = 215.412
# fb_fret_dict['f8'] = 239.675
# fb_fret_dict['f9'] = 262.575
# fb_fret_dict['f10'] = 284.191
# fb_fret_dict['f11'] = 304.593
# fb_fret_dict['f12'] = 323.850
# fb_fret_dict['f13'] = 342.026
# fb_fret_dict['f14'] = 359.182
# fb_fret_dict['f15'] = 375.376
# fb_fret_dict['f16'] = 390.660
# fb_fret_dict['f17'] = 405.087
# fb_fret_dict['f18'] = 418.703
# fb_fret_dict['f19'] = 431.556
# fb_fret_dict['f20'] = 443.687
# fb_fret_dict['f21'] = 455.138
### Frets (Fender Bullet Strat - Custom v1)
# fb_fret_dict = {}
# fb_fret_dict['f0'] = 0.0
# fb_fret_dict['f1'] = 47.41
# fb_fret_dict['f2'] = 88.05
# fb_fret_dict['f3'] = 125.31
# fb_fret_dict['f4'] = 159.00
# fb_fret_dict['f5'] = 189.48
# fb_fret_dict['f6'] = 217.59
# fb_fret_dict['f7'] = 242.99
# fb_fret_dict['f8'] = 266.19
# fb_fret_dict['f9'] = 288.21
# fb_fret_dict['f10'] = 308.19
# fb_fret_dict['f11'] = 326.98
# fb_fret_dict['f12'] = 344.93
# fb_fret_dict['f13'] = 360.85
# fb_fret_dict['f14'] = 375.58
# fb_fret_dict['f15'] = 389.64
# fb_fret_dict['f16'] = 402.34
# fb_fret_dict['f17'] = 414.36
# fb_fret_dict['f18'] = 425.53
# fb_fret_dict['f19'] = 436.03
# fb_fret_dict['f20'] = 445.52
# fb_fret_dict['f21'] = 455.138
### Frets (Fender Bullet Strat - Custom v2)
# fb_fret_dict = {}
# fb_fret_dict['f0'] = 0.0
# fb_fret_dict['f1'] = 48
# fb_fret_dict['f2'] = 90
# fb_fret_dict['f3'] = 126
# fb_fret_dict['f4'] = 161
# fb_fret_dict['f5'] = 192
# fb_fret_dict['f6'] = 220
# fb_fret_dict['f7'] = 245
# fb_fret_dict['f8'] = 270
# fb_fret_dict['f9'] = 292
# fb_fret_dict['f10'] = 312.5
# fb_fret_dict['f11'] = 329
# fb_fret_dict['f12'] = 348
# fb_fret_dict['f13'] = 364
# fb_fret_dict['f14'] = 379
# fb_fret_dict['f15'] = 392
# fb_fret_dict['f16'] = 405
# fb_fret_dict['f17'] = 416
# fb_fret_dict['f18'] = 427
# fb_fret_dict['f19'] = 437
# fb_fret_dict['f20'] = 446
# fb_fret_dict['f21'] = 455
### Frets (Fender Bullet Strat - Custom v2)
# Mantaining order of insertion by using OrderedDict
self.fb_fret_dict = OrderedDict([
('f0', 0.0), ('f1', 48.0), ('f2', 90.0), ('f3', 126.0), ('f4', 161.0), ('f5', 192.0),
('f6', 220.0), ('f7', 245.0), ('f8', 270.0), ('f9', 292.0), ('f10', 312.5), ('f11', 329.0),
('f12', 348.0), ('f13', 364.0), ('f14', 379.0), ('f15', 392.0), ('f16', 405.0), ('f17', 416.0),
('f18', 427.0), ('f19', 437.0), ('f20', 446.0), ('f21', 455.0)
])
self.fb_string_fret_dict = OrderedDict([
# String 1
('s1f1', (int((self.fb_fret_dict['f1'] + self.fb_fret_dict['f0'])/2), int(self.fb_string_dict['s1']))),
('s1f2', (int((self.fb_fret_dict['f2'] + self.fb_fret_dict['f1'])/2), int(self.fb_string_dict['s1']))),
('s1f3', (int((self.fb_fret_dict['f3'] + self.fb_fret_dict['f2'])/2), int(self.fb_string_dict['s1']))),
('s1f4', (int((self.fb_fret_dict['f4'] + self.fb_fret_dict['f3'])/2), int(self.fb_string_dict['s1']))),
('s1f5', (int((self.fb_fret_dict['f5'] + self.fb_fret_dict['f4'])/2), int(self.fb_string_dict['s1']))),
('s1f6', (int((self.fb_fret_dict['f6'] + self.fb_fret_dict['f5'])/2), int(self.fb_string_dict['s1']))),
('s1f7', (int((self.fb_fret_dict['f7'] + self.fb_fret_dict['f6'])/2), int(self.fb_string_dict['s1']))),
('s1f8', (int((self.fb_fret_dict['f8'] + self.fb_fret_dict['f7'])/2), int(self.fb_string_dict['s1']))),
('s1f9', (int((self.fb_fret_dict['f9'] + self.fb_fret_dict['f8'])/2), int(self.fb_string_dict['s1']))),
('s1f10', (int((self.fb_fret_dict['f10'] + self.fb_fret_dict['f9'])/2), int(self.fb_string_dict['s1']))),
('s1f11', (int((self.fb_fret_dict['f11'] + self.fb_fret_dict['f10'])/2), int(self.fb_string_dict['s1']))),
('s1f12', (int((self.fb_fret_dict['f12'] + self.fb_fret_dict['f11'])/2), int(self.fb_string_dict['s1']))),
# String 2
('s2f1', (int((self.fb_fret_dict['f1'] + self.fb_fret_dict['f0'])/2), int(self.fb_string_dict['s2']))),
('s2f2', (int((self.fb_fret_dict['f2'] + self.fb_fret_dict['f1'])/2), int(self.fb_string_dict['s2']))),
('s2f3', (int((self.fb_fret_dict['f3'] + self.fb_fret_dict['f2'])/2), int(self.fb_string_dict['s2']))),
('s2f4', (int((self.fb_fret_dict['f4'] + self.fb_fret_dict['f3'])/2), int(self.fb_string_dict['s2']))),
('s2f5', (int((self.fb_fret_dict['f5'] + self.fb_fret_dict['f4'])/2), int(self.fb_string_dict['s2']))),
('s2f6', (int((self.fb_fret_dict['f6'] + self.fb_fret_dict['f5'])/2), int(self.fb_string_dict['s2']))),
('s2f7', (int((self.fb_fret_dict['f7'] + self.fb_fret_dict['f6'])/2), int(self.fb_string_dict['s2']))),
('s2f8', (int((self.fb_fret_dict['f8'] + self.fb_fret_dict['f7'])/2), int(self.fb_string_dict['s2']))),
('s2f9', (int((self.fb_fret_dict['f9'] + self.fb_fret_dict['f8'])/2), int(self.fb_string_dict['s2']))),
('s2f10', (int((self.fb_fret_dict['f10'] + self.fb_fret_dict['f9'])/2), int(self.fb_string_dict['s2']))),
('s2f11', (int((self.fb_fret_dict['f11'] + self.fb_fret_dict['f10'])/2), int(self.fb_string_dict['s2']))),
('s2f12', (int((self.fb_fret_dict['f12'] + self.fb_fret_dict['f11'])/2), int(self.fb_string_dict['s2']))),
# String 3
('s3f1', (int((self.fb_fret_dict['f1'] + self.fb_fret_dict['f0'])/2), int(self.fb_string_dict['s3']))),
('s3f2', (int((self.fb_fret_dict['f2'] + self.fb_fret_dict['f1'])/2), int(self.fb_string_dict['s3']))),
('s3f3', (int((self.fb_fret_dict['f3'] + self.fb_fret_dict['f2'])/2), int(self.fb_string_dict['s3']))),
('s3f4', (int((self.fb_fret_dict['f4'] + self.fb_fret_dict['f3'])/2), int(self.fb_string_dict['s3']))),
('s3f5', (int((self.fb_fret_dict['f5'] + self.fb_fret_dict['f4'])/2), int(self.fb_string_dict['s3']))),
('s3f6', (int((self.fb_fret_dict['f6'] + self.fb_fret_dict['f5'])/2), int(self.fb_string_dict['s3']))),
('s3f7', (int((self.fb_fret_dict['f7'] + self.fb_fret_dict['f6'])/2), int(self.fb_string_dict['s3']))),
('s3f8', (int((self.fb_fret_dict['f8'] + self.fb_fret_dict['f7'])/2), int(self.fb_string_dict['s3']))),
('s3f9', (int((self.fb_fret_dict['f9'] + self.fb_fret_dict['f8'])/2), int(self.fb_string_dict['s3']))),
('s3f10', (int((self.fb_fret_dict['f10'] + self.fb_fret_dict['f9'])/2), int(self.fb_string_dict['s3']))),
('s3f11', (int((self.fb_fret_dict['f11'] + self.fb_fret_dict['f10'])/2), int(self.fb_string_dict['s3']))),
('s3f12', (int((self.fb_fret_dict['f12'] + self.fb_fret_dict['f11'])/2), int(self.fb_string_dict['s3']))),
# String 4
('s4f1', (int((self.fb_fret_dict['f1'] + self.fb_fret_dict['f0'])/2), int(self.fb_string_dict['s4']))),
('s4f2', (int((self.fb_fret_dict['f2'] + self.fb_fret_dict['f1'])/2), int(self.fb_string_dict['s4']))),
('s4f3', (int((self.fb_fret_dict['f3'] + self.fb_fret_dict['f2'])/2), int(self.fb_string_dict['s4']))),
('s4f4', (int((self.fb_fret_dict['f4'] + self.fb_fret_dict['f3'])/2), int(self.fb_string_dict['s4']))),
('s4f5', (int((self.fb_fret_dict['f5'] + self.fb_fret_dict['f4'])/2), int(self.fb_string_dict['s4']))),
('s4f6', (int((self.fb_fret_dict['f6'] + self.fb_fret_dict['f5'])/2), int(self.fb_string_dict['s4']))),
('s4f7', (int((self.fb_fret_dict['f7'] + self.fb_fret_dict['f6'])/2), int(self.fb_string_dict['s4']))),
('s4f8', (int((self.fb_fret_dict['f8'] + self.fb_fret_dict['f7'])/2), int(self.fb_string_dict['s4']))),
('s4f9', (int((self.fb_fret_dict['f9'] + self.fb_fret_dict['f8'])/2), int(self.fb_string_dict['s4']))),
('s4f10', (int((self.fb_fret_dict['f10'] + self.fb_fret_dict['f9'])/2), int(self.fb_string_dict['s4']))),
('s4f11', (int((self.fb_fret_dict['f11'] + self.fb_fret_dict['f10'])/2), int(self.fb_string_dict['s4']))),
('s4f12', (int((self.fb_fret_dict['f12'] + self.fb_fret_dict['f11'])/2), int(self.fb_string_dict['s4']))),
# String 5
('s5f1', (int((self.fb_fret_dict['f1'] + self.fb_fret_dict['f0'])/2), int(self.fb_string_dict['s5']))),
('s5f2', (int((self.fb_fret_dict['f2'] + self.fb_fret_dict['f1'])/2), int(self.fb_string_dict['s5']))),
('s5f3', (int((self.fb_fret_dict['f3'] + self.fb_fret_dict['f2'])/2), int(self.fb_string_dict['s5']))),
('s5f4', (int((self.fb_fret_dict['f4'] + self.fb_fret_dict['f3'])/2), int(self.fb_string_dict['s5']))),
('s5f5', (int((self.fb_fret_dict['f5'] + self.fb_fret_dict['f4'])/2), int(self.fb_string_dict['s5']))),
('s5f6', (int((self.fb_fret_dict['f6'] + self.fb_fret_dict['f5'])/2), int(self.fb_string_dict['s5']))),
('s5f7', (int((self.fb_fret_dict['f7'] + self.fb_fret_dict['f6'])/2), int(self.fb_string_dict['s5']))),
('s5f8', (int((self.fb_fret_dict['f8'] + self.fb_fret_dict['f7'])/2), int(self.fb_string_dict['s5']))),
('s5f9', (int((self.fb_fret_dict['f9'] + self.fb_fret_dict['f8'])/2), int(self.fb_string_dict['s5']))),
('s5f10', (int((self.fb_fret_dict['f10'] + self.fb_fret_dict['f9'])/2), int(self.fb_string_dict['s5']))),
('s5f11', (int((self.fb_fret_dict['f11'] + self.fb_fret_dict['f10'])/2), int(self.fb_string_dict['s5']))),
('s5f12', (int((self.fb_fret_dict['f12'] + self.fb_fret_dict['f11'])/2), int(self.fb_string_dict['s5']))),
# String 6
('s6f1', (int((self.fb_fret_dict['f1'] + self.fb_fret_dict['f0'])/2), int(self.fb_string_dict['s6']))),
('s6f2', (int((self.fb_fret_dict['f2'] + self.fb_fret_dict['f1'])/2), int(self.fb_string_dict['s6']))),
('s6f3', (int((self.fb_fret_dict['f3'] + self.fb_fret_dict['f2'])/2), int(self.fb_string_dict['s6']))),
('s6f4', (int((self.fb_fret_dict['f4'] + self.fb_fret_dict['f3'])/2), int(self.fb_string_dict['s6']))),
('s6f5', (int((self.fb_fret_dict['f5'] + self.fb_fret_dict['f4'])/2), int(self.fb_string_dict['s6']))),
('s6f6', (int((self.fb_fret_dict['f6'] + self.fb_fret_dict['f5'])/2), int(self.fb_string_dict['s6']))),
('s6f7', (int((self.fb_fret_dict['f7'] + self.fb_fret_dict['f6'])/2), int(self.fb_string_dict['s6']))),
('s6f8', (int((self.fb_fret_dict['f8'] + self.fb_fret_dict['f7'])/2), int(self.fb_string_dict['s6']))),
('s6f9', (int((self.fb_fret_dict['f9'] + self.fb_fret_dict['f8'])/2), int(self.fb_string_dict['s6']))),
('s6f10', (int((self.fb_fret_dict['f10'] + self.fb_fret_dict['f9'])/2), int(self.fb_string_dict['s6']))),
('s6f11', (int((self.fb_fret_dict['f11'] + self.fb_fret_dict['f10'])/2), int(self.fb_string_dict['s6']))),
('s6f12', (int((self.fb_fret_dict['f12'] + self.fb_fret_dict['f11'])/2), int(self.fb_string_dict['s6']))),
])
# logging.debug('fb_string_fret_dict {}'.format(self.fb_string_fret_dict))
def get_fretboard_overlay_basic(self):
# img_overlay = img_dst.copy()
# 4th channel is alpha
# fb_scale = 2.0
img_overlay = np.zeros((int(self.fb_h*self.fb_scale), int(self.fb_w*self.fb_scale), 4), np.uint8)
# self.fb_scale = 1.0
img_overlay[:,:,0:3] = 255
img_overlay[:,:,3] = 3 # Alpha channel values: [0:10]
### FretBoard
x, y, w, h = int(0*self.fb_scale), int(0*self.fb_scale), int(self.fb_w*self.fb_scale), int(self.fb_h*self.fb_scale)
cv2.rectangle(img_overlay, (x, y), (x+w, y+h), (0, 200, 0), 0) # A filled rectangle
### Strings
for string_name, string_height in self.fb_string_dict.items():
x1, y1, x2, y2 = int(0*self.fb_scale), int(string_height*self.fb_scale), int(self.fb_w*self.fb_scale), int(string_height*self.fb_scale)
cv2.line(img_overlay, (x1, y1), (x2, y2), (0,255,0), 1)
# for fret_name, fret_width in self.fb_fret_dict.items():
# x1, y1, x2, y2 = int(fret_width*self.fb_scale), int(0*self.fb_scale), int(fret_width*self.fb_scale), int(self.fb_h*self.fb_scale)
# cv2.line(img_overlay, (x1, y1), (x2, y2), (0,255,0), 1)
# cv2.flip(img_overlay, 1, img_overlay)
return img_overlay
def get_fretboard_overlay(self):
# img_overlay = img_dst.copy()
# 4th channel is alpha
# fb_scale = 2.0
img_overlay = np.zeros((int(self.fb_h*self.fb_scale), int(self.fb_w*self.fb_scale), 4), np.uint8)
# self.fb_scale = 1.0
img_overlay[:,:,0:3] = 255
img_overlay[:,:,3] = 7 # Alpha channel values: [0:10]
### FretBoard
x, y, w, h = int(0*self.fb_scale), int(0*self.fb_scale), int(self.fb_w*self.fb_scale), int(self.fb_h*self.fb_scale)
# logging.debug('x,y,w,h: {} {} {} {}'.format(x, y, w, h))
cv2.rectangle(img_overlay, (x, y), (x+w, y+h), (0, 200, 0), 0) # A filled rectangle
# alpha = 0.4
# img_overlay = cv2.addWeighted(img_overlay, alpha, img_overlay, 1 - alpha, 0)
# img_overlay = cv2.addWeighted(src1=overlay, alpha=1, src2=img_dst, beta=0.5, gamma=0)
### Strings
for string_name, string_height in self.fb_string_dict.items():
x1, y1, x2, y2 = int(0*self.fb_scale), int(string_height*self.fb_scale), int(self.fb_w*self.fb_scale), int(string_height*self.fb_scale)
cv2.line(img_overlay, (x1, y1), (x2, y2), (0,255,0), 1)
for fret_name, fret_width in self.fb_fret_dict.items():
x1, y1, x2, y2 = int(fret_width*self.fb_scale), int(0*self.fb_scale), int(fret_width*self.fb_scale), int(self.fb_h*self.fb_scale)
cv2.line(img_overlay, (x1, y1), (x2, y2), (0,255,0), 1)
# for string_fret_name, string_pos in self.fb_string_fret_dict.items():
# logging.debug('string_fret_name {}'.format(string_fret_name))
# logging.debug('string_pos {}'.format(string_pos))
# cv2.circle(img_overlay, center=(string_pos), radius=3, color=(255, 0, 0), thickness=1)
## Flip around axis
# cv2.flip(img_overlay, 1, img_overlay)
return img_overlay
def add_fretboard_overlay_notes(self, img_overlay, notes):
# logging.debug('notes {}'.format(notes))
notes_pos = []
for note in notes:
# logging.debug('note {}'.format(note))
# logging.debug('string_fret_name {}'.format(string_fret_name))
# logging.debug('string_pos {}'.format(string_pos))
if note is not None:
string_pos = self.fb_string_fret_dict[note[0]]
cv2.circle(img_overlay, center=(string_pos), radius=3, color=(255, 255, 0), thickness=2)
# TODO: Flipping notes for display
notes_pos.append([float(self.fb_w - string_pos[0]), float(string_pos[1])])
else:
notes_pos.append(None)
return notes_pos
def update_fretboard_overlay_got(self, img_overlay, progression_time):
if progression_time%10 == 0:
prog_time = int(progression_time/10)
# print('progression_time', progression_time)
# print('prog_time', prog_time)
if prog_time < len(self.progression) and self.progression[prog_time] is not None:
notes_pos = self.add_fretboard_overlay_notes(img_overlay, notes=self.progression[prog_time])
# print('notes_pos', notes_pos)
return notes_pos
else:
return None
return None
def tab_got(self):
self.progression = [
[['s4f1']],
[['s5f3']],
[['s4f1']],
[['s4f2']],
[['s4f1']],
[['s5f3']],
[['s4f1']],
[['s4f3']],
[['s4f1']],
[['s5f2']],
[['s4f1']],
[['s4f3']],
[['s4f1']],
[['s5f3']],
[['s4f1']],
[['s4f3']],
[['s4f1']],
[['s5f3']],
[['s4f1']],
[['s4f3']],
[['s4f1']],
[['s5f3']],
[['s4f2']],
[['s4f3']],
[['s4f1']],
[['s5f3']],
[['s4f2']],
[['s4f3']],
[['s4f1']],
[['s5f3']],
[['s4f2']],
[['s4f2']],
[['s4f1']],
[['s5f3']],
[['s4f2']],
[['s4f3']],
[['s4f1']],
[['s2f1']],
[['s5f2']],
[['s3f3']],
[['s4f1']],
[['s2f3']],
[['s4f3']],
[['s4f4']],
[['s5f2']],
[['s1f1']],
[['s4f3']],
[['s2f1']],
[['s5f3']],
[['s4f1']],
[['s1f2']],
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
# [['s5f1']],
# [['s5f3']],
# [['s2f1']],
# [['s4f3']],
# [['s5f1']],
# [['s5f3']],
# [['s4f1']],
# [['s4f3']],
# [['s2f4']],
# [['s5f3']],
# [['s4f1']],
# [['s1f3']],
# [['s4f1']],
# [['s5f3']],
# [['s5f1']],
# [['s4f4']],
# [['s4f1']],
# [['s5f3']],
# [['s1f1']],
# [['s4f3']],
# [['s4f1']],
# [['s1f3']],
# [['s4f4']],
# [['s5f3']],
# [['s4f1']],
# [['s5f3']],
# [['s4f1']],
# [['s4f3']],
# [['s4f4']],
# [['s2f3']],
# [['s4f1']],
# [['s5f3']],
# [['s4f1']],
# [['s5f3']],
# [['s1f1']],
# [['s4f4']],
# [['s4f1']],
# [['s5f3']],
# [['s1f1']],
# [['s4f3']],
# [['s4f4']],
# [['s5f3']],
]
if __name__ == '__main__':
# https://tlcguitargoods.com/en/howto-fret-calculator
output_dir = 'output'
fb = FretBoard(output_dir)
fb_overlay = fb.get_fretboard_overlay()
progression_time = 1
fb.update_fretboard_overlay_got(fb_overlay, progression_time)
cv2.flip(fb_overlay, 1, fb_overlay)
img_dst = cv2.imread('data/guitar/test/2019-05-28-085835_1.jpg')
fb.overlay_image_alpha(img_dst,
fb_overlay[:, :, 0:3],
(0, 0),
fb_overlay[:, :, 3]/10)
cv2.imwrite(os.path.join(output_dir, 'img_overlay_dst.jpg'), img_dst)