mardi 10 mars 2015

how to read images from aspecified folder in matlab


myPath= 'C:\Users\Prienka\Documents\MATLAB\frames';
a =dir(fullfile(myPath,'*.png'));
a(1).name
a(end).name
Im1 = imread(a(1).name);
Im2 = imread(a(end).name);
Im1 = rgb2gray(Im1);
Im2 = rgb2gray(Im2);
hn1 = imhist(Im1)./numel(Im1); %initial pixel postion
hn2 = imhist(Im2)./numel(Im2); %final pixel position
d = sum(sqrt(hn2-hn1).^2);
d=sprintf('%.0f',d);
obj = VideoReader('traffic.mp4')
x=obj.FrameRate
velocity=d/x;
velocity=sprintf('%.0f',velocity)
if velocity >= 63
msgbox('SPEED EXCEEDED' )
end


this is my code for calculating the velocity of a vehicle in a vedio... the problem is i have extracted all the movie frames in a different folder named "frames"... here whenever m trying to run the code its showing a error like this "Error using imread (line 350) File "001.png" does not exist.


Error in pikz (line 5) Im1 = imread(a(1).name);" my file name is pikz.m


Aucun commentaire:

Enregistrer un commentaire