roiFinder.h

00001 /* Copyright (c) 2009       Maxim Makhinya
00002  *
00003  * This library is free software; you can redistribute it and/or modify it under
00004  * the terms of the GNU Lesser General Public License version 2.1 as published
00005  * by the Free Software Foundation.
00006  *  
00007  * This library is distributed in the hope that it will be useful, but WITHOUT
00008  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00010  * details.
00011  * 
00012  * You should have received a copy of the GNU Lesser General Public License
00013  * along with this library; if not, write to the Free Software Foundation, Inc.,
00014  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00015  */
00016 
00017 #ifndef EQ_ROI_FINDER_H
00018 #define EQ_ROI_FINDER_H
00019 
00020 #include "roiEmptySpaceFinder.h"
00021 #include "roiTracker.h"
00022 
00023 #include <eq/client/image.h>   // member
00024 
00025 #include <vector>
00026 #include <string>
00027 
00028 
00029 namespace eq
00030 {
00034     class ROIFinder
00035     {
00036     public:
00037         ROIFinder();
00038         virtual ~ROIFinder() {}
00039 
00052         PixelViewportVector findRegions( const uint32_t         buffers,
00053                                          const PixelViewport&   pvp,
00054                                          const Zoom&            zoom,
00055                                          const uint32_t         stage,
00056                                          const uint32_t         frameID,
00057                                          Window::ObjectManager* glObjects );
00058 
00060         GLEWContext* glewGetContext() { return _glObjects->glewGetContext(); }
00061 
00062     protected:
00063 
00064     private:
00065         struct Area;
00066 
00067         const void* _getInfoKey( ) const;
00068 
00071         void _readbackInfo();
00072 
00074         void _dumpDebug( const uint32_t stage = 0 );
00075 
00078         void _init( );
00079 
00081         void _fillWithColor( const PixelViewport& pvp, uint8_t* dst,
00082                              const uint8_t val );
00083 
00085         void _resize( const PixelViewport& pvp );
00086 
00088         PixelViewport _getObjectPVP( const PixelViewport& pvp,
00089                                      const uint8_t* src );
00090 
00092         uint8_t _splitArea( Area& area );
00093 
00095         void _updateSubArea( const uint8_t type );
00096 
00098         void _findAreas( PixelViewportVector& resultPVPs );
00099 
00101         void _invalidateAreas( Area* areas, uint8_t num );
00102 
00105         struct Dims
00106         {
00107             uint8_t x1, x2, x3;
00108             uint8_t y1, y2, y3;
00109             uint8_t w1, w2, w3, w4, w5, w6, w7, w8;
00110             uint8_t h1, h2, h3, h4, h5, h6, h7, h8;
00111         } _dim;
00112 
00114         struct Area
00115         {
00116             Area(){};
00117             Area( PixelViewport pvp_ ) : emptySize( 0 ), pvp ( pvp_ ) {}
00118 
00119             int32_t       emptySize; 
00120             PixelViewport pvp;       
00121             PixelViewport hole;      
00122 
00123             bool          valid; 
00124         };
00125 
00126         Area  _tmpAreas[17];  
00127         Area* _finalAreas[4]; 
00128 
00129         std::vector< Area > _areasToCheck;
00130 
00131         PixelViewport       _pvp;        //<! current, alligned to grid, PVP
00132         PixelViewport       _pvpOriginal;//<! original PVP
00133 
00134         ROIEmptySpaceFinder _emptyFinder;
00135 
00136         int32_t _w;     
00137         int32_t _h;     
00138         int32_t _wh;    
00139         int32_t _wb;    
00140         int32_t _hb;    
00141         int32_t _wbhb;  
00142 
00143         UByteVector _tmpMask; 
00144         UByteVector _mask;    
00145 
00146         std::vector<float> _perBlockInfo; 
00147 
00148         uint8_t _histX[256]; 
00149         uint8_t _histY[256]; 
00150 
00151         Image _tmpImg;   
00152 
00153         ROITracker _roiTracker; 
00154 
00156         Window::ObjectManager* _glObjects;
00157     };
00158 }
00159 
00160 #endif // EQ_ROI_FINDER_H
00161 
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8