$search
00001 00002 #ifndef _IMAGE_PROCESSOR_H_ 00003 #define _IMAGE_PROCESSOR_H_ 00004 00005 namespace Tracking{ 00006 class ImageProcessor; 00007 } 00008 #include <blort/Tracker/headers.h> 00009 00010 #include <blort/Tracker/Shader.h> 00011 #include <blort/Tracker/Texture.h> 00012 #include <blort/TomGine/tgCamera.h> 00013 #include <blort/Tracker/Resources.h> 00014 00015 enum LensMode{ 00016 NONE, // No rectification 00017 BARREL, // Rectification using Barrel equation 00018 }; 00019 00020 namespace Tracking{ 00021 00023 class ImageProcessor{ 00024 private: 00025 unsigned m_width; // Image width in pixels 00026 unsigned m_height; // Image height in pixels 00027 int m_dlRect; // Display list for rectification (distorted TexCoords) 00028 int m_dlImage; // Display List for normal images (less geometry) 00029 int m_dlUpsideDown; // Display List for flipping image upside down 00030 LensMode m_lensMode; // Enumeration for lens rectification algorithm (NONE, BARREL) 00031 00032 Shader* m_shadeGauss; // Fragment shader for blurring image using gaussian filter 00033 Shader* m_shadeSobel; // Fragment shader for edge detection with sobel algorithm 00034 Shader* m_shadeThinning; // Fragment shader for thinning edges 00035 Shader* m_shadeSpreading; // Fragment shader for spreading edges 00036 00037 TomGine::tgCamera m_cam_ortho, m_cam_ortho_fbo; 00038 00039 GLuint fbo; 00040 GLuint fbo_tex; 00041 GLuint fbo_tex_depth; 00042 int fbo_res; 00043 int fbo_stage; 00044 bool m_sum_init; 00045 00046 bool initShader(); 00047 bool dlImage(); 00048 bool dlImage(float x, float y, float w, float h); 00049 bool dlFlipUpsideDown(); 00050 bool dlRectification(); 00051 bool transform(float i, float j, float *ix, float *iy); 00052 00053 public: 00054 00055 ImageProcessor(); 00056 ~ImageProcessor(); 00057 00058 // Set functions 00059 void setCamOrtho(); 00060 int getWidth(){ return m_width; } 00061 int getHeight(){ return m_height; } 00062 00063 // Image Processing functions 00064 void flipUpsideDown(Texture* source, Texture* result); 00065 void copy(Texture* source, Texture* result); 00066 void rectification(Texture* source, Texture* result); 00067 void gauss(Texture* source, Texture* result); 00068 void sobel(Texture* source, Texture* result, float threshold=0.01, bool normalise=false, bool binary=false); 00069 void sobel(Texture* source, Texture* result, Texture* mask, float threshold=0.01, bool normalize=false, bool binary=false); 00070 void thinning(Texture* source, Texture* result); 00071 void thinning(Texture* source, Texture* result, Texture* mask); 00072 void spreading(Texture* source, Texture* result); 00073 void render(Texture* tex); 00074 void render(Texture*tex, int x, int y, unsigned w, unsigned h); 00075 00076 // summation 00077 GLenum avgInit(int res); 00078 void avgActivate(); 00079 void avgGet(float *avg, int lvl=0); 00080 void avgDeactivate(); 00081 inline int avgGetResolution(){ return fbo_res; } 00082 00083 // Main functions 00084 bool init(unsigned w, unsigned h); 00085 }; 00086 00087 } // namespace Tracking 00088 00089 #endif