summaryrefslogtreecommitdiff
path: root/macros/peopleDetector.sci
blob: 1770ae34a7fab9c7310b342d2594751f682bb42c (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function bboxes = peopleDetector(image, varargin)
// Detects people in an image
//
// Calling Sequence
// [bboxes] = peopleDetector(image)
// [bboxes] = peopleDetector(image, ["Parameter1", value1, ["Parameter2", value2 ... ]])
//
// Parameters
// image : input image 
// hitThreshold : threshold for distance between features and SVM classifying plane. Default value is 0.
// winStride : Window stride. Multiple of block stride. Default value (8, 8)
// padding : Default value (16, 16).
// scale : Coefficient of the detection window increase. Default value 1.05
// finalThreshold : Coefficient to regulate the similarity threshold. Some people may cover more boxex. To regulate that it is used. Default value 2.
// useMeanshiftGrouping : Default value false.
// bboxes : M * 4 matrix denoting M bounding boxes for detected people
//
// Description
// The peopleDetector function detects standing people in the image using the Histogram of Oriented Gradient (HOG) features and a trained Support Vector Machine
// (SVM) classifier. It detects standing peole in the image. It returns M * 4 matrix having M detected people in the image. Each row of matrix contains
// [x, y, width, height] field. x, y represent the upper left corner point of the bounding box. width and height represent the width and height of the bounding box
// respectively. 
//
// Examples
// I = imread('standing.jpg')
// [bboxes] = peopleDetector(I)
// I = imread('standing.jpg')
// [bboxes] = peopleDetector(I, "scale", 1.02)
//
// Authors
// Suraj Prakash



	[ lhs rhs ] = argn(0)
	
	if lhs > 1 then
		error(msprintf("Too many output arguments"))
	end
	
	if rhs > 13 then
		error(msprintf("Too many input arguments"))
	end
	
	if modulo(rhs, 2) <> 1 then
		error(msprintf("Wrong number of input arguments"))
	end
	
	image_list = mattolist(image)
	
	if rhs == 1 then
		
		bboxes = opencv_peopleDetector(image_list)
		
	elseif rhs == 3 then
		
		bboxes = opencv_peopleDetecotr(image_list, varargin(1), varargin(2))
	
	elseif rhs == 5 then
		
		bboxes = opencv_peopleDetector(image_list, varargin(1), varargin(2), varargin(3), varargin(4))
	
	elseif rhs == 7 then
		
		bboxes = opencv_peopleDetector(image_list, varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6))
	
	elseif rhs == 9 then
		
		bboxes = opencv_peopleDetector(image_list, varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6), varagin(7), varagin(8))
		
	elseif rhs == 11 then
		
		bboxes = opencv_peopleDetector(image_list, varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6), varargin(7), varargin(8), varargin(9), varargin(10))
	
	elseif rhs == 13 then
		bboxes = opencv_peopleDetector(image_list, varargin(1), varargin(2), varargin(3), varargin(4), varargin(5), varargin(6), varargin(7), varargin(8), varargin(9), varargin(10), varargin(11), varargin(12))
	end
	
endfunction