34 #include <QGLFunctions>
36 #include <QQuaternion>
38 #include <QBasicTimer>
39 #include <QGLShaderProgram>
42 #include "gridengine.h"
43 #include "videoengine.h"
44 #include "calibrationpoints.h"
45 #include "cavapa/cavapa.h"
47 namespace cavapa_gui {
67 class SourceScene :
public QGLWidget,
protected QOpenGLFunctions
156 this->isAddCalibrationPointsEnabled = enabled;
213 isDrawCalibrationPointsEnabled = enabled;
305 void handleContextMenuAction(QAction* action);
309 cv::Mat background_mat;
312 QGLShaderProgram program;
313 QGLShaderProgram gridProgram;
317 QMatrix4x4 gridProjection;
318 QMatrix4x4 videoSurfaceProjection;
320 QPoint newCalibrationPointLocation;
324 QQuaternion cameraYRotation;
325 QQuaternion cameraXRotation;
326 QQuaternion cameraZRotation;
333 qreal aspect, zNear, zFar;
335 bool isDrawGridEnabled =
false;
336 bool isDrawCalibrationPointsEnabled =
false;
346 QAction* actionAddCalibrationPoint;
347 QAction* actionRemoveSelectedCalibrationPoint;
348 QAction* actionClearCalibartionPoints;
350 bool isAddCalibrationPointsEnabled =
false;
355 #endif // SOURCESCENE_H
void drawGrid()
Draws the grid.
Definition: sourcescene.cpp:361
Draws a grid with OpenGL.
Definition: gridengine.h:48
void setCameraYRot(float value)
Sets the camera rotation around Y axis.
Definition: sourcescene.cpp:154
void resizeGL(int w, int h)
Resizes the GL viewport.
Definition: sourcescene.cpp:297
void setCameraHeight(float value)
Sets the camera height.
Definition: sourcescene.cpp:142
A class for drawing the video frame with OpenGL.
Definition: videoengine.h:44
CalibrationPoints getCalibrationPoints()
Gets the calibration points.
Definition: sourcescene.h:138
QVector3D getCameraPosition()
Gets the camera position.
Definition: sourcescene.cpp:255
float getCameraYRot()
Returns the camera rotation around Y axis.
Definition: sourcescene.h:89
void timerEvent(QTimerEvent *e)
The timer event.
Definition: sourcescene.cpp:173
SourceScene draws a video stream and configures camera parameters.
Definition: sourcescene.h:67
void mouseReleaseEvent(QMouseEvent *e)
Reacts to a mouse release event: If right mouse button was released, display a context menu that has ...
Definition: sourcescene.cpp:70
cavapa::camera getCameraSettings()
Gets the camera settings.
Definition: sourcescene.cpp:259
float getCameraZRot()
Returns the camera rotation around Z axis.
Definition: sourcescene.h:95
void setCameraFov(float value)
Sets the camera field of view.
Definition: sourcescene.cpp:168
void setCameraXRot(float value)
Sets the camera rotation around X axis.
Definition: sourcescene.cpp:147
void updateImage(const cv::Mat &image)
Updates the background image.
Definition: sourcescene.cpp:282
CalibrationPoints stores a collection of calibration points that can be drawn on a QPainter...
Definition: calibrationpoints.h:52
void setCameraSettings(cavapa::camera settings)
Sets camera settings.
Definition: sourcescene.cpp:272
void addCalibrationlPoint(QPointF point)
Adds a new calibration point.
Definition: sourcescene.h:145
void paintGL()
Paints the GL scene.
Definition: sourcescene.cpp:408
float getCameraHeight()
Returns the camera height.
Definition: sourcescene.h:101
void setDrawGridEnabled(bool enabled)
Sets if the grid should be drawn.
Definition: sourcescene.h:205
void drawCalibrationPoints(QPainter &painter)
Draws the calibration points.
Definition: sourcescene.cpp:391
void setAddCalibrationPointsEnabled(bool enabled)
Sets if adding calibration points should be possible.
Definition: sourcescene.h:154
void setGlViewport()
Sets the GL viewport.
Definition: sourcescene.cpp:316
void setDrawCalibrationPointsEnabled(bool enabled)
Sets if the calibration points should be drawn.
Definition: sourcescene.h:212
float getCameraFov()
Sets the field of view of the camera.
Definition: sourcescene.h:107
void calculateViewPort()
Calculates the viewport maintaining the video aspect ratio.
Definition: sourcescene.cpp:320
void initShaders()
Initializes the shaders.
Definition: sourcescene.cpp:198
void mousePressEvent(QMouseEvent *e)
Reacts to a mouse press event by highlighting the closest calibration point.
Definition: sourcescene.cpp:112
QPointF getRelativeVideoPosition(QPoint widgetPoint)
Calculates the relative position of a point in the video.
Definition: sourcescene.cpp:134
void push_back(QPointF newPoint)
Adds a new calibration point.
Definition: calibrationpoints.cpp:38
SourceScene(QWidget *parent=0)
Constructs a new SourceScene having the specified parent widget.
Definition: sourcescene.cpp:45
void initializeGL()
Initializes the OpenGL scene.
Definition: sourcescene.cpp:185
void setCameraZRot(float value)
Sets the camera rotation around Z axis.
Definition: sourcescene.cpp:161
float getCameraXRot()
Returns the camera rotation around X axis.
Definition: sourcescene.h:83
void drawBackgroundImage()
Draws the background image.
Definition: sourcescene.cpp:347
QVector3D getCameraLookDirection()
Gets the camera look direction.
Definition: sourcescene.cpp:251