Video Processing using MATLAB software
Tutorial 1
%To get video information
%use above video material
clear all;
clc;
close all;
trafficObj = mmreader('S1.avi');
get(trafficObj)
implay('S1.avi');
Result in MATLAB Command Window
General Settings:
Duration = 9.3401
Name = S1.avi
Path = D:\GeneralFiles\Researchgate_Upload\VideoProcessingTutorials\finalproject\S1
Tag =
Type = VideoReader
UserData = []
Video Settings:
BitsPerPixel = 24
FrameRate = 11.4560
Height = 320
NumberOfFrames = 107
VideoFormat = RGB24
Width = 480
Tutorial 2
%To track an object and measure its speed
%Track object a bus and a bike
%use the above video
clear all;
clc;
close all;
trafficObj = mmreader('S1.avi');
get(trafficObj)
implay('S1.avi');
%darkCar = rgb2gray(read(trafficObj,73));
Bike_Person = read(trafficObj,73);
imshow(Bike_Person)
Bus = read(trafficObj,41);
figure
imshow(Bus)
nframes = get(trafficObj, 'NumberOfFrames');
I = read(trafficObj,1);
taggedbike = zeros([size(I,1) size(I,2) 3 nframes], class(I));
taggedBus = zeros([size(I,1) size(I,2) 3 nframes], class(I));
for k = 1 : nframes
singleFrame = read(trafficObj,k);
taggedbike(:,:,:,k) = singleFrame;
taggedBus(:,:,:,k) = singleFrame;
[m,n,C] = size(singleFrame);
for i = 1:m
for j = 1:n
%To identify the bike person
if((singleFrame(i,j,1)>226)&(singleFrame(i,j,1)<248 bike="" div="" nbsp="" person="" tart="" to="" trace="">
if((singleFrame(i,j,2)>180)&(singleFrame(i,j,2)<210 div="">
248>
if((singleFrame(i,j,3)>248)&(singleFrame(i,j,3)<255 div="">
210>
taggedbike(i,j,1,k) = 255;
taggedbike(i,j,2,k) = 0;
taggedbike(i,j,3,k) = 0;
end
end
end %End of trace of bike person
%To identify the Green Coded Tamilnadu State Transport
%Corporation Bus [Covai Region]
if((singleFrame(i,j,1)>35)&(singleFrame(i,j,1)<58 bus="" div="" nbsp="" tart="" to="" trace="">
255>
if((singleFrame(i,j,2)>86)&(singleFrame(i,j,2)<100 div="">
100>
58>
if((singleFrame(i,j,3)>81)&(singleFrame(i,j,3)<87 div="">
taggedBus(i,j,1,k) = 200;
taggedBus(i,j,2,k) = 200;
taggedBus(i,j,3,k) = 10;
end
end
end %End of trace Bus
end
end
end
frameRate = get(trafficObj,'FrameRate');
implay(taggedbike,frameRate);
Bike_speed = Speed_Measurement(73,96,frameRate,40)
figure
imshow(Bike_Person)
title('Speed Measurement of Known object: Bike Person')
text(240,240,'20.6208 KMPH')
87>
Results
Figure 1: Bike person Identified
Figure 2: Moving Bus
Figure 3: Moving Bike- Speed Measurement
Comments
Post a Comment