Commit 1f431075 authored by Robozman's avatar Robozman

merged

parent 494d37f7
......@@ -3,6 +3,7 @@ matplotlib.use('TkAgg')
import time
import matplotlib.pyplot as plt
import numpy as np
import scipy
import scipy.io.wavfile as wavfile
from scipy import signal
import sounddevice
......@@ -86,7 +87,8 @@ timestep = 1/24
t = time.time()
origin = time.time()
nextBeat = 0
cap = cv2.VideoCapture("sn.webm")
cap = cv2.VideoCapture('snow.webm')
is_beat = False
while t - origin < len(wav_data) / rate:
ret, frame = cap.read()
if load_from_file == True:
......@@ -94,6 +96,7 @@ while t - origin < len(wav_data) / rate:
if time.time() - origin >= beat_times[nextBeat]:
nextBeat += 1
print(f"Beat {t - origin}")
is_beat = True
except:
print("Last beat encountered")
......@@ -115,24 +118,25 @@ while t - origin < len(wav_data) / rate:
h, s, v = cv2.split(hsv_frame)
#v = np.where(True, 255 * (350 - max_val) / 350, 255)
#v *= math.floor((350 - max_val) / 350)
np.multiply(v, (350 - max_val) / 350, out=v, casting='unsafe')
np.multiply(v, (((350 - max_val) / 350) + 0.5*5)/6, out=v, casting='unsafe')
final_hsv = cv2.merge((h, s, v))
img = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)
#image.xticks([])
#image.ytacks([])
#image.show()
a = np.abs(np.fft.fftshift(np.fft.fft(second[:])))
fftToImage.fftToImage(a, image)
# cv2.imshow("t", (img * (1/255) + image).clip(0, 1))
preV = (img * (1/255) + image).clip(0, 1)
#fftToImage.fftToImage(a, image)
#cv2.imshow("t", (img * (1/255) + image).clip(0, 1))
preV = (img * (1/255)).clip(0, 1)
row,cols,rgb = img.shape
a = cv2.getGaussianKernel(cols,200.0)
b = cv2.getGaussianKernel(row,200.0)
a = cv2.getGaussianKernel(cols,300.0)
b = cv2.getGaussianKernel(row,300.0)
c = b*a.T
d = c/c.max()
d = np.array([d, d, d]).transpose(1, 2, 0)
preV = preV * d
preV = preV * ( d * 10)
#print(preV)
cv2.imshow('frame', preV)
cv2.waitKey(1)
# cv2.imshow('frame', img)
......@@ -140,6 +144,8 @@ while t - origin < len(wav_data) / rate:
peaks, _ = signal.find_peaks(transform, prominence=20)
is_beat = False
plot = False
if plot is True:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment