diff --git a/.cache b/.cache deleted file mode 100644 index 387f693..0000000 --- a/.cache +++ /dev/null @@ -1 +0,0 @@ -{"access_token": "BQDeVV_yylewo72n9ZtSMTn1WNhJKSbUBDKv18Cl-QY7dphidwC9jDuGuZWKaIWZv-fVIG1uuP1XvJFKwcj3GOxgRxYJbaWOLtogCHkAxC-iOaZe6uphn-vCy5rbX6Xlx9XVUG-jHNu0jaCf1-ueTRUQuyF0Btu4_aAcIktTnYyofSUJuk_Mdi1J6V3hmARkCl34Rv-4hgfXcIqQ_rpdCFHGheEU1rSL5oME", "token_type": "Bearer", "expires_in": 3600, "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1757966041, "refresh_token": "AQAxD3wm_8aDlK9w2ZsibKsrPY0SxUJb2UaqiT2ygxK-pEq2ojxPzgLa6DNt9EpP3mjFDCLmGO5glj5fSpR3ZnqEa26belG4EQv5FOeee38ix31o2xuxPbDsY44KR5Uj1KE"} \ No newline at end of file diff --git a/final-loop/Dockerfile b/final-loop/Dockerfile new file mode 100644 index 0000000..71c5ea5 --- /dev/null +++ b/final-loop/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY requirements.txt ./ + +RUN pip install --no-cache-dir -r requirements.txt + +COPY src/ . + diff --git a/final-loop/client-cache/credentials.json b/final-loop/client-cache/credentials.json new file mode 100644 index 0000000..42c2078 --- /dev/null +++ b/final-loop/client-cache/credentials.json @@ -0,0 +1 @@ +{"username":"mathias-120","auth_type":1,"auth_data":"QWdDZF9iOVZDTUltQ0Noc0lnSFdfNU5QOXBMdFdiQllFclJ3dHM3ZVRaY1lzUEpKd1Jwc1pOc3FzdjFwYnRYZ2ZRSXE2Q1ZiWTBjdzRDTUYzdkJMekdqOVliRTh1UldlZlJOdF94eEgydzJUWmhtT0RlX295ODdrTzZDYXFuMW5SVEQ4TV95S2R0aEJLTDZldkxPeDlva0wtcHJNY0p6Q3VzQl9YOGFhVHNYaw=="} \ No newline at end of file diff --git a/final-loop/client-cache/volume b/final-loop/client-cache/volume new file mode 100644 index 0000000..35ff949 --- /dev/null +++ b/final-loop/client-cache/volume @@ -0,0 +1 @@ +65535 \ No newline at end of file diff --git a/final-loop/compose.yml b/final-loop/compose.yml new file mode 100644 index 0000000..51b0d73 --- /dev/null +++ b/final-loop/compose.yml @@ -0,0 +1,34 @@ +services: + librespot: + container_name: spotvinyl-client + image: giof71/librespot:latest + network_mode: host + devices: + - /dev/snd:/dev/snd + environment: + - DEVICE=hw:x20,0 + - BACKEND=alsa + - BITRATE=320 + - INITIAL_VOLUME=100 + - DEVICE_NAME=spotvinyl + - ENABLE_OAUTH=headless # Enables OAuth headless mode + - ENABLE_SYSTEM_CACHE=Y # Cache token for persistent login + volumes: + - ./client-cache:/data/system-cache + stdin_open: true + tty: true + + spotvinyl: + build: . + container_name: spotvinyl + devices: + - /dev/video2 + volumes: + - ./src:/app + # - ./spotvinyl-cache + working_dir: /app + env_file: + - .env + command: python3 decode_barcode.py + ports: + - "5000:5000" diff --git a/final-loop/requirements.txt b/final-loop/requirements.txt new file mode 100644 index 0000000..f58bc59 --- /dev/null +++ b/final-loop/requirements.txt @@ -0,0 +1,32 @@ +certifi==2025.11.12 +chardet==5.2.0 +charset-normalizer==3.4.4 +contourpy==1.3.3 +crccheck==1.3.1 +cycler==0.12.1 +decorator==5.2.1 +fonttools==4.60.1 +idna==3.11 +ImageIO==2.37.2 +joblib==1.5.2 +kiwisolver==1.4.9 +lazy_loader==0.4 +matplotlib==3.10.7 +networkx==3.5 +numpy==2.2.6 +opencv-python==4.12.0.88 +packaging==25.0 +pillow==12.0.0 +pyparsing==3.2.5 +python-dateutil==2.9.0.post0 +PyWavelets==1.9.0 +redis==7.1.0 +requests==2.32.5 +scikit-image==0.25.2 +scikit-learn==1.7.2 +scipy==1.16.3 +six==1.17.0 +spotipy==2.25.1 +threadpoolctl==3.6.0 +tifffile==2025.10.16 +urllib3==2.5.0 diff --git a/final-loop/spotify-codes-part-2/.cache b/final-loop/spotify-codes-part-2/.cache deleted file mode 100644 index 573b327..0000000 --- a/final-loop/spotify-codes-part-2/.cache +++ /dev/null @@ -1 +0,0 @@ -{"access_token": "BQAHRFXWQMMKWNbUO3sfhk92iUGi5VJNZmB2lTjRim-g2AIe88mgDvyc1NywjCVBTeZK-b3PkXzGDANJDDOouitEt5P8z0jpVuPrpalwAg0PzEwtKBXr8PHvacajO9B3s7Wy0s7G3CFlfGfbOfmXtW_vF8G2_ooGnlFp_oM8RcOyBl7D5Okf6kr07CWIJty4mNeTf1Ifd212u1tBnbU64lckqlQ0f0W105mt", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "AQCSe9ARCDB-Q6gzna_KKAlcEuNOx2IC9BSVXS5GZxNDi4AjJdA4Kn3hp1YPfiPfogd2rz-5zLbyjUxiRj9oTd-q5EItEPZHIVt-eMf7gCGHfj6h-hLpRrnhgMZjzRAS7CY", "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1757966002} \ No newline at end of file diff --git a/final-loop/spotify-codes-part-2/requirements.txt b/final-loop/spotify-codes-part-2/requirements.txt deleted file mode 100644 index a77113c..0000000 --- a/final-loop/spotify-codes-part-2/requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -certifi>=2023.5.7 -chardet>=5.1.0 -crccheck>=1.0 -cycler>=0.11.0 -decorator>=5.1.1 -idna>=3.5 -imageio>=2.31.1 -kiwisolver>=1.4.4 -matplotlib>=3.7.1 -networkx>=3.1 -numpy>=1.24.2 -Pillow>=10.0.0 -pyparsing>=3.0.9 -python-dateutil>=2.8.2 -PyWavelets>=1.4.1 -requests>=2.31.0 -scikit-image>=0.25.2 -scipy>=1.11.1 -six>=1.16.0 -tifffile>=2023.7.23 -urllib3>=2.0.4 diff --git a/final-loop/spotify-codes-part-2/src/decode_barcode.py b/final-loop/spotify-codes-part-2/src/decode_barcode.py deleted file mode 100644 index 0bd7463..0000000 --- a/final-loop/spotify-codes-part-2/src/decode_barcode.py +++ /dev/null @@ -1,57 +0,0 @@ -import argparse -import pprint -from get_heights import get_heights -from encode_decode import spotify_bar_decode -from get_uri import get_uri, get_info -import cv2 - - -def process_frame(frame, token): - heights = get_heights(frame) - print(len(heights)) # assumes get_heights can take image array - if len(heights) != 23: - return None # skip bad frames - else: - print("ON TROUVE UN CODE") - - heights = heights[1:11] + heights[12:-1] - decoded = spotify_bar_decode(heights) - uri = get_uri(decoded, token) - summary, full_response = get_info(uri["target"], token) - return summary - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("--token", required=True) - args = parser.parse_args() - token = args.token - - cap = cv2.VideoCapture(0) # 0 for default webcam - - while True: - ret, frame = cap.read() - if not ret: - break - - # Définir les dimensions et la marge du cadre - height, width, _ = frame.shape - margin = 100 # ajustez la taille du cadre ici - frame = frame[margin:height - margin, margin:width - margin] - - try: - summary = process_frame(frame, token) - except Exception: - continue - - if summary: - print("Summary:") - pprint.pprint(summary) - - cv2.imshow("Live Barcode", frame) - - if cv2.waitKey(1) & 0xFF == ord('q'): - break - - cap.release() - cv2.destroyAllWindows() diff --git a/final-loop/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg b/final-loop/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg deleted file mode 100644 index 64eb04b..0000000 Binary files a/final-loop/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg and /dev/null differ diff --git a/final-loop/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg b/final-loop/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg deleted file mode 100644 index 47ed030..0000000 Binary files a/final-loop/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg and /dev/null differ diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/crc.py b/final-loop/src/crc.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/crc.py rename to final-loop/src/crc.py diff --git a/final-loop/src/decode_barcode.py b/final-loop/src/decode_barcode.py new file mode 100644 index 0000000..a56cfdd --- /dev/null +++ b/final-loop/src/decode_barcode.py @@ -0,0 +1,86 @@ +import argparse +import pprint +from get_heights import get_heights +from encode_decode import spotify_bar_decode +from get_uri import get_uri, get_info +import cv2 +from start_song import start_song +import os +from flask import Flask, Response +import threading +import time +import numpy as np + +os.environ["QT_QPA_PLATFORM"] = "xcb" +def process_frame(frame, token): + + heights,preprocess = get_heights(frame) + cv2.imshow("frame", preprocess) + if len(heights)!=23: + return None # skip bad frames + else: + print("ON TROUVE UN CODE") + + + heights = heights[1:11] + heights[12:-1] + decoded = spotify_bar_decode(heights) + uri = get_uri(decoded, token) + summary, full_response = get_info(uri["target"], token) + print(f"SONG FOUND : {summary["name"]}") + if uri: + start_song(uri['target'],os.getenv('DEVICE_ID')) + return summary + + + + + + + + + + +if __name__ == "__main__": + + + + cap = cv2.VideoCapture('/dev/video0') + + + token = os.getenv('ACCESS_TOKEN') + if not token: + token = "BQCph85n2Cr-h8jKWhsdsdhywaX3h_bn4pJ_-jdque2u_gn9bI-OdthIowGSU6r058QozL0eJfzy_ClWezXYKrQO2npuyfWVphxSQrKqhBWkGr5bK0UrIfsKKAdJvoNrXD9Db-ObgP5D3-rMpF0Xq3RXwMpTal9NpzTJcHZs_PBjbNClJVy24Jk5WfGbKZPkMs_Hon5TjABx4QzxzE2vxjd4X4EyPlyPuKiIVp-f7yTSJbbRLqt-_O_VJ9mnQ1RgGK16afY7p3JZH_B6-VSCrFuhK_m9yhSieiWoqEeopFEX47Nc4-tuqe8CXcYGiRLZBIcc4w64ly36ZIftxRN7ehcJb2gcV26ZqMS1lg1Yxp0OD4ShJJsinA69X535_w" + print(token) + + + if not cap.isOpened(): + print("Error: Could not open camera.") + exit(1) + else: + print("Camera is working and ready to capture frames.") + + while True: + ret, frame = cap.read() + if not ret: + break + # Crop same as streaming for consistency + height, width, _ = frame.shape + margin = 100 + frame = frame[margin:height - margin, margin:width - margin] + + try: + + + summary = process_frame(frame, token) + + except Exception as e: + print(e) + print("") + continue + # cv2.imshow("preframe", frame) + + if cv2.waitKey(1) & 0xFF == ord('q'): + break + + cap.release() + cv2.destroyAllWindows() \ No newline at end of file diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/encode_decode.py b/final-loop/src/encode_decode.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/encode_decode.py rename to final-loop/src/encode_decode.py diff --git a/final-loop/spotify-codes-part-2/src/get_heights.py b/final-loop/src/get_heights.py similarity index 57% rename from final-loop/spotify-codes-part-2/src/get_heights.py rename to final-loop/src/get_heights.py index 38b8ea4..a2a6e50 100644 --- a/final-loop/spotify-codes-part-2/src/get_heights.py +++ b/final-loop/src/get_heights.py @@ -8,24 +8,46 @@ from skimage.color import rgb2gray import matplotlib.patches as patches from sklearn.cluster import KMeans import warnings +from skimage.morphology import remove_small_objects +from skimage.transform import resize +from skimage import exposure +from skimage.morphology import erosion, square +import cv2 +from skimage.filters import threshold_local +from scipy import ndimage as ndi +from skimage.segmentation import watershed +from skimage.morphology import opening, rectangle +from scipy.ndimage import gaussian_filter warnings.filterwarnings("ignore", category=FutureWarning, message=".*square.*deprecated.*") - +#### keep this. If does not work, remove black and reaply the logic only to not-black part of the picture def get_heights(image): # image = io.imread(filename) + + im = rgb2gray(image) - binary_im = im > threshold_otsu(im) - smooth_im = gaussian(binary_im.astype(float), sigma=1) - morph_im = closing(smooth_im > 0.5, square(3)) - labeled = label(morph_im) + + # Filtrage gaussien léger pour diminuer bruit + im_blur = gaussian_filter(im, sigma=1) + + # Calcul du seuil local avec block_size impair, ajuster offset si besoin + th = threshold_local(im_blur, block_size=71, offset=-0.09) + + binary_im = im_blur > th + + separated = binary_im + labeled = label(separated) + bar_dims = [r.bbox for r in regionprops(labeled)] bar_dims.sort(key=lambda x: x[1]) # left to right - bars = bar_dims[1:] # skip logo + bars = bar_dims#[1:] # skip logo bar_heights_raw = [] if(len(bars)!=23): - return [0] + print(len(bars)) + return [0], (separated.astype("uint8") * 255) # convert to 0/255 uint8 + for bar in bars: top, left, bottom, right = bar effective_height = bottom - top # use bounding box height directly @@ -44,5 +66,5 @@ def get_heights(image): closest_cluster = np.argmin(diffs) predicted_levels.append(int(closest_cluster)) - - return predicted_levels + print(predicted_levels) + return predicted_levels, (separated.astype("uint8") * 255) diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/get_uri.py b/final-loop/src/get_uri.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/get_uri.py rename to final-loop/src/get_uri.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/permute.py b/final-loop/src/permute.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/permute.py rename to final-loop/src/permute.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/simple_convolutional_code.py b/final-loop/src/simple_convolutional_code.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/simple_convolutional_code.py rename to final-loop/src/simple_convolutional_code.py diff --git a/main.py b/final-loop/src/start_song.py similarity index 69% rename from main.py rename to final-loop/src/start_song.py index 852fbfe..ac6e89d 100644 --- a/main.py +++ b/final-loop/src/start_song.py @@ -9,7 +9,7 @@ REDIRECT_URI = 'https://vinyly.couraud.xyz' SCOPE = 'user-modify-playback-state user-read-playback-state' -def main(): +def start_song(URI="spotify:track:0RoA7ObU6phWpqhlC9zH4Z",device_id="a499b8f3684d8098ffb5f9ff11392ebdd61fc6d1"): auth_manager = SpotifyOAuth(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, redirect_uri=REDIRECT_URI, @@ -26,28 +26,18 @@ def main(): sp = spotipy.Spotify(auth_manager=auth_manager) - if len(sys.argv) < 2: - print('Usage: python play_spotify.py "song name"') - sys.exit(1) - - song_name = ' '.join(sys.argv[1:]) - - results = sp.search(q=song_name, type='track', limit=1) - if not results['tracks']['items']: - print(f'No track found for: {song_name}') - sys.exit(1) - - track_uri = results['tracks']['items'][0]['uri'] devices = sp.devices() if not devices['devices']: print('No active Spotify devices found. Please start playback on a device.') sys.exit(1) - active_device_id = devices['devices'][0]['id'] - - sp.start_playback(device_id=active_device_id, uris=[track_uri]) - print(f'Playing "{song_name}" on device ID: {active_device_id}') + current = sp.current_user_playing_track() + if current and current.get("item"): + current_uri = current["item"]["uri"] + + if current_uri != URI: + sp.start_playback(device_id=device_id, uris=[URI]) if __name__ == '__main__': - main() \ No newline at end of file + start_song(URI,device_id) diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/step_by_step.py b/final-loop/src/step_by_step.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/step_by_step.py rename to final-loop/src/step_by_step.py diff --git a/old/.cache b/old/.cache new file mode 100644 index 0000000..bb567df --- /dev/null +++ b/old/.cache @@ -0,0 +1 @@ +{"access_token": "BQBR3Dnu7QMSOnq8G_8lOiz858WKJmMxiCgskqjp3QDu17EcQWx3Y8ALVQGSXzUcTgkJb-z5oHjJxEQJNfz8tSYREfJGGMKQfoCo0P2tCUbnB0wdGm7iSmWOlYuvrnDTVleJ9nJBGG6vVGc2ZEIl43T54_TmKbkPzampV8FuuGIATUvzbjRO6uEHqzc3ImuBELCZJjj0n8-h4zImXifkJP6pssEY76_GWgKo_HVx", "token_type": "Bearer", "expires_in": 3600, "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1763737778, "refresh_token": "AQAxD3wm_8aDlK9w2ZsibKsrPY0SxUJb2UaqiT2ygxK-pEq2ojxPzgLa6DNt9EpP3mjFDCLmGO5glj5fSpR3ZnqEa26belG4EQv5FOeee38ix31o2xuxPbDsY44KR5Uj1KE"} \ No newline at end of file diff --git a/anaislpb.py b/old/anaislpb.py similarity index 100% rename from anaislpb.py rename to old/anaislpb.py diff --git a/rebirth.jpg b/old/rebirth.jpg similarity index 100% rename from rebirth.jpg rename to old/rebirth.jpg diff --git a/shapeDetectionImageCrop.py b/old/shapeDetectionImageCrop.py similarity index 100% rename from shapeDetectionImageCrop.py rename to old/shapeDetectionImageCrop.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/.cache b/old/spotify-codes-part-2/.cache similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/.cache rename to old/spotify-codes-part-2/.cache diff --git a/boonepeter.github.io-code/spotify-codes-part-2/README.md b/old/spotify-codes-part-2/README.md similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/README.md rename to old/spotify-codes-part-2/README.md diff --git a/boonepeter.github.io-code/spotify-codes-part-2/aa.jpg b/old/spotify-codes-part-2/aa.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/aa.jpg rename to old/spotify-codes-part-2/aa.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/allo.jpg b/old/spotify-codes-part-2/allo.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/allo.jpg rename to old/spotify-codes-part-2/allo.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/aloorrrrr.jpg b/old/spotify-codes-part-2/aloorrrrr.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/aloorrrrr.jpg rename to old/spotify-codes-part-2/aloorrrrr.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/biz.jpg b/old/spotify-codes-part-2/biz.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/biz.jpg rename to old/spotify-codes-part-2/biz.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/biz.png b/old/spotify-codes-part-2/biz.png similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/biz.png rename to old/spotify-codes-part-2/biz.png diff --git a/boonepeter.github.io-code/spotify-codes-part-2/bizrog.jpg b/old/spotify-codes-part-2/bizrog.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/bizrog.jpg rename to old/spotify-codes-part-2/bizrog.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/bw.jpg b/old/spotify-codes-part-2/bw.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/bw.jpg rename to old/spotify-codes-part-2/bw.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/bz.jpg b/old/spotify-codes-part-2/bz.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/bz.jpg rename to old/spotify-codes-part-2/bz.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/code.jpeg b/old/spotify-codes-part-2/code.jpeg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/code.jpeg rename to old/spotify-codes-part-2/code.jpeg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/csq.jpg b/old/spotify-codes-part-2/csq.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/csq.jpg rename to old/spotify-codes-part-2/csq.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/imperdable.jpg b/old/spotify-codes-part-2/imperdable.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/imperdable.jpg rename to old/spotify-codes-part-2/imperdable.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/jtd.jpg b/old/spotify-codes-part-2/jtd.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/jtd.jpg rename to old/spotify-codes-part-2/jtd.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/jtd.png b/old/spotify-codes-part-2/jtd.png similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/jtd.png rename to old/spotify-codes-part-2/jtd.png diff --git a/boonepeter.github.io-code/spotify-codes-part-2/lala.jpeg b/old/spotify-codes-part-2/lala.jpeg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/lala.jpeg rename to old/spotify-codes-part-2/lala.jpeg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/layayaya.jpg b/old/spotify-codes-part-2/layayaya.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/layayaya.jpg rename to old/spotify-codes-part-2/layayaya.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/maybe.jpg b/old/spotify-codes-part-2/maybe.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/maybe.jpg rename to old/spotify-codes-part-2/maybe.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/maybe.png b/old/spotify-codes-part-2/maybe.png similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/maybe.png rename to old/spotify-codes-part-2/maybe.png diff --git a/boonepeter.github.io-code/spotify-codes-part-2/nggyu.jpg b/old/spotify-codes-part-2/nggyu.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/nggyu.jpg rename to old/spotify-codes-part-2/nggyu.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/nggyu.png b/old/spotify-codes-part-2/nggyu.png similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/nggyu.png rename to old/spotify-codes-part-2/nggyu.png diff --git a/boonepeter.github.io-code/spotify-codes-part-2/parfd.jpg b/old/spotify-codes-part-2/parfd.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/parfd.jpg rename to old/spotify-codes-part-2/parfd.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/print.jpg b/old/spotify-codes-part-2/print.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/print.jpg rename to old/spotify-codes-part-2/print.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/rage.jpg b/old/spotify-codes-part-2/rage.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/rage.jpg rename to old/spotify-codes-part-2/rage.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/rbw.jpg b/old/spotify-codes-part-2/rbw.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/rbw.jpg rename to old/spotify-codes-part-2/rbw.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/requirements.txt b/old/spotify-codes-part-2/requirements.txt similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/requirements.txt rename to old/spotify-codes-part-2/requirements.txt diff --git a/boonepeter.github.io-code/spotify-codes-part-2/rog.jpg b/old/spotify-codes-part-2/rog.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/rog.jpg rename to old/spotify-codes-part-2/rog.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/rogprint.jpg b/old/spotify-codes-part-2/rogprint.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/rogprint.jpg rename to old/spotify-codes-part-2/rogprint.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/rouuuge.jpg b/old/spotify-codes-part-2/rouuuge.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/rouuuge.jpg rename to old/spotify-codes-part-2/rouuuge.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/rr.jpeg b/old/spotify-codes-part-2/rr.jpeg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/rr.jpeg rename to old/spotify-codes-part-2/rr.jpeg diff --git a/final-loop/spotify-codes-part-2/src/crc.py b/old/spotify-codes-part-2/src/crc.py similarity index 100% rename from final-loop/spotify-codes-part-2/src/crc.py rename to old/spotify-codes-part-2/src/crc.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/decode_barcode.py b/old/spotify-codes-part-2/src/decode_barcode.py similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/decode_barcode.py rename to old/spotify-codes-part-2/src/decode_barcode.py diff --git a/final-loop/spotify-codes-part-2/src/encode_decode.py b/old/spotify-codes-part-2/src/encode_decode.py similarity index 100% rename from final-loop/spotify-codes-part-2/src/encode_decode.py rename to old/spotify-codes-part-2/src/encode_decode.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/get_heights.py b/old/spotify-codes-part-2/src/get_heights.py similarity index 94% rename from boonepeter.github.io-code/spotify-codes-part-2/src/get_heights.py rename to old/spotify-codes-part-2/src/get_heights.py index a263351..fb5e051 100644 --- a/boonepeter.github.io-code/spotify-codes-part-2/src/get_heights.py +++ b/old/spotify-codes-part-2/src/get_heights.py @@ -21,12 +21,12 @@ def get_heights(filename: str): bars = bar_dims[1:] # skip logo bar_heights_raw = [] - + print(len(bars)) for bar in bars: top, left, bottom, right = bar effective_height = bottom - top # use bounding box height directly bar_heights_raw.append(effective_height) - print(len(bars)) + # Cluster measured heights to 8 clusters representing discrete bar levels bar_heights_raw_np = np.array(bar_heights_raw).reshape(-1, 1) @@ -38,8 +38,8 @@ def get_heights(filename: str): for h in bar_heights_raw: diffs = np.abs(cluster_centers - h) closest_cluster = np.argmin(diffs) - predicted_levels.append(closest_cluster) + predicted_levels.append(int(closest_cluster)) - print(len(predicted_levels)) + print((predicted_levels)) return predicted_levels diff --git a/final-loop/spotify-codes-part-2/src/get_uri.py b/old/spotify-codes-part-2/src/get_uri.py similarity index 100% rename from final-loop/spotify-codes-part-2/src/get_uri.py rename to old/spotify-codes-part-2/src/get_uri.py diff --git a/final-loop/spotify-codes-part-2/src/permute.py b/old/spotify-codes-part-2/src/permute.py similarity index 100% rename from final-loop/spotify-codes-part-2/src/permute.py rename to old/spotify-codes-part-2/src/permute.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg b/old/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg rename to old/spotify-codes-part-2/src/pics/spotify_playlist_37i9dQZF1DXcBWIGoYBM5M.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg b/old/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg rename to old/spotify-codes-part-2/src/pics/spotify_track_6vQN2a9QSgWcm74KEZYfDL.jpg diff --git a/final-loop/spotify-codes-part-2/src/simple_convolutional_code.py b/old/spotify-codes-part-2/src/simple_convolutional_code.py similarity index 100% rename from final-loop/spotify-codes-part-2/src/simple_convolutional_code.py rename to old/spotify-codes-part-2/src/simple_convolutional_code.py diff --git a/final-loop/spotify-codes-part-2/src/step_by_step.py b/old/spotify-codes-part-2/src/step_by_step.py similarity index 100% rename from final-loop/spotify-codes-part-2/src/step_by_step.py rename to old/spotify-codes-part-2/src/step_by_step.py diff --git a/boonepeter.github.io-code/spotify-codes-part-2/st.jpeg b/old/spotify-codes-part-2/st.jpeg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/st.jpeg rename to old/spotify-codes-part-2/st.jpeg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/test.jpg b/old/spotify-codes-part-2/test.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/test.jpg rename to old/spotify-codes-part-2/test.jpg diff --git a/boonepeter.github.io-code/spotify-codes-part-2/testrouge.jpg b/old/spotify-codes-part-2/testrouge.jpg similarity index 100% rename from boonepeter.github.io-code/spotify-codes-part-2/testrouge.jpg rename to old/spotify-codes-part-2/testrouge.jpg diff --git a/test/compose.yml b/old/test/compose.yml similarity index 100% rename from test/compose.yml rename to old/test/compose.yml diff --git a/test/spotifyd.conf b/old/test/spotifyd.conf similarity index 100% rename from test/spotifyd.conf rename to old/test/spotifyd.conf