Cara Mengekstrak Frame Video Menggunakan Matlab


Dalam bidang video processing, pada umumnya diawali dengan proses ekstraksi frame dari video sehingga pemrosesan video dilakukan pada setiap frame (frame by frame).

Berikut ini merupakan contoh aplikasi pemrograman matlab untuk mengekstrak frame dari suatu video.

Video pada contoh berikut ini berdurasi 20 detik dengan frame rate sebesar 30 per detik sehingga video tersebut memiliki jumlah frame sebanyak 20 x 30 = 600 frame.

Format video yang dapat dibaca oleh Matlab antara lain .avi, .mpg, dan .mp4.


File source code lengkap beserta video untuk mengekstrak frame dapat diperoleh melalui halaman berikut ini: Source Code

Sedangkan tampilan source codenya adalah:

clc;clear;close all;

vid = VideoReader('Sloped Best Line Skate Contest - Red Bull Bomb the Line 2012 Germany.mp4');

vidWidth = vid.Width;
vidHeight = vid.Height;
mov = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),...
    'colormap',[]);

k = 1;
while hasFrame(vid)
    mov(k).cdata = readFrame(vid);
    imwrite(mov(k).cdata,strcat(['Frame ',num2str(k),'.jpg']))
    k = k+1;
end

hf = figure;
set(hf,'position',[150 150 vidWidth vidHeight]);

movie(hf,mov,1,vid.FrameRate);

Maka hasil yang diperoleh dari coding tersebut adalah:

Posted on February 18, 2016, in Pengolahan Video and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink. 8 Comments.

  1. kok saya run error terus ya? di bagian videoreader

  2. kalo pake matlab r2010b apa yg harus diganti?
    sama videoreader nya gimana dimatlab 2010?

  3. maaf mas mau tanya, untuk memindahkan gambarnya ke folder yang ditentukan bagaimana ya?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: