#pragma once #include #include "ofMain.h" #include "tesselator.h" #include "ofxOpenCv.h" #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 TITLES 0 #define CREDIT 1 #define EXPLAIN 2 #define PLAYING 3 #define GOTCHA 4 #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; 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 players; trapdoor trapDoor; ofMesh ground; vector groundlines; ofTessellator tess; void tessGround(int doornum); void makeGround(int doornum); vector trapdoors; float trapdoorSize; float trapdoorSlotSize; int numtrapdoorSlots; int trapdoorCounter; float trapdoorTime; //time per trap door float trapdoorTimer; ofSoundPlayer* doorsounds; ofVec3f* testpts; bird Bird; map players; bool drawStats; bool drawInstructions; bool firstframe; //for background removal float bgnum; ofLight light; ofPlane* bounds; ofVec3f centre; vector border; bool drawingborder; ofSoundPlayer* sounds; ofImage* billboards; ofVec2f scaleFactor; int gameState; float gameStart; float segTimes[5]; };