00001 00002 #ifndef CUDAPYRBUILDER_H_DEFINED 00003 #define CUDAPYRBUILDER_H_DEFINED 00004 00005 #include "CUDA/CudaConvolutions.H" 00006 #include "CUDA/CudaImage.H" 00007 #include "Image/PyramidTypes.H" 00008 00009 #include <deque> 00010 00011 template <class T> class CudaImageSet; 00012 template <class T> class PixRGB; 00013 template <class T> class CudaPyramidCache; 00014 00015 // ###################################################################### 00016 //! An interface class for creating dyadic pyramids from input images. 00017 /*! A dyadic image pyramid is an array of images such that the next image 00018 is obtained from the previous one by applying some filter and 00019 decimating the image by a factor 2 horizontally and vertically. 00020 00021 The PyrBuilder classes essentially wrap one of the buildPyr*() 00022 functions, binding preset values to all of the trailing arguments. This 00023 allows all of the buildPyr*() functions to be presented behind a 00024 uniform interface. 00025 00026 PyrBuilder defers the actual handling of input images through the 00027 abstract function build(). Different subclasses may implement this to 00028 apply different filters (e.g., gaussian, laplacian, gabor) before 00029 decimation. GenericPyrBuilder offers a generic implementation, while 00030 GaussianPyrBuilder, LaplacianPyrBuilder, and OrientedPyrBuilder are 00031 specialized for single filter types. 00032 */ 00033 template <class T> 00034 class CudaPyrBuilder 00035 { 00036 public: 00037 //! Create an empty CudaPyrBuilder 00038 CudaPyrBuilder(); 00039 00040 // default copy contructor and assignment are okay 00041 00042 //! Virtual destructor for safe inheritance. 00043 virtual ~CudaPyrBuilder(); 00044 00045 //! Cloning constructor useful to make clones from pointers: 00046 virtual CudaPyrBuilder<T>* clone() const = 0; 00047 00048 //! Create a pyramid from an input image, with given depth (=nb levels) 00049 /*! @param firstlevel if non-zero, then pyramid levels prior to 00050 firstlevel may be skipped and left empty, as long as the 00051 remaining pyramid levels contain the same values that they would 00052 normally contain -- this parameter is only an optimization hint, 00053 and subclasses are free to ignore it if they so choose 00054 00055 @param depth number of levels the pyramid should contain (note 00056 that if firstlevel is non-zero, then some of those levels may be 00057 empty) 00058 */ 00059 virtual CudaImageSet<T> build(const CudaImage<T>& image, 00060 const int firstlevel, const int depth, 00061 CudaPyramidCache<T>* cache = 0) = 0; 00062 00063 //! reset the pyramid - whatever that means for a specific pyramid 00064 /*! a no op implementation is given in this base class - so if pyramids 00065 don't need this, they don't have to worry about it */ 00066 virtual void reset(); 00067 00068 private: 00069 }; 00070 00071 00072 // ###################################################################### 00073 //! This class implements Reichardt motion detections 00074 /*! The class uses the filter results of pyramids of other types 00075 to implement Reichardt motion detection. The pyramids of the previous 00076 time step are stored and used with the pyramid of this time step and 00077 a version of the current pyramid, in which each level is shifted by the 00078 same amount dx and dy. The results are stored in the Reichardt pyramid and 00079 represent motion at different speeds and spatial resolutions. */ 00080 template <class T> 00081 class CudaReichardtPyrBuilder : public CudaPyrBuilder<T> 00082 { 00083 public: 00084 CudaReichardtPyrBuilder(); 00085 // ###################################################################### 00086 // #### Constructors 00087 // ###################################################################### 00088 //! build with depth, dx, dy and type, but no input image yet 00089 /*! @param dx the number of pixels to shift into the x-direction 00090 (can be fractional value) 00091 @param dy the number of pixels to shift into the y-direction 00092 @param typ the type of pyramid to use for the filtering 00093 @param gabor_theta orientation of a gabor filter (if typ is GaborX) 00094 @param intens used for gabor filter ... */ 00095 CudaReichardtPyrBuilder(const float dx, 00096 const float dy, 00097 const PyramidType typ, 00098 const float gabor_theta = 0.0F, 00099 const float intens = 10.0F); 00100 00101 // default copy constructor and assignment are okay 00102 // std::vector and std::deque handle the copying of the indivisual images 00103 00104 //! cloning constructor 00105 virtual CudaReichardtPyrBuilder<T>* clone() const; 00106 00107 //! Builds a Reichardt pyramid based on a image 00108 virtual CudaImageSet<T> build(const CudaImage<T>& image, 00109 const int firstlevel, const int depth, 00110 CudaPyramidCache<T>* cache = 0); 00111 00112 //! reset the stored queues - overrides PyrBuilder<T>::reset() 00113 virtual void reset(); 00114 00115 private: 00116 float itsDX, itsDY; 00117 PyramidType itsPtype; // Gaussian, Laplacian, Gabor, etc. 00118 float itsGaborAngle; // orientation tuning for Gabor pyr 00119 float itsGaborIntens; // filter strength for Gabor pyr 00120 std::deque< CudaImageSet<T> > shifted, unshifted; 00121 }; 00122 00123 #endif