As i'm currently working on biometric gait recognition project so to complete that project i have to background subtraction to extract foreground from video.
i'm using CASIA data set videos for my experiments.
So background subtraction is the first thing to do in my project so when we have extracted human structure from video we easily perform our algorithms on it to identify its gait.
Matlab code for background subtraction using frame difference:
clc; % clear command window
clear all; % clear work space
% Reading video from computer directory
videoObject = VideoReader('001-bg-01-090.avi');
% Determine how many frames there are.
numberOfFrames = videoObject.NumberOfFrames;
% Loop through all frames
for frame = 1 : numberOfFrames
% Extract the frame from the movie structure.
img1 = read(videoObject, frame);
img2 = read(videoObject, frame+10);
% In above we take two frame to subtract them from each other
% Subtract frames from each other img3 = imsubtract(img1,img2);