This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRawImagesWindow.cpp
More file actions
170 lines (143 loc) · 4.94 KB
/
Copy pathRawImagesWindow.cpp
File metadata and controls
170 lines (143 loc) · 4.94 KB
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
/**
* This file is part of the rgbdemo project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Nicolas Burrus <nicolas@burrus.name>, (C) 2010, 2011
*/
#include <sstream>
#include "RawImagesWindow.h"
#include "ui_RawImagesWindow.h"
#include "PoseRecognizer.h"
#include "GuiController.h"
#include <ntk/camera/rgbd_frame_recorder.h>
#include <ntk/camera/rgbd_processor.h>
#include <ntk/gesture/skeleton.h>
#include <ntk/utils/opencv_utils.h>
#ifdef NESTK_USE_FREENECT
# include <ntk/camera/freenect_grabber.h>
#endif
#include <QCloseEvent>
using namespace ntk;
using namespace cv;
using namespace std;
RawImagesWindow::RawImagesWindow(GuiController& controller, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::RawImagesWindow),
m_controller(controller),
jointPos(4),
myRecognizer()
{
ui->setupUi(this);
connect(ui->depthView, SIGNAL(mouseMoved(int,int)),
&m_controller, SLOT(on_depth_mouse_moved(int,int)));
ui->depthView->setMouseTracking(true);
ui->action_Show_Object_Detector->setDisabled(true);
ui->action_3D_View->setDisabled(true);
if (m_controller.grabber().isSynchronous())
ui->syncMode->setChecked(true);
}
RawImagesWindow::~RawImagesWindow()
{
delete ui;
}
void RawImagesWindow :: update(const ntk::RGBDImage& image)
{
myRecognizer.setSkeleton(image);
jointPos[0] = image.skeleton()->getProjectedJoint(ntk::Skeleton::NTK_SKEL_HEAD);
jointPos[1] = image.skeleton()->getProjectedJoint(ntk::Skeleton::NTK_SKEL_NECK);
jointPos[2] = image.skeleton()->getProjectedJoint(ntk::Skeleton::NTK_SKEL_LEFT_HAND);
jointPos[3] = image.skeleton()->getProjectedJoint(ntk::Skeleton::NTK_SKEL_RIGHT_HAND);
int ind = 0;
//update joint readings in joints tableviewwidget
for (vector<Point3f>::const_iterator iter = jointPos.begin(); iter != jointPos.end(); ++iter) {
ind = iter - jointPos.begin();
QString temp = QString("(%1, %2, %3)").arg(iter->x,0,'f',1).arg(iter->y,0,'f',1).arg(iter->z,0,'f',1);
if (ui->joints->item(ind,0) == 0) {
QTableWidgetItem *itab = new QTableWidgetItem;
itab->setText(temp);
ui->joints->setItem(ind,0,itab);
}
else {
ui->joints->item(ind,0)->setText(temp);
}
}
// try to recognize pose and print ui_gesture label
ui->gesture->setText(QString((myRecognizer.recognizePose()).c_str()));
if (ui->colorView->isVisible())
ui->colorView->setImage(image.rgb());
if (ui->depthView->isVisible())
{
double min_dist = m_controller.rgbdProcessor().minDepth();
double max_dist = m_controller.rgbdProcessor().maxDepth();
cv::Mat1f masked_distance; image.depth().copyTo(masked_distance);
apply_mask(masked_distance, image.depthMask());
cv::Mat3b depth_as_color;
compute_color_encoded_depth(masked_distance, depth_as_color, &min_dist, &max_dist);
if (image.skeleton())
image.skeleton()->drawOnImage(depth_as_color);
ui->depthView->setImage(depth_as_color);
}
// ui->depthView->setImageAsColor(image.depth(), &min_dist, &max_dist);
// ui->depthView->setImage(image.depth(), &min_dist, &max_dist);
if (image.userLabels().data && ui->intensityView->isVisible())
{
cv::Mat3b user_labels;
image.fillRgbFromUserLabels(user_labels);
ui->intensityView->setImage(user_labels);
}
int x,y;
ui->depthView->getLastMousePos(x,y);
m_controller.on_depth_mouse_moved(x,y);
}
void RawImagesWindow::on_outputDirText_editingFinished()
{
QString dir = ui->outputDirText->text();
m_controller.frameRecorder()->setDirectory(dir.toStdString());
}
void RawImagesWindow::on_action_GrabOneFrame_triggered()
{
m_controller.frameRecorder()->saveCurrentFrame(m_controller.lastImage());
}
void RawImagesWindow::on_action_Quit_triggered()
{
m_controller.quit();
}
void RawImagesWindow::on_action_Screen_capture_mode_toggled(bool active)
{
m_controller.setScreenCaptureMode(active);
}
void RawImagesWindow::on_action_GrabFrames_toggled(bool active)
{
m_controller.setGrabFrames(active);
}
void RawImagesWindow::on_syncMode_toggled(bool checked)
{
m_controller.grabber().setSynchronous(checked);
if (checked)
m_controller.grabber().newEvent();
}
void RawImagesWindow::closeEvent(QCloseEvent *event)
{
ui->action_Quit->trigger();
event->accept();
}
void RawImagesWindow::on_actionPause_toggled(bool active)
{
m_controller.setPaused(active);
}
void RawImagesWindow::on_actionNext_frame_triggered()
{
m_controller.processOneFrame();
}