Go to the documentation of this file.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,
00017 BARREL,
00018 };
00019
00020 namespace Tracking{
00021
00023 class ImageProcessor{
00024 private:
00025 unsigned m_width;
00026 unsigned m_height;
00027 int m_dlRect;
00028 int m_dlImage;
00029 int m_dlUpsideDown;
00030 LensMode m_lensMode;
00031
00032 Shader* m_shadeGauss;
00033 Shader* m_shadeSobel;
00034 Shader* m_shadeThinning;
00035 Shader* m_shadeSpreading;
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
00059 void setCamOrtho();
00060 int getWidth(){ return m_width; }
00061 int getHeight(){ return m_height; }
00062
00063
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
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
00084 bool init(unsigned w, unsigned h);
00085 };
00086
00087 }
00088
00089 #endif