Signapse
Gui.cpp
Go to the documentation of this file.
1#include "Gui.h"
2
3#define UI_WDH 1000
4#define UI_HGT 700
5
11Gui::Gui(QMainWindow* win, Ui_MainWindow* ui_win) {
12 widget = win;
13 widget->setFixedSize(UI_WDH, UI_HGT);
14 ui = ui_win;
15 ui->setupUi(widget);
16 SetTask("A");
17 makeConnections();
18 SignapseUtils::randSeed();
19}
25 //flip frame
26 if(next.result == "") {
27 cv::Mat temp;
28 cv::flip(next.frame, temp, 1);
29 QImage imgIn = QImage((uchar *) temp.data, temp.cols, temp.rows, temp.step,
30 QImage::Format_RGB888);
31 ui->label->setPixmap(QPixmap::fromImage(imgIn));
32 ui->label->resize(ui->label->pixmap()->size());
33 }
34 else{
35 int progress = progressBar.GetProgress(next.result, currentTask);
36 emit progressChanged(progress);
37 if(progress >= 100){
39 }
40 }
41
42}
47void Gui::SetVisible(bool visible) {
48 widget->setVisible(visible);
49}
54void Gui::SetTargetImage(std::string letter) {
55 std::string impath = testFolder + letter + "_test.jpg";
56 cv::Mat img = cv::imread(impath);
57 setDemoImage(img);
58 setTaskText(letter);
59}
64 std::string new_task = SignapseUtils::makeTask();
65 SetTargetImage(new_task);
66 currentTask = new_task;
67 progressBar.ResetProgress();
68}
69
71 progressBar.SetThreshold(ui->spinBox->value());
72 progressBar.ResetProgress();
73}
74
78void Gui::makeConnections() {
79 QObject::connect(ui->pushButton, &QPushButton::released, this, &Gui::buttonPressed);
80 QObject::connect(this, &Gui::progressChanged, ui->progressBar, &QProgressBar::setValue);
81 QObject::connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Gui::updateThreshold);
82}
83
84
85void Gui::setDemoImage(cv::Mat img) {
86 cv::Mat rgb;
87 cv::cvtColor(img, rgb, cv::COLOR_BGR2RGB);
88 cv::Mat flip;
89 cv::flip(rgb, flip, 1);
90 ui->label_2->setPixmap(QPixmap::fromImage(QImage(flip.data, flip.cols, flip.rows, flip.step, QImage::Format_RGB888)));
91 ui->label_2->resize(ui->label_2->pixmap()->size());
92
93}
94
95void Gui::setTaskText(std::string letter){
96 ui->listWidget->item(2)->setText(QCoreApplication::translate("MainWindow", letter.c_str(), nullptr));
97}
98
99void Gui::SetTask(std::string newTask){
100 currentTask = newTask;
101 SetTargetImage("A");
102}
#define UI_WDH
Definition: Gui.cpp:3
#define UI_HGT
Definition: Gui.cpp:4
#define testFolder
Definition: Gui.h:16
void buttonPressed()
Definition: Gui.cpp:63
void updateThreshold()
Definition: Gui.cpp:70
void SetTargetImage(int target)
virtual void NextScene(Scene next)
Definition: Gui.cpp:24
void SetVisible(bool visible)
Definition: Gui.cpp:47
void SetTask(std::string newTask)
Definition: Gui.cpp:99
Gui(QMainWindow *win, Ui_MainWindow *ui_win)
Definition: Gui.cpp:11
void progressChanged(int progress)
void ResetProgress()
Definition: ProgressBar.cpp:17
int GetProgress(std::string s, std::string task)
Definition: ProgressBar.cpp:9
void SetThreshold(int thres)
Definition: ProgressBar.cpp:21
Struct Scene.
Definition: Scene.h:36
std::string result
Member variable.
Definition: Scene.h:47
cv::Mat frame
Member variable.
Definition: Scene.h:42