サンプルコード
以下のサンプルコードでは、scikit-imageのsobel/roberts輪郭抽出し、動画を出力しています。from moviepy.editor import *
from skimage.filters import sobel
from skimage.filters import roberts
from skimage.color import *
def process_sobel(image):
gray = rgb2gray(image.astype(float))
return gray2rgb(sobel(gray))
def process_roberts(image):
gray = rgb2gray(image.astype(float))
return gray2rgb(roberts(gray))
clip1 = VideoFileClip("hydrangea.mp4")
clip1t = clip1.fl_image(process_sobel)
clip1t.write_videofile("sobel.mp4")
clip1t = clip1.fl_image(process_roberts)
clip1t.write_videofile("roberts.mp4")
〇元動画の画面

〇出力動画の画面(sobel)

〇出力動画の画面(roberts)

〇scikit-imageインストール
MoviePyの他、仮想環境のフォルダに移動して以下のコマンドを実行します。
pipenv install scikit-image
関連情報
・MoviePyのまとめ・moviepyのホームページ
https://zulko.github.io/moviepy/
0 件のコメント:
コメントを投稿