-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForeground.cpp
74 lines (52 loc) · 1.76 KB
/
Foreground.cpp
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
/*
Main Function: To detect the movement in fully restricted area by separating foreground and background.
Two methods are shown to extract foreground:
1. Running average Method
2. Mixture of Gaussian Method
*/
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/background_segm.hpp>
#include "Video_Processor.h"
#include "Running_Avg.h"
#include "Gaussian_Mixture.h"
using namespace cv;
using namespace std;
int main()
{
// Foreground separation by Running average method
// Creating instance of VideoProcessor
VideoProcessor Processor1;
// Creating instance of Running_Avg class
Running_Avg function1;
//Set threshold value
function1.setThreshold(25);
//Open video file
Processor1.Set_Input("video_feed.mp4");
//Declare a window to display the input video
Processor1.Set_Input_Window("Input Video");
//Declare a window to display the output video
Processor1.Set_Output_Window("Extracted Foreground");
//set frame processor
Processor1.Set_Process(&function1);
//Start the process
Processor1.Run();
///////////////////////////////////////////////////////////////////
// Foreground separation by Mixture of Gaussian method
// Creating instance of VideoProcessor
VideoProcessor Processor2;
// Creating instance of Running_Avg class
Gaussian_Mixture function2;
//Open video file
Processor2.Set_Input("video_feed.mp4");
//Declare a window to display the input video
Processor2.Set_Input_Window("Input Video");
//Declare a window to display the output video
Processor2.Set_Output_Window("Extracted Foreground");
//set frame processor
Processor2.Set_Process(&function2);
//Start the process
Processor2.Run();
}