-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtexture2grayimageconvertor.h
55 lines (42 loc) · 1.72 KB
/
texture2grayimageconvertor.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
51
52
53
54
55
#ifndef TEXTURE2GRAYIMAGECONVERTOR_H
#define TEXTURE2GRAYIMAGECONVERTOR_H
#include <tuple>
#include <QSize>
#include <QSharedPointer>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLFramebufferObject>
#include <QMatrix4x4>
#include <opencv2/core.hpp>
#include "gl/gl_mesh.h"
#include "gl/gl_shadermaterial.h"
class Texture2GrayImageConvertor
{
public:
Texture2GrayImageConvertor();
cv::Mat read(QOpenGLFunctions * gl,
GLuint textureId,
QSize textureSize,
const QSize & maxImageSize,
int orientation = 0,
bool flipHorizontally = false);
std::tuple<cv::Mat, QVector2D> read_cropped(QOpenGLFunctions * gl,
GLuint textureId,
QSize textureSize,
const QSize & maxImageSize,
float viewAspect,
int orientation = 0,
bool flipHorizontally = false);
private:
GL_MeshPtr m_quad;
GL_ShaderMaterialPtr m_materialColor;
GL_ShaderMaterialPtr m_materialPackedGray;
QSharedPointer<QOpenGLFramebufferObject> m_fboColor;
QSharedPointer<QOpenGLFramebufferObject> m_fboPackedGray;
QSize _getImageSize(const QSize & textureSize,
QSize maxImageSize, bool k4fixFlag) const;
QMatrix4x4 _getRotation(int orientation) const;
QMatrix4x4 _getViewMatrix(float scaleX, float scaleY) const;
QMatrix4x4 _getMatrixMVP(int orientation, bool flipHorizontally) const;
};
#endif // TEXTURE2GRAYIMAGECONVERTOR_H