//============================================================================= #ifndef CORRELATOR_H #define CORRELATOR_H #include "movieIO.h" #include #include #include class bwImage; class rgbImage; class correlator { public: correlator( const movieIO &src, bool visible, bool clearFrames ); correlator( int width, int height, bool visible, bool clearFrames ); ~correlator(); bool addImageFrame( int idx, bwImage *frm ); bool addImageFrame( int idx, rgbImage *frm ); void clearWindow(); float correlation( int frame1, int tri1x1, int tri1y1, int tri1x2, int tri1y2, int tri1x3, int tri1y3, int frame2, int tri2x1, int tri2y1, int tri2x2, int tri2y2, int tri2x3, int tri2y3 ) const; void setCorrelationSrc( int frame1, int tri1x1, int tri1y1, int tri1x2, int tri1y2, int tri1x3, int tri1y3 ) const; float correlateWith( int frame2, int tri2x1, int tri2y1, int tri2x2, int tri2y2, int tri2x3, int tri2y3 ) const; float correlation( int frame1, int ulx, int uly, int lrx, int lry, int frame2, int dx, int dy ); void setCorrelationSrc( int frame1, int ulx, int uly, int lrx, int lry ); float correlateWith( int frame2, int dx, int dy ); int getNumFrames() const { return numFrames_; } int getWidth() const { return imgWidth_; } int getHeight() const { return imgHeight_; } public: int nextPowerOfTwo( int x ); protected: GLuint frameHandles_[100]; int numFrames_; int texWidth_, texHeight_, imgWidth_, imgHeight_; unsigned char *localCompBuf_; Display *dpy_; Window window_; GLXContext ctx_; bool visible_, clearFrames_; int srcUlx_, srcUly_, srcLrx_, srcLry_, srcWidth_, srcHeight_; }; inline int correlator::nextPowerOfTwo( int x ) { for ( int ret=2; ; ret*=2 ) if (ret>=x) return ret; } inline float correlator::correlation( int frame1, int ulx, int uly, int lrx, int lry, int frame2, int dx, int dy ) { setCorrelationSrc( frame1, ulx, uly, lrx, lry ); return correlateWith( frame2, dx, dy ); } #endif // CORRELATOR_H