dari hasil pacaran ama source code selama seminggu ternyata membuahkan hasil juga, xixixixi...
code:
clear all
clc
hbfr = video.MultimediaFileReader('tugas.mp4');
hcr = video.ChromaResampler('Resampling', '4:2:0 (MPEG1) to 4:4:4', 'InterpolationFilter', 'Pixel replication');
hcsc1 = video.ColorSpaceConverter('Conversion', 'YCbCr to RGB');
hcsc2 = video.ColorSpaceConverter('Conversion', 'RGB to intensity');
hidtc = video.ImageDataTypeConverter('OutputDataType', 'single');
hof = video.OpticalFlow('OutputValue', 'Horizontal and vertical components in complex form', 'ReferenceFrameDelay', 3);
hmean1 = video.Mean;
hmean2 = video.Mean('RunningMean', true);
hmedianfilt = video.MedianFilter2D;
hclose = video.MorphologicalClose('Neighborhood', strel('line',5,45));
hblob = video.BlobAnalysis(...
'CentroidOutputPort', false,...
'AreaOutputPort', true, ...
'BoundingBoxOutputPort', true, ...
'OutputDataType', 'double', ...
'NumBlobsOutputPort', false, ...
'MinimumBlobAreaSource', 'Property', ...
'MinimumBlobArea', 250, ...
'MaximumBlobAreaSource', 'Property', ...
'MaximumBlobArea', 3600, ...
'FillValues', -1, ...
'MaximumCount', 80);
herode = video.MorphologicalErode('Neighborhood', strel('square',2));
hshapeins1 = video.ShapeInserter('BorderColor', 'Custom', 'CustomBorderColor', [0 1 0]);
hshapeins2 = video.ShapeInserter('Shape','Lines', 'BorderColor', 'Custom', 'CustomBorderColor', [255 255 0]);
htextins = video.TextInserter('Text', '%4d', 'Location', [0 0], 'Color', [1 1 1], 'Font', 'Arial', 'FontSize', 12);
hVideo1 = video.VideoPlayer('WindowCaption', 'Original Video');
hVideo1.WindowPosition(1) = round(0.4*hVideo1.WindowPosition(1)) ;
hVideo1.WindowPosition(2) = round(1.5*(hVideo1.WindowPosition(2))) ;
hVideo1.WindowPosition([4 3]) = [300 300];
hVideo2 = video.VideoPlayer('WindowCaption', 'Motion Vector');
hVideo2.WindowPosition(1) = hVideo1.WindowPosition(1) + 350;
hVideo2.WindowPosition(2) =round(1.5* hVideo2.WindowPosition(2));
hVideo2.WindowPosition([4 3]) = [300 300];
hVideo3 = video.VideoPlayer('WindowCaption', 'Thresholded Video');
hVideo3.WindowPosition(1) = hVideo2.WindowPosition(1) + 350;
hVideo3.WindowPosition(2) = round(1.5*(hVideo3.WindowPosition(2))) ;
hVideo3.WindowPosition([4 3]) = [300 300];
hVideo4 = video.VideoPlayer('WindowCaption', 'Results');
hVideo4.WindowPosition(1) = hVideo1.WindowPosition(1);
hVideo4.WindowPosition(2) = round(0.3*(hVideo4.WindowPosition(2))) ;
hVideo4.WindowPosition([4 3]) = [300 300];
% inisialisasi beberapa variabel digunakan untuk plot motion vektor
MotionVecGain = 20;
line_row = 22;
borderOffset = 5;
decimFactorRow = 5;
decimFactorCol = 5;
firstTime = true;
while ~isDone(hbfr)
%[y, cb, cr] = step(hbfr);
my_rgb_frame = step(hbfr); % Read input video frame
my_rgb_frame = step(hbfr); % Read input video frame
image = step(hidtc, my_rgb_frame);
I = step(hcsc2, image);
of = step(hof, I); % Estimate optical flow
y1 = of .* conj(of);
vel_th = 0.5 * step(hmean2, step(hmean1, y1));
filteredout = step(hmedianfilt, y1 >= vel_th);
th_image = step(hclose, step(herode, filteredout));
[area, bbox] = step(hblob, th_image);
Idx = bbox(1,:) > line_row;
ratio = zeros(1, length(Idx));
ratio(Idx) = single(area(1,Idx))./single(bbox(3,Idx).*bbox(4,Idx));
ratiob = ratio > 0.4;
count = int32(sum(ratiob));
bbox(:, ~ratiob) = int32(-1);
y2 = step(hshapeins1, image, bbox);
y2(22:23,:,:) = 1;
y2(1:15,1:30,:) = 0;
image_out = step(htextins, y2, count);
if firstTime
[R C] = size(of);
RV = borderOffset:decimFactorRow:(R-borderOffset);
CV = borderOffset:decimFactorCol:(C-borderOffset);
[Y X] = meshgrid(CV,RV);
firstTime = false;
end
tmp = of(RV,CV) .* MotionVecGain;
lines = [X(:)';Y(:)';X(:)' + imag(tmp(:))';Y(:)' + real(tmp(:))'];
mv_video = step(hshapeins2, image, lines);
step(hVideo1, image);
step(hVideo2, mv_video);
step(hVideo3, th_image);
step(hVideo4, image_out);
end
hasilnya running:
Selengkapnya...
terus terang terang terus...
Followers
Blogroll
Total Pageviews
Tentang Blog
semua tentang blog
posting populer
-
Bagi yang sering liat film cookiez pastinya tak asing lagi dengan rilik lagu nih kan.... Cinta adalah Persahabatan Yang pasti berakhir diwak...
-
Album Aku Berselimutkan Debu Al-Muqtashidah Group Album Sholawat "Aku berselimutkan Debu" ini dikeluarkan oleh group sholawat Al M...
-
libsvm merupakan library yang mendukung beberapa bahasa pemrograman seperti python, C#, matlab, dan beberapa bahasa pemrograman lainnya un...
-
dari hasil pacaran ama source code selama seminggu ternyata membuahkan hasil juga, xixixixi... code: clear all clc hbfr = video.MultimediaFi...
-
untuk merubah eth1 ke eth0 pada debian kta dapat merubah bagian pada udev. 1.edit bagian /etc/udev/rules.d/70-persistent-net.rules 2.edit pa...
-
Pondok Pesantren Bahrul Ulum (PPBU) didirikan oleh KH. Abdus Salam seorang keturunan raja Majapahit, pada tahun 1838 M di desa Tambakberas, ...
-
Semaleman budrek karna gcc.. sekarang akhirnya terkuak juga, hahahha... ha ini saya terjadi saat mengerjakan TA tentang car detection. saya ...
-
- buka terminal Ubuntu atau Debian, lalu ketik command Untuk Ubuntu => sudo gedit /etc/bash.bashrc Untuk Debian, masuk sebagai root d...
-
libsvm merupakan
OPTICAL FLOW DI MATLAB
Langganan:
Postingan (Atom)
Blog Archive
About Me

- ilin.blogspot.com
- jombang berIMAN, surabaya, Indonesia
- sEnYum AdaLaH IbAdaH,,,:)