예제 #1
0
def test_video_buffer_smk():
    # load only 100 images
    video_buffer = io.video_buffer(video_file, nimages=100)
    images_rgb = np.asarray([image for image in video_buffer])
    images_luminance = io.imagearray2luminance(images_rgb, size=None)

    images_luminance_resized = io.imagearray2luminance(images_rgb,
                                                       size=small_size)
예제 #2
0
def test_video2luminance():
    # test video2luminance generator
    nimages = 256
    video_buffer = io.video_buffer(video_file, nimages=nimages)
    # load and downsample 1000 images
    aspect_ratio = 16 / 9.0
    small_size = (96, int(96 * aspect_ratio))

    luminance_images = np.asarray([io.imagearray2luminance(image, size=small_size).squeeze() \
                                   for image in video_buffer])

    lum = io.video2luminance(video_file, size=small_size, nimages=nimages)
    assert np.allclose(luminance_images, lum)
예제 #3
0
import os
import PIL
import tempfile
from moten import io

# This can also be a local file or an HTTP link
video_file = 'http://anwarnunez.github.io/downloads/avsnr150s24fps_tiny.mp4'
video_buffer = io.video_buffer(video_file)

# store frames in temporary directory
tmpdir = tempfile.mkdtemp()

# Write 100 images from video as PNG
for frameidx in range(100):
    image_array = video_buffer.__next__()
    image_object = PIL.Image.fromarray(image_array)
    image_object.save(os.path.join(tmpdir, 'frame%08i.png' % frameidx))

video_buffer.close()
예제 #4
0
def test_video_buffer_image():
    video_buffer = io.video_buffer(video_file)
    image_rgb = video_buffer.__next__()  # load a single image
    assert image_rgb.ndim == 3
    assert image_rgb.dtype == np.uint8