Commit d72f0cc2 authored by Jackson Garner's avatar Jackson Garner

Add fft to image

parent 80ef7608
def fftToImage(a, image):
start = 0
for i in a:
if i < .2:
start += 1
else:
break
a = a[start:a.size - start]
i = 0
print(image.shape)
jump = a.size / image.shape[1] * 10
if a.size != 0:
for p in image.transpose(1, 0, 2):
p[:] = a[int(int(i)*jump)] * 10
i += 0.1
image *= 0.5/image.max()
......@@ -14,6 +14,7 @@ import cv2
import librosaToWave
import generate_waves
import fftToImage
load_from_file = False
file_name = None
......@@ -71,6 +72,8 @@ fig = plt.figure()
fft_plot = fig.add_subplot(121)
#image = fig.add_subplot(122)
image = np.ones((480, 640, 3))
sounddevice.play(wav_data, rate)
timestep = .01
......@@ -115,17 +118,18 @@ while t - origin < len(wav_data) / rate:
#image.xticks([])
#image.ytacks([])
#image.show()
cv2.imshow('frame', img)
a = np.abs(np.fft.fftshift(np.fft.fft(second[:])))
fftToImage.fftToImage(a, image)
cv2.imshow("t", (img * (1/255) + image).clip(0, 1))
cv2.waitKey(1)
# cv2.imshow('frame', img)
# cv2.waitKey(1)
peaks, _ = signal.find_peaks(transform, prominence=20)
plot = False
if plot is True:
print(peaks)
fft_plot.clear()
if load_from_file == 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