roiEmptySpaceFinder.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_EMPTY_SPACE_FINDER_H
00018 #define EQ_ROI_EMPTY_SPACE_FINDER_H
00019 
00020 #include <eq/client/pixelViewport.h>
00021 #include <vector>
00022 
00023 namespace eq
00024 {
00028     class ROIEmptySpaceFinder
00029     {
00030     public:
00031         ROIEmptySpaceFinder() : _mask( 0 ) {};
00032         virtual ~ROIEmptySpaceFinder(){};
00033 
00036         void update( const uint8_t* mask, const int32_t w, const int32_t h );
00037 
00040         PixelViewport getLargestEmptyArea( const PixelViewport& pvp ) const;
00041 
00042         inline uint16_t getArea( const int32_t x, const int32_t y,
00043                                  const int32_t w, const int32_t h ) const;
00044 
00045         inline uint16_t getArea( const int32_t x, const int32_t y,
00046                                  const int32_t w, const int32_t h,
00047                                  const uint16_t* data ) const;
00048 
00049         void setLimits( const int16_t absolute, const float relative )
00050         {
00051             _limAbs = absolute;
00052             _limRel = relative;
00053         }
00054 
00055     protected:
00056 
00057     private:
00059         void _resize( const int32_t w, const int32_t h );
00060 
00061         bool _updateMaximalEmptyRegion( const int32_t x, const int32_t y,
00062                                         const int32_t w, const int32_t h,
00063                                         PixelViewport& pvp,
00064                                         const uint16_t* data ) const;
00065 
00066         int32_t _w;
00067         int32_t _h;
00068 
00069         int16_t _limAbs;
00070         float   _limRel;
00071 
00072         UShortVector _data;
00073         const uint8_t* _mask;
00074     };
00075 }
00076 
00077 #endif // EQ_ROI_EMPTY_SPACE_FINDER_H
00078 
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8