Added just getting frames and not displaying. Added publishing to ros and zeromq.
This commit is contained in:
@@ -6,4 +6,4 @@ def black_and_white(arr):
|
||||
return (np.sum(arr, axis=-1) / 3).astype(np.uint8)
|
||||
|
||||
|
||||
display(0, callbacks=black_and_white, blocking=True)
|
||||
display(0, callbacks=black_and_white, blocking=True)
|
||||
|
||||
@@ -5,9 +5,15 @@ from examples.videos import test_video
|
||||
|
||||
def forest_color(arr):
|
||||
forest_color.i += 1
|
||||
arr[..., 0] = (m.sin(forest_color.i * (2 * m.pi) * .4 / 360) * 255 + arr[..., 0]) % 255
|
||||
arr[..., 1] = (m.sin((forest_color.i * (2 * m.pi) * .5 + 45) / 360) * 255 + arr[..., 1]) % 255
|
||||
arr[..., 2] = (m.cos(forest_color.i * (2 * m.pi) * .3 / 360) * 255 + arr[..., 2]) % 255
|
||||
arr[..., 0] = (
|
||||
m.sin(forest_color.i * (2 * m.pi) * 0.4 / 360) * 255 + arr[..., 0]
|
||||
) % 255
|
||||
arr[..., 1] = (
|
||||
m.sin((forest_color.i * (2 * m.pi) * 0.5 + 45) / 360) * 255 + arr[..., 1]
|
||||
) % 255
|
||||
arr[..., 2] = (
|
||||
m.cos(forest_color.i * (2 * m.pi) * 0.3 / 360) * 255 + arr[..., 2]
|
||||
) % 255
|
||||
|
||||
|
||||
forest_color.i = 0
|
||||
|
||||
@@ -9,4 +9,4 @@ def fix_arr_cv(arr_in):
|
||||
arr_in %= 1.0
|
||||
|
||||
|
||||
display(arr, callbacks=fix_arr_cv, blocking=True)
|
||||
display(arr, callbacks=fix_arr_cv, blocking=True)
|
||||
|
||||
@@ -2,7 +2,7 @@ from displayarray import breakpoint_display
|
||||
import numpy as np
|
||||
|
||||
center = (75, 450)
|
||||
zoom = .5
|
||||
zoom = 0.5
|
||||
zoom_out = 1.0 / zoom
|
||||
|
||||
arr = np.random.uniform(0, 1, (300, 600, 3))
|
||||
@@ -13,8 +13,8 @@ x = np.arange(arr.shape[1])
|
||||
y_ = (y - center[0]) * zoom_out / arr.shape[0]
|
||||
x_ = (x - center[1]) * zoom_out / arr.shape[1]
|
||||
p = np.array(np.meshgrid(x_, y_))
|
||||
breakpoint_display(p[0] + .5)
|
||||
breakpoint_display(p[1] + .5)
|
||||
breakpoint_display(p[0] + 0.5)
|
||||
breakpoint_display(p[1] + 0.5)
|
||||
|
||||
barrel_power = 1.5
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from displayarray import display
|
||||
import numpy as np
|
||||
|
||||
display(np.random.normal(0.5, 0.1, (500, 500, 3))).block()
|
||||
display(np.random.normal(0.5, 0.1, (500, 500, 3))).block()
|
||||
|
||||
@@ -2,7 +2,9 @@ import numpy as np
|
||||
from displayarray import display
|
||||
|
||||
|
||||
def mandel(height=240, width=320, itermax=255, y_min=-1.8, y_max=.6, x_min=-1.6, x_max=1.6):
|
||||
def mandel(
|
||||
height=240, width=320, itermax=255, y_min=-1.8, y_max=0.6, x_min=-1.6, x_max=1.6
|
||||
):
|
||||
"""
|
||||
Generate a view of the mandlebrot fractal
|
||||
|
||||
@@ -43,13 +45,13 @@ def mandel(height=240, width=320, itermax=255, y_min=-1.8, y_max=.6, x_min=-1.6,
|
||||
return img / 255.0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
img = mandel()
|
||||
center = (0, -.6)
|
||||
center = (0, -0.6)
|
||||
length = 3.2
|
||||
d = display(img)
|
||||
while d:
|
||||
length *= .9
|
||||
length *= 0.9
|
||||
y_min = center[1] - length / 2.0
|
||||
y_max = center[1] + length / 2.0
|
||||
x_min = center[0] - length / 2.0
|
||||
|
||||
@@ -4,10 +4,12 @@ from examples.videos import test_video
|
||||
|
||||
# Move the mouse to center the image, scroll to increase/decrease barrel, ctrl+scroll to increase/decrease zoom
|
||||
|
||||
d = display(test_video) \
|
||||
.add_callback(crop.Crop()) \
|
||||
.add_callback(lens.Barrel().enable_mouse_control()) \
|
||||
d = (
|
||||
display(test_video)
|
||||
.add_callback(crop.Crop())
|
||||
.add_callback(lens.Barrel().enable_mouse_control())
|
||||
.wait_for_init()
|
||||
)
|
||||
|
||||
while d:
|
||||
print(d.frames[0].shape)
|
||||
|
||||
@@ -4,7 +4,6 @@ from examples.videos import test_video
|
||||
|
||||
# Move the mouse to move where the crop is from on the original image
|
||||
|
||||
display(test_video) \
|
||||
.add_callback(crop.Crop()) \
|
||||
.add_callback(lens.Barrel().enable_mouse_control()) \
|
||||
.block()
|
||||
display(test_video).add_callback(crop.Crop()).add_callback(
|
||||
lens.Barrel().enable_mouse_control()
|
||||
).block()
|
||||
|
||||
@@ -28,20 +28,33 @@ autoencoder.compile(loss="mse", optimizer="adam")
|
||||
while displayer:
|
||||
displayer.update()
|
||||
grab = tf.convert_to_tensor(
|
||||
next(iter(displayer.FRAME_DICT.values()))[np.newaxis, ...].astype(np.float32) / 255.0
|
||||
)
|
||||
grab_noise = tf.convert_to_tensor(
|
||||
((next(iter(displayer.FRAME_DICT.values()))[np.newaxis, ...].astype(
|
||||
np.float32) + np.random.uniform(0, 255, grab.shape)) / 2)
|
||||
next(iter(displayer.FRAME_DICT.values()))[np.newaxis, ...].astype(np.float32)
|
||||
/ 255.0
|
||||
)
|
||||
displayer.update((grab_noise.numpy()[0] * 255.0).astype(np.uint8), "uid for grab noise")
|
||||
grab_noise = tf.convert_to_tensor(
|
||||
(
|
||||
(
|
||||
next(iter(displayer.FRAME_DICT.values()))[np.newaxis, ...].astype(
|
||||
np.float32
|
||||
)
|
||||
+ np.random.uniform(0, 255, grab.shape)
|
||||
)
|
||||
/ 2
|
||||
)
|
||||
/ 255.0
|
||||
)
|
||||
displayer.update(
|
||||
(grab_noise.numpy()[0] * 255.0).astype(np.uint8), "uid for grab noise"
|
||||
)
|
||||
autoencoder.fit(grab_noise, grab, steps_per_epoch=1, epochs=1)
|
||||
output_image = autoencoder.predict(grab, steps=1)
|
||||
displayer.update((output_image[0] * 255.0).astype(np.uint8), "uid for autoencoder output")
|
||||
displayer.update(
|
||||
(output_image[0] * 255.0).astype(np.uint8), "uid for autoencoder output"
|
||||
)
|
||||
|
||||
get_3rd_layer_output = tf.keras.backend.function([autoencoder.layers[0].input],
|
||||
[autoencoder.layers[1].output])
|
||||
get_3rd_layer_output = tf.keras.backend.function(
|
||||
[autoencoder.layers[0].input], [autoencoder.layers[1].output]
|
||||
)
|
||||
layer_output = get_3rd_layer_output([grab_noise])[0]
|
||||
|
||||
displayer.update(layer_output[0], "conv 1")
|
||||
displayer.update(layer_output[0], "conv 1")
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
import os
|
||||
|
||||
test_video = os.path.join(os.path.dirname(__file__), 'fractal test.mp4')
|
||||
test_video_2 = os.path.join(os.path.dirname(__file__), 'fractal test 2.mp4')
|
||||
test_video = os.path.join(os.path.dirname(__file__), "fractal test.mp4")
|
||||
test_video_2 = os.path.join(os.path.dirname(__file__), "fractal test 2.mp4")
|
||||
|
||||
Reference in New Issue
Block a user