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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
#pragma once
#include <set>
#include "ofMain.h"
#include "tesselator.h"
#include "ofxOpenCv.h"
#include <opencv2/opencv.hpp>
#include "ofxRay.h"
#include "ofxXmlSettings.h"
#include "ofxBlobsManager.h"
#include "trapdoor.h"
#include "bird.h"
#include "player.h"
#include "outsidePolygon.h"
//#define _USE_LIVE_VIDEO // uncomment this to use a live camera
// otherwise, we'll use a movie file
#define PLAY 0
#define CALIBRATE 1
#define CHECKACCUM 2
#define TITLES 0
#define EXPLAIN 1
#define PLAYING 2
#define GOTCHA 3
#define CAM_WIDTH_FG 640
#define CAM_HEIGHT_FG 480
#define chan_R 1
#define chan_G 2
#define chan_B 3
#define chan_H 4
#define chan_S 5
#define chan_V 6
#define DEBUG 1
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
int windowWidth, windowHeight;
bool mirror; //horiz flip
int mode;
//utility functions
ofVec2f screen2plane(ofVec2f screenpos);
ofVec3f plane2world(ofVec2f planepos);
void updatePlane();
bool rectsCross(ofRectangle rect1,ofRectangle rect2);
ofxXmlSettings XML;
void loadSettings(string filename);
void saveSettings(string filename);
bool useCamera;
bool hasCamera;
ofVideoGrabber vidGrabber;
ofVideoPlayer vidPlayer;
ofxCvColorImage colorImg;
string testmovie;
int diffchannel;
cv::Mat accumulator,outmat,hsvback,hsvfront,backchan,frontchan,output; // background accumulation
ofxCvColorImage currentFrame;
ofxCvColorImage background;
ofxCvColorImage mogoutput;
ofxCvGrayscaleImage grayFrame;
ofxCvGrayscaleImage grayBg;
ofxCvGrayscaleImage grayDiff;
float learningRate;
bool bFirstFrame;
//cv::BackgroundSubtractorMOG mog;
float mogf;
bool removeShadows;
int shadowThreshold;
/*
ofxCvFloatImage accumImg;
ofxCvGrayscaleImage bgImg;
ofxCvGrayscaleImage grayImage;
ofxCvGrayscaleImage grayBg;
ofxCvGrayscaleImage grayDiff;
*/
ofxCvContourFinder contourFinder;
ofxBlobsManager blobsManager;
int threshold;
bool bLearnBakground;
float cam_angle;
ofCamera cam;
ofRay ray;
ofPlane plane;
ofProjector projector;
ofVec2f pos;
//vector<ofVec3f> players;
trapdoor trapDoor;
ofMesh ground;
vector<ofPolyline> groundlines;
ofTessellator tess;
void tessGround(int doornum);
void makeGround(int doornum);
vector<trapdoor> trapdoors;
float trapdoorSize;
float trapdoorSlotSize;
int numtrapdoorSlots;
int trapdoorCounter;
float trapdoorTime; //time per trap door
float trapdoorTimer;
ofSoundPlayer* doorsounds;
ofVec3f* testpts;
bird Bird;
map<int,player> players;
bool drawStats;
bool drawInstructions;
bool firstframe; //for background removal
float bgnum;
ofLight light;
ofPlane* bounds;
ofVec3f centre;
vector<ofPoint> border;
bool drawingborder;
ofSoundPlayer* sounds;
ofImage* billboards;
ofVec2f scaleFactor;
int gameState;
float gameStart;
float segTimes[5];
};
|