-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGui.cpp
More file actions
140 lines (108 loc) · 4.3 KB
/
Copy pathGui.cpp
File metadata and controls
140 lines (108 loc) · 4.3 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
#include "Gui.h"
#include <vector>
#include <boost/filesystem.hpp>
#include <QAction>
#include <QFileDialog>
#include <QShortcut>
#include <QKeySequence>
#include <QListWidget>
#include "opencv2/highgui/highgui.hpp"
namespace BioTracker {
namespace Gui {
Gui::Gui()
: QObject()
, m_biotracker()
, m_mainWindow(m_biotracker) {
initConnects();
m_mainWindow.show();
}
void Gui::initConnects() {
//File -> Open Video
QObject::connect(m_mainWindow.getUi().actionOpen_Video, &QAction::triggered,
this, &Gui::browseVideo);
QObject::connect(m_mainWindow.getUi().actionOpen_Picture, &QAction::triggered,
this, &Gui::browsePictures);
QObject::connect(m_mainWindow.getUi().actionOpen_Camera, &QAction::triggered,
this, &Gui::browseCameras);
QObject::connect(m_mainWindow.getUi().actionLoad_Tracker, &QAction::triggered,
this, &Gui::loadTracker);
QObject::connect(m_mainWindow.getUi().actionLoad_tracking_data,
&QAction::triggered, this, &Gui::loadTrackingData);
QObject::connect(m_mainWindow.getUi().actionSave_tracking_data,
&QAction::triggered, this, &Gui::storeTrackingData);
QObject::connect(m_mainWindow.getUi().actionQuit, &QAction::triggered, this,
&Gui::exit);
QObject::connect(&m_biotracker, &Core::BioTrackerApp::frameCalculated,
m_mainWindow.getVideoControl(), &VideoControlWidget::frameCalculated);
QObject::connect(&m_biotracker, &Core::BioTrackerApp::notify,
&m_mainWindow.getNotification(), &NotificationWidget::notify);
QObject::connect(&m_biotracker, &Core::BioTrackerApp::fileOpened,
&m_mainWindow, &MainWindow::fileOpened);
QObject::connect(&m_biotracker, &Core::BioTrackerApp::fileOpened,
m_mainWindow.getVideoControl(), &VideoControlWidget::fileOpened);
}
void Gui::browseVideo() {
static const QString videoFilter("Video files (*.avi *.wmv *.mp4 *.mkv)");
std::vector<boost::filesystem::path> files;
const QString filename = QFileDialog::getOpenFileName(&m_mainWindow,
"Open video", "", videoFilter);
if (!filename.isEmpty()) {
m_biotracker.openVideo(boost::filesystem::path(filename.toStdString()));
m_mainWindow.getVideoControl()->updateWidgets();
}
}
void Gui::browsePictures() {
static const QString imageFilter(
"image files (*.png *.jpg *.jpeg *.gif *.bmp *.jpe *.ppm *.tiff *.tif *.sr *.ras *.pbm *.pgm *.jp2 *.dib)");
std::vector<boost::filesystem::path> files;
for (QString const &path : QFileDialog::getOpenFileNames(&m_mainWindow,
"Open image files", "", imageFilter)) {
files.push_back(boost::filesystem::path(path.toStdString()));
}
if (!files.empty()) {
m_biotracker.openImages(files);
m_mainWindow.getVideoControl()->updateWidgets();
}
}
void Gui::browseCameras() {
OpenCameraDialog &cameraDialog = m_mainWindow.getOpenCameraDialog();
// Preparing list widget
QListWidget *cameraListWidget = cameraDialog.getUi().cameraList;
cameraListWidget->clear();
// Add Item for each camera
cv::VideoCapture vcap;
for (uint8_t i = 0; i <= 254; i++) {
vcap = cv::VideoCapture(i);
if (!vcap.isOpened()) {
break;
}
vcap.release();
cameraListWidget->addItem(QString("Camera ") + QString::number(static_cast<int>
(i)));
}
if (cameraDialog.exec() == QDialog::Accepted) {
// Getting chosen
int row = cameraListWidget->currentRow();
if (row >= 0) {
m_biotracker.openCamera(row);
m_mainWindow.getVideoControl()->updateWidgets();
}
}
}
void Gui::loadTracker() {
static const QString trackerFilter("BioTracker algorithms (*.tracker)");
const QString path = QFileDialog::getOpenFileName(&m_mainWindow, "Load Tracker",
"", trackerFilter);
if (!path.isEmpty()) {
boost::filesystem::path libraryPath(path.toStdString());
m_biotracker.getRegistry().loadTrackerLibrary(libraryPath);
}
}
void Gui::loadTrackingData() {
}
void Gui::storeTrackingData() {
}
void Gui::exit() {
}
} // Gui
} // BioTracker