Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

InterestPointSelector.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Geometry_InterestPointSelector_h
00002 #define Impala_Core_Geometry_InterestPointSelector_h
00003 
00004 #include "Basis/ILog.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Geometry
00011 {
00012 
00015 class InterestPointSelector
00016 {
00017 public:
00018     InterestPointSelector()
00019     {}
00020 
00021     InterestPointSelector(std::string config, int borderOffset) 
00022         : pyramidMode(false), boundingBoxMode(false)
00023     {
00024         if(config.substr(0,1) == std::string("P")) 
00025         {
00026             // pyramid selection
00027             Util::StringParser sp(config.substr(1,config.size()));
00028             xDivision = sp.GetInt('x', false, true);
00029             yDivision = sp.GetInt('#', false, true);
00030             index = sp.GetInt(' ');
00031             //std::cout << "SEL: " << index << " " << xDivision << " " << yDivision << std::endl;
00032             pyramidMode = true;
00033         }
00034         else if(config.substr(0,1) == std::string("B"))
00035         {
00036             // bounding box
00037             Util::StringParser sp(config.substr(1,config.size()));
00038             // subtract one, because public format is 1..n
00039             boxMinX = sp.GetDouble('#', true, true) - 1 - borderOffset;
00040             boxMaxX = sp.GetDouble('/', true, true) - 1 - borderOffset;
00041             boxMinY = sp.GetDouble('#', true, true) - 1 - borderOffset;
00042             boxMaxY = sp.GetDouble(' ') - 1 - borderOffset;
00043             boundingBoxMode = true;
00044         }
00045         else
00046         {
00047             throw "Unknown pointSelector";
00048         }
00049     }
00050 
00051     virtual bool
00052     Accept(int x, int y, int imageWidth, int imageHeight)
00053     {
00054         if(pyramidMode)
00055         {
00056             int xIndex = index % xDivision;
00057             int yIndex = index / xDivision;
00058             
00059             int minX = (xIndex     * imageWidth) / xDivision;
00060             int maxX = ((xIndex+1) * imageWidth) / xDivision;
00061             int minY = (yIndex     * imageHeight) / yDivision;
00062             int maxY = ((yIndex+1) * imageHeight) / yDivision;
00063             
00064             //std::cout << "SEL: " << index << " " << xDivision << " " << yDivision << std::endl;
00065             //std::cout << minX << " " << maxX << " " << minY << " " << maxY << std::endl;
00066             if((x >= minX) && (x < maxX) &&
00067                (y >= minY) && (y < maxY)) 
00068             {
00069                 return true;
00070             }
00071         } 
00072         else if(boundingBoxMode)
00073         {
00074             if((x >= boxMinX) && (x <= boxMaxX) &&
00075                (y >= boxMinY) && (y <= boxMaxY)) 
00076             {
00077                 return true;
00078             }
00079         }
00080         return false;
00081     }
00082 private:
00083     // pyramid
00084     int xDivision;
00085     int yDivision;
00086     int index;
00087     // bounding box
00088     double boxMinX, boxMaxX, boxMinY, boxMaxY;
00089     bool pyramidMode, boundingBoxMode;
00090 
00091 };
00092 
00093 } // namespace Geometry
00094 } // namespace Core
00095 } // namespace Impala
00096 
00097 #endif

Generated on Fri Mar 19 09:31:09 2010 for ImpalaSrc by  doxygen 1.5.1