2016-08-16 4 views
0

Ich habe eine Falte mit einer Liste von Bildern, die Frames aus einem Videoclip extrahieren. Ich frage mich, wie ich die Bildsequenz sequentiell genauso abspielen kann wie der Clip. (Hmm, FPS spielt keine Rolle.) Überprüfung PIL Modul und skimage Modul, scheint, dass ich es auf Python nicht tun kann, es sei denn, ich konvertiere die JPG Sequenz in GIF Format.So zeigen Sie Bildsequenzen als Videoclip auf Python an

Antwort

0

Ein Weg wäre, die Animationsfähigkeit der Matplotlib-Bibliothek zu verwenden. Hier ist ein Beispiel Kopieren/Einfügen aus dem online documentation:

#!/usr/bin/env python 
""" 
An animated image 
""" 
import numpy as np 
import matplotlib.pyplot as plt 
import matplotlib.animation as animation 

def f(x, y): 
    return np.sin(x) + np.cos(y) 

x = np.linspace(0, 2 * np.pi, 120) 
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1) 


fig = plt.figure() 
im = plt.imshow(f(x, y)) 

def updatefig(*args): 
    global x,y 
    x += np.pi/15. 
    y += np.pi/20. 
    im.set_array(f(x,y)) 
    return im, 

ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True) 
plt.show() 

Nur wenige Dinge zu beachten sind:

  • jedes Bild zu einem numpy Array umgewandelt werden
  • Verwendung im.set_array (in der updatefig Funktion) um das nächste Bild zu laden