You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#ifndef __FULL_SCREEN_GL_VIDEO_WIDGET_HEADER__
#define __FULL_SCREEN_GL_VIDEO_WIDGET_HEADER__
#include <vector>
#include "../guiClass.h"
#include <QtWidgets/QOpenGLWidget>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/QOpenGLBuffer>
#include <QtGui/QVector3D>
#include <QtGui/QMatrix4x4>
#include <QtCore/QTime>
#include <QtCore/QVector>
#include <QtWidgets/QPushButton>
#include <QtGui/QOpenGLShaderProgram>
#include <QtGui/QOpenGLTexture>
#include <opencv2/opencv.hpp>
#include "../../components/base/basicLIBAV.h"
#include "../../components/base/basicMediaDestination.h"
#include "../../components/base/basicMutex.h"
#include "../../components/base/basicCameraPTZ.h"
#include "../../components/base/basicStatus.h"
#include <string.h> // for memcpy
#include <stdexcept>
#include <assert.h>
// It's important to keep these unique so that glEnableVertexAttribArray only needs to be called a minimal amount as it is an expensive call on the raspberry pi
#define MY_VERTEX_ARRAY 0
#define MY_TEXCOORD_ARRAY 1
#define PROGRAM_VERTEX_ATTRIBUTE 0
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
// this can be replaced with whatever
#define GL_ASSERT(str) assert(glGetError() == GL_NO_ERROR)
// макрос приведения к типу const GLvoid *
#define GL_OFFSET_(x) ((const GLvoid *)(x))
// структура с описанием вершины для полноэкранного прямоугольника
typedef struct S_fsqVertex { GLfloat position[3]; GLfloat texcoord[2];} fsqVertex;
// VAO и VBO для полноэкранного прямоугольника
//GLuint fsqVAO = 0, fsqVBO = 0;
//class MainWindow;
class FSGLVideoWidget : public QOpenGLWidget, protected QOpenGLFunctions, public basicMediaDestination { //friend class QPixmap;
private: U8 m_bStatus; int m_nMouseX; int m_nMouseY; int m_nSourceWidth; int m_nSourceHeight; U32 m_nKeyCode; U32 m_nOldKeyCode;
ControlDirection m_nManualControlMode;
//bool m_bMouseActive;
int m_nMenuActivityCounter; bool m_bGrayScale; bool m_bEnhanced; bool m_bDirectDrawing; FrameAspectRatio m_eWidgetAspectRatio; FrameAspectRatio m_eStreamAspectRatio;
IplImage *m_pGraber; cv::Mat *m_mFrame; cv::Mat *m_mOutput;
QOpenGLTexture *m_pTexture; QOpenGLShader *m_pVertexShader; QOpenGLShader *m_pFragmentShader; QOpenGLShaderProgram *m_pShaderProgram; QColor m_background; int m_vertexAttr; int m_normalAttr; int m_matrixUniform; int m_textureUniform; int m_texCoordAttr; qreal m_fAngle; qreal m_fScale; QVector<QVector3D> m_vertices; QVector<QVector3D> m_normals; QOpenGLBuffer m_vbo; GLuint m_nTextureID;
GLuint m_uTexCoordBuffer; GLuint m_uTexCoordFlippedBuffer; GLuint m_uVertexBufferFullScreen;
GLsizei m_nTextureWidth; GLsizei m_nTextureHeight;
objectCaps m_nCameraCaps; basicCamera *m_pCamera;
basicMediaDestination *m_pParentViewer; basicMutex *m_pPropertiesProtectorMutex; basicMutex *m_pWidgetProtectorMutex; void m_fThreadProc(void);
GLuint fsqVAO, fsqVBO; QOpenGLBuffer m_vbo1; QOpenGLBuffer m_vbo2; /* Initers */ void InitGLAttributes(void); void InitTextures(void); void InitShaders(void); void InitSamplers(void); void InitBuffers(void); void InitProjectionMatrices(void); void InitViewMatrices(void); protected: QImage m_iFrame; /* Main Video */ QPixmap *m_pPixmap; /* OSD Pixmaps */ QPixmap *m_pManualMode; QPixmap *m_pPixUp; QPixmap *m_pPixDown; QPixmap *m_pPixLeft; QPixmap *m_pPixRight; QPixmap *m_pPixWide; QPixmap *m_pPixTele; protected: void resizeGL( int w, int h) Q_DECL_OVERRIDE; void paintGL() Q_DECL_OVERRIDE; void initializeGL() Q_DECL_OVERRIDE; public:
explicit FSGLVideoWidget( QWidget *parent, int sizeX, int sizeY, const QColor &background );
~FSGLVideoWidget();
virtual void render( QPainter *painter); bool init( void ); void pushFrame( cv::Mat *Frame ); void setSourceSize( int sizeX, int sizeY ); void setSoutceType( int Type );
/* Binding to parent Video Viewer */ void setCameraControl( basicCamera *C, objectCaps CC); void setBindingSize( basicMediaDestination *P, int x, int y);
//public slots:
//void renderLater();
//void renderNow();
protected: bool event(QEvent *event);
//void resizeEvent(QResizeEvent *event);
void exposeEvent(QExposeEvent *event); //void paintEvent(QPaintEvent *event);
//void drawContents(QPainter * p, const QRectF & rect = QRectF());
private: bool m_bUpdateIsPending; QTimer *m_pTimer;};
#endif
|