forked from priyanjasingh/hand-gesture-recognisation
/
12_feb_back_main.cpp
38 lines (38 loc) · 907 Bytes
/
12_feb_back_main.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
#include<opencv2/opencv.hpp>
#include<iostream>
#include<vector>
#include<algorithm>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
Mat frame;
Mat back;
Mat fore;
VideoCapture cap(0);
int i=0;
BackgroundSubtractorMOG2 bg;
bg.set("nmixtures",3);
bg.set("detectShadows",false);
namedWindow("Frame");
namedWindow("Background");
int backgroundFrame=500;
for(;;)
{
//Get the frame
cap >> frame;
//Update the current background model and get the foreground
if(backgroundFrame>0)
{bg.operator ()(frame,fore);backgroundFrame--;}
else
{bg.operator()(frame,fore,0);}
//Get background image to display it
bg.getBackgroundImage(back);
imshow("Frame",frame);
imshow("Background",back);
if(waitKey(10) >= 0) break;
}
return 0;
}