-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebcamviewer.h
50 lines (34 loc) · 1.32 KB
/
webcamviewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef WEBCAMVIEWER_H
#define WEBCAMVIEWER_H
#include <QWidget>
#include <QGLWidget>
#include <opencv2/core/core.hpp>
class WebcamViewer : public QGLWidget
{
Q_OBJECT
public:
explicit WebcamViewer(QWidget *parent = 0);
virtual void mousePressEvent(QMouseEvent *event);
protected:
void initializeGL(); /// OpenGL initialization
void paintGL(); /// OpenGL Rendering
void resizeGL(int width, int height); /// Widget Resize Event
void updateScene(); /// Forces a scene update
void renderImage(); /// Render image on openGL frame
signals:
void imageSizeChanged( int outW, int outH ); /// Used to resize the image outside the widget
void mousePress(int x, int y);
public slots:
bool showImage( cv::Mat image ); /// Used to set the image to be viewed
private:
bool mSceneChanged; /// Indicates when OpenGL view is to be redrawn
QImage mRenderQtImg; /// Qt image to be rendered
cv::Mat mOrigImage; /// original OpenCV image to be shown
QColor mBgColor; /// Background color
int mOutH; /// Resized Image height
int mOutW; /// Resized Image width
float mImgRatio; /// height/width ratio
int mPosX; /// Top left X position to render image in the center of widget
int mPosY; /// Top left Y position to render image in the center of widget
};
#endif // WEBCAMVIEWER_H