Visualization 2 - Lab Course
 All Classes Functions Enumerations Enumerator
cannyedge.h
1 #ifndef CANNYEDGE_H
2 #define CANNYEDGE_H
3 
4 #include <QtGui>
5 #include <QWindow>
6 #include <QtOpenGL>
7 #include <QOpenGLFunctions_3_2_Core>
8 #include "junctiondetector.h"
9 
10 #define PI acos(-1.0f)
11 
12 
19 class CannyEdge
20 {
21 public:
32  CannyEdge(QWindow *_qgl_window, QOpenGLContext *_qgl_contex, float _sigma, int _filterSize, int _width, int _height);
33 
37  ~CannyEdge();
38 
43  void setSigma(float _sigma);
48  float getSigma();
53  void setFilterSize(int _filterSize);
58  int getFilterSize();
59 
63  void detectEdges(GLuint texture);
64 
69  GLuint getGradientFieldTexture();
74  GLuint getCannyEdgeTexture();
79  QImage getGradientFieldImage();
84  QImage getCannyEdgeImage();
85 
86 private:
87  float sigma;
88  int filterSize;
89  float *filterCoefficients;
90  int width, height;
91  float *verticesFullscreenQuad;
92 
93  QWindow *qgl_window;
94 
95  GLuint image;
96  GLuint filterTex;
97 
98  QOpenGLContext *qgl_context;
99  QOpenGLFunctions_3_2_Core *qgl_funcs;
100 
101  QOpenGLShaderProgram qgl_cannyBlurShader;
102  QOpenGLShaderProgram qgl_cannyMagnitudeShader;
103  QOpenGLShaderProgram qgl_cannyEdgeShader;
104  QOpenGLFramebufferObject *qgl_cannyFBO1;
105  QOpenGLFramebufferObject *qgl_cannyFBO2;
106 
107  QOpenGLVertexArrayObject qgl_quad;
108 
109  void prepareShaders();
110  void prepareVertexArrayObject();
111 
112  void updateFilterCoefficients();
113 
114  void imageBlur(QOpenGLFramebufferObject *fbo, GLuint texture);
115  void imageMagnitude(QOpenGLFramebufferObject *fbo, GLuint texture);
116  void imageNonMaximaSuppression(QOpenGLFramebufferObject *fbo, GLuint texture);
117 };
118 
119 #endif //CANNYEDGE