Commit db9a35ca authored by Jackson Garner's avatar Jackson Garner

Add better Vignette

parent b87330cd
......@@ -12,4 +12,4 @@ def fftToImage(a, image):
for p in image.transpose(1, 0, 2):
p[:] = a[int(int(i)*jump)] * 10
i += 0.1
image *= 0.5/image.max()
image *= 0.3/image.max()
......@@ -83,60 +83,60 @@ sounddevice.play(wav_data, rate)
timestep = .01
timestep = 1/24
t = time.time()
origin = time.time()
nextBeat = 0
cap = cv2.VideoCapture('snow.webm')
timestep = 1/cap.get(cv2.CAP_PROP_FPS)
is_beat = False
beat_distance = 0
while t - origin < len(wav_data) / rate:
ret, frame = cap.read()
if load_from_file == True:
try:
if time.time() - origin >= beat_times[nextBeat]:
nextBeat += 1
print(f"Beat {t - origin}")
# print(f"Beat {t - origin}")
is_beat = True
except:
print("Last beat encountered")
pass
# print("Last beat encountered")
while (time.time() - t < timestep):
pass
t = time.time()
beat_distance = beat_times[nextBeat] - time.time() + origin
second = wav_data[math.floor((t - origin) * rate) : math.floor((t - origin + timestep) * rate)]
# print(second)
transform = np.abs(np.fft.fft(second[:]))
plot_transform = np.fft.fftshift(transform)
print(ImageFunctions.getBaseWeight(transform))
# print(ImageFunctions.getBaseWeight(transform))
max_val = np.amax(transform)
hsv_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
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) + 0.5*5)/6, out=v, casting='unsafe')
np.multiply(s, (((350 - max_val) / 350) + 0.5*5)/6, out=s, 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)
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,300.0)
b = cv2.getGaussianKernel(row,300.0)
a = cv2.getGaussianKernel(cols, 350.0 / (beat_distance))
b = cv2.getGaussianKernel(row, 350.0 / (beat_distance))
c = b*a.T
d = c/c.max()
d = np.array([d, d, d]).transpose(1, 2, 0)
preV = preV * ( d * 10)
#print(preV)
d = np.array([d, d, d]).transpose(1, 2, 0) + image
preV = preV * ( d)
cv2.imshow('frame', preV)
cv2.waitKey(1)
# cv2.imshow('frame', img)
......
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