-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel.h
89 lines (66 loc) · 2 KB
/
panel.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef PANEL_H
#define PANEL_H
#include <QOpenGLWidget>
#include <QQuaternion>
#include <QBasicTimer>
#include <QOpenGLFramebufferObject>
#include <opencv2/opencv.hpp>
#include "rendermesh.h"
#include "meshbuilders.h"
#include "fileutil.h"
struct CameraParam{
float fx = 473.297f;
float fy = fx;
float cx = 316.561f;
float cy = 245.293f;
};
class Panel : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit Panel(QWidget *parent = 0);
~Panel();
void addMesh(unique_ptr<Mesh> mesh);
void setHandMesh(unique_ptr<Mesh> mesh);
void addKeyIndices(const std::vector<int> & indices);
void setMeshVisible(int id, bool show);
void reloadMeshes(QString path);
void showDepthMap(bool depth_mode);
void saveColorImage(QString filename);
void saveDepthImage(QString filename);
void saveKeyPos(QString filename);
protected:
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void wheelEvent(QWheelEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
void initMeshes();
private:
void clearAuxiliaryMeshes();
void initAuxiliaryMeshes();
void updateAuxiliaryMeshes();
private:
CameraParam cameraParam;
QMat4 projection_;
QVec2 mouse_position_;
QVec3 rotation_axis_;
QQuaternion rotation_;
qreal angular_speed_;
qreal scale_;
qreal offset_x_, offset_y_, offset_z_;
bool press_{0};
bool depth_{0};
unique_ptr<Mesh> hand_mesh_;
std::vector<unique_ptr<Mesh>> meshes_;
unordered_map<Mesh*, unique_ptr<RenderMesh>> mesh_map_;
std::vector<std::vector<int>> hand_key_indices_;
std::vector<Vec3> hand_key_pos_;
std::vector<unique_ptr<Mesh>> auxiliary_meshes_;
GLuint colorbuffer, depthbuffer;
cv::Mat color_image_, depth_image_;
};
#endif // PANEL_H