-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
91 lines (70 loc) · 2.56 KB
/
Copy pathtest.py
File metadata and controls
91 lines (70 loc) · 2.56 KB
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
import cv2
import os
import functions as fs
import modules as md
import pitchDetection
import time
resource_path = os.getcwd() + "/resources/"
src = cv2.imread(resource_path + "music66.jpg")
final_list = []
start = time.time()
image = md.deskew(src)
image_0, subimages = md.remove_noise(image)
normalized_images, stave_list = md.digital_preprocessing(image_0, subimages)
rec_list, note_list, rest_list = md.beat_extraction(normalized_images)
print('note_list: ')
print(note_list)
print('\nrec_list: ')
print(rec_list)
clef_list = pitchDetection.detect1(cv2.cvtColor(cv2.bitwise_not(image_0), cv2.COLOR_GRAY2BGR))
note_list2, pitch_list = md.pitch_extraction(stave_list, normalized_images, clef_list)
print('\nclef_list: ')
print(clef_list)
print('\nnote_list2: ')
print(note_list2)
print('\npitch_list: ')
print(pitch_list)
rec_list = fs.standardize_sharps(rec_list)
note_list2 = fs.standardize_keysharps(note_list2)
print('\nrec_list(changed): ')
print(rec_list)
print('\nnote_list2(changed): ')
print(note_list2)
# synchronize_sharps_and_keysharps 함수 호출
rec_list, note_list2 = fs.synchronize_sharps_and_keysharps(rec_list, note_list2)
print('\nrec_list(changed2): ')
print(rec_list)
print('\nnote_list2(changed2): ')
print(note_list2)
for i, (rec, pitches) in enumerate(zip(rec_list, pitch_list)):
sharps, flats = fs.count_sharps_flats(rec)
# 만약 sharps와 flats가 0이라면 기본값을 사용 (예: sharps=0, flats=0)
if sharps == 0 and flats == 0:
sharps = 0
flats = 0
temp_dict = {}
clef_type = pitches[0] # clef type is the first element
modified_pitches = fs.modify_notes(pitches[1:], sharps, flats) # Skip the clef type in pitches
for pit in modified_pitches:
if clef_type == 0:
positions = fs.get_guitar(pit)
elif clef_type == 1:
positions = fs.get_bass_guitar(pit)
temp_dict[pit] = positions
modified_pitches = fs.calculate_efficient_positions(modified_pitches, temp_dict)
pitch_list[i] = [clef_type] + modified_pitches # Update the pitch_list with modified pitches including clef type
for note2, note1 in zip(note_list2, note_list):
note2[1:] = fs.update_notes(note2[1:], note1)
print('\nnote_list2(changed3): ')
print(note_list2)
print('\npitch_list2: ')
print(pitch_list)
for list1, list2, list3 in zip(rec_list, note_list2, pitch_list):
m_list = fs.merge_three_lists(list1, list2, list3)
final_list.append(m_list)
print('\nfinal_list: ')
print(final_list)
sen = fs.convert_to_sentence(final_list)
print(sen)
end = time.time()
print(f"{end - start:.5f} sec")