summaryrefslogtreecommitdiff
path: root/macros/ForegroundDetector.sci
blob: 16a1e81d307e9532e295ec90382de1ace1c4e0c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function [varargout] = ForegroundDetector(varargin)	
// This function creates a ForeggroundDetector struct which is used to detect Foreground with Gaussian Mixture Models.
//
// Calling Sequence
//	 result = ForegroundDetector()
//	 result = ForegroundDetector(Name, Value, ..)
//
// Parameters
// results: ForegroundDetector struct containing AdaptLearningRate, NumTrainingFrames, MinimumBackgroundRatio, NumGaussians and LearningRate.
// AdaptLearningRate : (optional) If true, it enables the adaptation of Learning Rate during the period specified by number of training frames.
// NumTrainingFrames : (optional) The number of initial video frames employed to train the Background Model.
// MinimumBackgroundRatio : (optional) 
// NumGaussians : (optional) 
// LearningRate : (optional) This comes into action when AdaptLearningRate is enabled. 
//
// Description
// This function returns a ForegreoundDetector Struct which basically sets a background model and tracks changes in an input video frame with respect to the background and then computes the Foreground Mask. 
//
// Examples
// myStr = ForegroundDetector("NumGaussians", 4)
// 
// Authors
//  Shashank Shekhar
	[ lhs, rhs ] = argn(0)	
	if modulo(rhs,2)~=0 then
		error(msprintf("Incorrect number of input arguments"))
	end

	if rhs > 10 then
		error(msprintf("Too many input arguments"))
	end		
	if lhs > 1 then
		error(msprintf("Too many output arguments"))
	end
	select rhs 
		case 0 then	
			[fdAdaptLearningRate, fdNumTrainingFrames,fdMinimumBackgroundRatio, fdNumGaussians, fdLearningRate ]= ocv_ForegroundDetector()
			
		case 2 then		
			[fdAdaptLearningRate, fdNumTrainingFrames,fdMinimumBackgroundRatio, fdNumGaussians, fdLearningRate ] = ocv_ForegroundDetector(varargin(1), varargin(2))
		
		case 4 then
			[fdAdaptLearningRate, fdNumTrainingFrames,fdMinimumBackgroundRatio, fdNumGaussians, fdLearningRate ] = ocv_ForegroundDetector(varargin(1), varargin(2), varargin(3), varargin(4))
				
		case 6 then
			[fdAdaptLearningRate, fdNumTrainingFrames,fdMinimumBackgroundRatio, fdNumGaussians, fdLearningRate ] = ocv_ForegroundDetector(varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6))
				
		case 8 then
			[fdAdaptLearningRate, fdNumTrainingFrames,fdMinimumBackgroundRatio, fdNumGaussians, fdLearningRate ] = ocv_ForegroundDetector(varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6), varargin(7), varargin(8))
			
		case 10 then
			[fdAdaptLearningRate, fdNumTrainingFrames,fdMinimumBackgroundRatio, fdNumGaussians, fdLearningRate ] = ocv_ForegroundDetector(varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6), varargin(7), varargin(8), varargin(9), varargin(10))				
	end
		varargout(1) = struct("AdaptLearningRate", fdAdaptLearningRate, "NumTrainingFrames", fdNumTrainingFrames, "MinimumBackgroundRatio", fdMinimumBackgroundRatio, "NumGaussians", fdNumGaussians, "LearningRate", fdLearningRate);	
endfunction