ProgramCL.h
Go to the documentation of this file.
00001 
00002 //      File:           ProgramCL.h
00003 //      Author:         Changchang Wu
00004 //      Description :   interface for the ProgramCL classes.
00005 //              ProgramCL:              Cg programs
00006 //              ShaderBagCG:    All Cg shaders for Sift in a bag
00007 //              FilterCL:               Cg Gaussian Filters
00008 //
00009 //      Copyright (c) 2007 University of North Carolina at Chapel Hill
00010 //      All Rights Reserved
00011 //
00012 //      Permission to use, copy, modify and distribute this software and its
00013 //      documentation for educational, research and non-profit purposes, without
00014 //      fee, and without a written agreement is hereby granted, provided that the
00015 //      above copyright notice and the following paragraph appear in all copies.
00016 //      
00017 //      The University of North Carolina at Chapel Hill make no representations
00018 //      about the suitability of this software for any purpose. It is provided
00019 //      'as is' without express or implied warranty. 
00020 //
00021 //      Please send BUG REPORTS to ccwu@cs.unc.edu
00022 //
00024 
00025 
00026 #if defined(CL_SIFTGPU_ENABLED) 
00027 
00028 #ifndef _PROGRAM_CL_H
00029 #define _PROGRAM_CL_H
00030 
00031 #include "ProgramGPU.h"
00032 
00033 class ProgramCL: public ProgramGPU
00034 {
00035         cl_program                _program; 
00036         cl_kernel                 _kernel;
00037         int                               _valid;
00038 public:
00039         int IsValidProgram(){return _program && _valid;}
00040         ProgramCL(const char* name, const char * code, cl_context contex, cl_device_id device);
00041         ProgramCL();
00042     void PrintBuildLog(cl_device_id device, int all);
00043         virtual ~ProgramCL();
00044     virtual int UseProgram(){return 1;}
00045     virtual void * GetProgramID() {return _kernel;}
00046     friend class ProgramBagCL;
00047     friend class ProgramBagCLN;
00048 };
00049 
00050 class  CLTexImage;
00051 class FilterCL
00052 {
00053 public:
00054         ProgramCL*  s_shader_h;
00055         ProgramCL*  s_shader_v;
00056         int                      _size;
00057         int                      _id; 
00058     CLTexImage * _weight;
00059 public:
00060     FilterCL() : s_shader_h(NULL), s_shader_v(NULL), _size(0), _id(0), _weight(NULL) {}
00061     ~FilterCL() {if(s_shader_h) delete s_shader_h; if(s_shader_v) delete s_shader_v; if(_weight) delete _weight; }
00062 };
00063 
00064 class  SiftParam;
00065 
00066 class ProgramBagCL
00067 {
00068 protected:
00069     cl_platform_id      _platform;
00070     cl_device_id        _device;
00071     cl_context          _context;
00072     cl_command_queue    _queue;
00073 protected:
00074     ProgramCL  * s_gray;
00075         ProgramCL  * s_sampling;
00076     ProgramCL  * s_sampling_k;
00077     ProgramCL  * s_sampling_u;
00078         ProgramCL  * s_zero_pass;
00079     ProgramCL  * s_packup;
00080     ProgramCL  * s_unpack;
00081     ProgramCL  * s_unpack_dog;
00082     ProgramCL  * s_unpack_grd;
00083     ProgramCL  * s_unpack_key;
00084     ProgramCL  * s_dog_pass;
00085     ProgramCL  * s_grad_pass;
00086     ProgramCL  * s_grad_pass2;
00087     ProgramCL  * s_gray_pack;
00088     ProgramCL  * s_keypoint;
00089 public:
00090         FilterCL  *         f_gaussian_skip0;
00091         vector<FilterCL*>   f_gaussian_skip0_v;
00092         FilterCL  *         f_gaussian_skip1;
00093         FilterCL  **        f_gaussian_step;
00094     int                     _gaussian_step_num;
00095 public:
00096         ProgramBagCL();
00097     bool InitializeContext();
00098         virtual ~ProgramBagCL();
00099     void FinishCL();
00100     cl_context          GetContextCL() {return _context;}
00101     cl_command_queue    GetCommandQueue() {return _queue;}
00102     static const char* GetErrorString(cl_int error);
00103     static bool  CheckErrorCL(cl_int error, const char* location = NULL);
00104 public:
00105     FilterCL * CreateGaussianFilter(float sigma);
00106     void CreateGaussianFilters(SiftParam&param);
00107     void SelectInitialSmoothingFilter(int octave_min, SiftParam&param);
00108     void FilterInitialImage(CLTexImage* tex, CLTexImage* buf);
00109     void FilterSampledImage(CLTexImage* tex, CLTexImage* buf);
00110     void UnpackImage(CLTexImage*src, CLTexImage* dst); 
00111     void UnpackImageDOG(CLTexImage*src, CLTexImage* dst); 
00112     void UnpackImageGRD(CLTexImage*src, CLTexImage* dst); 
00113     void UnpackImageKEY(CLTexImage*src, CLTexImage* dog, CLTexImage* dst); 
00114     void ComputeDOG(CLTexImage*tex, CLTexImage* texp, CLTexImage* dog, CLTexImage* grad, CLTexImage* rot);
00115     void ComputeKEY(CLTexImage*dog, CLTexImage* key, float Tdog, float Tedge);
00116 public:
00117         virtual void SampleImageU(CLTexImage *dst, CLTexImage *src, int log_scale);
00118         virtual void SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale = 1); 
00119     virtual void FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp);
00120     virtual ProgramCL* CreateFilterH(float kernel[], int width);
00121     virtual ProgramCL* CreateFilterV(float kernel[], int width);
00122     virtual FilterCL*  CreateFilter(float kernel[], int width);
00123 public:
00124     virtual void InitProgramBag(SiftParam&param);
00125         virtual void LoadDescriptorShader();
00126         virtual void LoadDescriptorShaderF2();
00127         virtual void LoadOrientationShader();
00128         virtual void LoadGenListShader(int ndoglev, int nlev);
00129         virtual void UnloadProgram() ;
00130         virtual void LoadKeypointShader();
00131         virtual void LoadFixedShaders();
00132         virtual void LoadDisplayShaders();
00133     virtual void LoadDynamicShaders(SiftParam& param);
00134 public:
00135         //parameters
00136         virtual void SetGradPassParam(int texP);
00137         virtual void SetGenListEndParam(int ktex);
00138         virtual void SetGenListStartParam(float width, int tex0);
00139         virtual void SetGenListInitParam(int w, int h);
00140         virtual void SetMarginCopyParam(int xmax, int ymax);
00141         virtual void SetDogTexParam(int texU, int texD);
00142         virtual void SetGenListStepParam(int tex, int tex0);
00143         virtual void SetGenVBOParam( float width, float fwidth, float size);
00144         virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
00145         virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step);
00146         virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
00147 
00148 };
00149 
00150 class CLTexImage ;
00151 class ProgramBagCLN: public ProgramBagCL
00152 {
00153 public:
00154         virtual void SampleImageD(CLTexImage *dst, CLTexImage *src, int log_scale = 1); 
00155     virtual FilterCL*  CreateFilter(float kernel[], int width);
00156     virtual ProgramCL* CreateFilterH(float kernel[], int width);
00157     virtual ProgramCL* CreateFilterV(float kernel[], int width);
00158     virtual void FilterImage(FilterCL* filter, CLTexImage *dst, CLTexImage *src, CLTexImage*tmp);
00159     virtual void LoadFixedShaders();
00160         virtual void LoadDisplayShaders();
00161 };
00162 #endif
00163 #endif
00164 


siftgpu
Author(s): Changchang Wu (library), Bence Magyar (ROS wrapper)
autogenerated on Thu Jan 2 2014 11:38:01