%%Extracting & Saving of frames from a Video file through Matlab Code%%
clc;close all;clear all;% assigning the name of sample mp4 file to a variable
filename = 'C:\Users\Hp\Desktop\xyz.mp4';%reading a video file
mov = VideoReader(filename);%getting no of frames
numFrames = mov.NumberOfFrames;%setting current status of number of frames written to zero
numFramesWritten = 0;%for loop to traverse & process from frame '1' to 'last' frames
for t = 1 : numFramescurrFrame = read(mov, t); %reading individual frames
opBaseFileName = sprintf('%3.3d.png', t);opFullFileName = fullfile('C:\Users\Hp\Desktop\col1', opBaseFileName);imwrite(currFrame, opFullFileName, 'png'); %saving as 'png' file
progIndication = sprintf('Wrote frame %4d of %d.', t, numFrames);disp(progIndication);numFramesWritten = numFramesWritten + 1;end %end of 'for' loop
progIndication = sprintf('Wrote %d frames to folder "%s"',numFramesWritten, 'C:\Users\Hp\Desktop\col1');disp(progIndication);%End of the code
%frame differncing code
I=imread('C:\Users\Hp\Desktop\col\001.png'); I1=rgb2gray(I);imshow(I1);J=imread('C:\Users\Hp\Desktop\col1\001.png');I1=rgb2gray(I);J1=rgb2gray(J);imshow(I1);imshow(J1);K=I1-J1;figure;imshow(K);title('SUBTRACTED IMAGE ');
MATLAB: After converting video into frame, and appling frame differencing method to subtract two image, now i want to draw boundary in foreground of video, how
activity detectionboundaryframe differencingImage Processing Toolboxvideo processing
Best Answer