-
Notifications
You must be signed in to change notification settings - Fork 7
/
mainwindow.h
198 lines (155 loc) · 6.76 KB
/
mainwindow.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*#-------------------------------------------------
#
# Segmentation to Depthmap to 3D with openCV
#
# by AbsurdePhoton - www.absurdephoton.fr
#
# v1.5 - 2019/07/08
#
#-------------------------------------------------*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <iostream>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include <opencv2/ximgproc.hpp>
#include "opencv2/opencv.hpp"
#include "opencv2/core/utility.hpp"
#include <QMainWindow>
#include <QFileDialog>
#include <QButtonGroup>
#include <QListWidgetItem>
#include "mat-image-tools.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
private slots:
//// quit
void on_button_quit_clicked();
//// init
void AddCurveItem(const QString &title, const QColor &color, const QString &tip);
//// labels
void on_listWidget_labels_currentItemChanged(QListWidgetItem *currentItem); // show current label color when item change
//// load & save
void ChangeBaseDir(QString filename); // Set base dir and file
void SaveDirBaseFile(); // just to keep the last open dir
void DisableGUI();
void on_button_save_depthmap_clicked(); // save session files
void on_button_load_depthmap_clicked(); // load session files
void on_button_load_segmentation_clicked();
void on_button_load_rgbd_clicked();
void on_button_save_ply_clicked();
//// Display
// Masks
void on_checkBox_depthmap_clicked(); // toggle depthmap view
void on_checkBox_image_clicked(); // toggle image view
void on_horizontalSlider_blend_image_valueChanged(); // image transparency
void on_horizontalSlider_blend_depthmap_valueChanged(); // depthmap transparency
// Gradients
void on_radioButton_flat_clicked();
void on_radioButton_linear_clicked();
void on_radioButton_double_linear_clicked();
void on_radioButton_radial_clicked();
void on_horizontalSlider_begin_valueChanged(int value);
void on_horizontalSlider_end_valueChanged(int value);
void on_listWidget_gradient_curve_currentItemChanged(QListWidgetItem *currentItem);
// Viewport
void on_pushButton_zoom_minus_clicked(); // levels of zoom
void on_pushButton_zoom_plus_clicked();
void on_pushButton_zoom_fit_clicked();
void on_pushButton_zoom_100_clicked();
void on_horizontalScrollBar_viewport_valueChanged(); // scroll the viewport
void on_verticalScrollBar_viewport_valueChanged();
// 3D view
void on_checkBox_3d_realtime_clicked();
void on_button_3d_update_clicked();
void on_checkBox_3d_anaglyph_clicked();
void on_checkBox_3d_axes_clicked();
void on_checkBox_3d_blur_clicked();
void on_checkBox_3d_light_clicked();
void on_comboBox_3d_tint_currentIndexChanged(int index);
void on_doubleSpinBox_gamma_valueChanged(double value);
void on_horizontalSlider_depth3D_valueChanged(int value);
void on_horizontalSlider_anaglyph_shift_valueChanged(int value);
void on_horizontalSlider_blur_amount_valueChanged(int value);
void on_button_3d_reset_clicked();
void on_checkBox_3d_fullscreen_clicked();
// 3D capture
void on_spinBox_3d_frames_valueChanged(int value);
void on_checkBox_3d_capture_clicked();
void on_checkBox_3d_capture_unique_clicked();
void on_checkBox_3d_infinite_cycle_clicked();
void on_checkBox_3d_double_cycle_clicked();
//void on_checkBox_3d_circular_clicked();
void on_checkBox_3d_capture_fullscreen_clicked();
private:
//// UI
void InitializeValues();
//// labels
int GetCurrentLabelNumber(); // label value for use with label_mask
void DeleteAllLabels(); // delete ALL labels and create one new if wanted
//// Keyboard & mouse events
void keyPressEvent(QKeyEvent *keyEvent); // for the create cell mode
void keyReleaseEvent(QKeyEvent *keyEvent);
void mouseReleaseEvent(QMouseEvent *eventRelease); // when the mouse button is released
void mousePressEvent(QMouseEvent *eventPress); // mouse events = zoom, set cell color etc
void mouseMoveEvent(QMouseEvent *eventPress);
void wheelEvent(QWheelEvent *wheelEvent);
//// Display
void Render(); // display image in viewport with depthmap and selection
void ShowThumbnail(); // display thumbnail view
/*void ShowAnaglyph();
void ShowAnaglyphProject3D();*/
void ZoomPlus(); // zoom in
void ZoomMinus(); // zoom out
void ShowZoomValue(); // display current zoom level
void BlockGradientsSignals(const bool &active);
void ChangeLabelGradient();
void ShowGradient();
void SetViewportXY(const int &x, const int &y); // change the origin of the viewport
void UpdateViewportDimensions(); // calculate width and height of the viewport
cv::Point Viewport2Image(const cv::Point &p); // calculate coordinates in the image from the viewport
// the UI object, to access the UI elements created with Qt Designer
Ui::MainWindow *ui;
cv::Mat labels; // Segmentation cells and labels
int nbLabels; // max number of labels
cv::Mat image, // main image
thumbnail, // thumbnail of main image
depthmap, // gray-painted cells
selection, // selection mask
currentLabelMask; // for 3D partial update
cv::Rect selection_rect; // rectangle of current selection
cv::Mat disp_color; // Processed image display with mask and depthmap
cv::Rect viewport; // part of the segmentation image to display
std::string basefile, basedir, basedirinifile; // main image filename: directory and filename without extension
Qt::MouseButton mouseButton; // save mouse button value when holding down a mouse button
QPoint mouse_origin; // save the mouse position when holding down a mouse button
cv::Point pos_save; // save the mouse position in image coordinates
int num_zooms = 22; // number of zoom values
double zooms[23] = {0, 0.05, 0.0625, 0.0833, 0.125, 0.1667, 0.25, 0.3333, 0.5, 0.6667, // reduced view
1, 1.25, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10000}; // zoomed view
double zoom, oldZoom; // zoom factor for image display
QString zoom_type; // if zoom changes indicates where it came from: button clic or mouse wheel
bool loaded, computeVertices3D, updateVertices3D, computeColors3D; // indicators: image loaded & segmentation computed
bool moveBegin, moveEnd;
bool abort_3d;
int saveXOpenGL, saveYOpenGL, saveWidthOpenGL, saveHeightOpenGL;
struct struct_gradient{
cv::Point beginPoint;
cv::Point endPoint;
int beginColor;
int endColor;
gradientType gradient;
curveType curve;
};
struct_gradient gradients[1000];
};
#endif // MAINWINDOW_H