Skip to content

Instantly share code, notes, and snippets.

@fado
Created February 18, 2015 11:22
Show Gist options
  • Save fado/1e4dc3ecb612edc57ffe to your computer and use it in GitHub Desktop.
Save fado/1e4dc3ecb612edc57ffe to your computer and use it in GitHub Desktop.
Background generator...
function [ Bkg ] = bckGenerator( videoStream, sampling )
buffer = [];
counter = 0;
% start : step size : end
for t = 1:sampling:size(videoStream, 4)
counter = counter + 1;
currentFrame = read(videoStream, t);
currentFrameGrey = rgb2gray(currentFrame);
currentFrameGrey = double(currentFrameGrey);
buffer(:,:,counter) = currentFrameGrey;
end
Bkg = median(buffer, 3);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment