#ifndef _CTRACKING_MANAGER_ #define _CTRACKING_MANAGER #include "ofMain.h" #include "ofCvMain.h" #include "cvContourToImage.h" //#include "highGui.h" /* Performs basic contour tracking on the video and then finds the area in the image where the computer screen is. Image warping is used to convert the tracked pixels in the image to onscreen coordinates. */ #define MAX_BLOBS 20 class CTrackingManager { public: CTrackingManager(); ~CTrackingManager(); void setup( int _w, int _h, int _screenW, int _screenH); void update( ofCvGrayscaleImage giPixels ); // find points where blobs touch the screen void findTouchScreenPoints(); // learns background over time. set fLearnRate to 0 for no learning. void learnBackground( ofCvGrayscaleImage & _giLive, ofCvGrayscaleImage & _giBgImage, ofCvFloatImage & _fiLearn, float _fLearnRate ); // capture bg image void bgCapture(ofCvGrayscaleImage _giLive); // sets a binary image that define the screen area. Pass in points of screen corners in cam image (from boxAligner) void setScreenArea( ofPoint2f scrPts[4] ); // save and load images //void saveImage( ofCvGrayscaleImage & giSaveMe, char * filename); void loadImage( ofCvGrayscaleImage & giLoadIntoMe, char * filename); // draw stuff void draw( int x, int y ); void drawTouchingPoints(); //--------------------- ofCvContourFinder contourFinder; ofCvContourFinder contourFinderHand; cvContourToImage contourToImage; //--------------------- ofCvGrayscaleImage giBgImage; // background capture ofCvGrayscaleImage giDiff; // difference image ofCvGrayscaleImage giScreenArea; // holds polygon image of screen ofCvGrayscaleImage giTouchArea; // used to find where blobs intersect screen area ofCvGrayscaleImage giWarpTouchArea; // warp the screen area so it scales nicelt. hmm not so efficient maybe? ofCvGrayscaleImage giAllTouchArea; // just for degbuggin and display ofCvFloatImage fiLearn; //--------------------- float fLearnRate; // rate to learn background int nThreshold; // thrshold for tracking int w,h; // dimensions of image capture float screenW,screenH; // reslution of computer screen ofPoint2f scrnSrcPts[4]; // points for warping screen area ofPoint2f scrnDstPts[4]; ofPoint2f scrnScaleUp; // scale factor to convert image coordinates up to screen coordinates ofPoint2f touchSpots[MAX_BLOBS]; // coordinates of all points where blob touches the screen int nTotalTouching; bool bSetScreenArea; }; #endif