diff --git a/app/SandboxSetup/SandboxSetup.pro b/app/SandboxSetup/SandboxSetup.pro index 05ce6410ae113f6510f52873a8ab01c758c2a0ff..7706c051720102cc884c63e18978972053f17cc0 100644 --- a/app/SandboxSetup/SandboxSetup.pro +++ b/app/SandboxSetup/SandboxSetup.pro @@ -30,14 +30,16 @@ SOURCES += \ camerafocus.cpp \ croppingmask.cpp \ maskedit.cpp \ - projectiongui.cpp + projectiongui.cpp \ + qtfullscreen.cpp HEADERS += \ monitorgui.h \ camerafocus.h \ croppingmask.h \ maskedit.h \ - projectiongui.h + projectiongui.h \ + qtfullscreen.h FORMS += \ monitorgui.ui \ diff --git a/app/SandboxSetup/monitorgui.cpp b/app/SandboxSetup/monitorgui.cpp index 32a82c016326b17a9c6d3e96fd75652a7b0c6f90..51ccf34e81c970a588bec1706990492e0c88af49 100644 --- a/app/SandboxSetup/monitorgui.cpp +++ b/app/SandboxSetup/monitorgui.cpp @@ -27,6 +27,23 @@ MonitorGui::~MonitorGui() delete ui; } +QScreen* MonitorGui::getScreen(){ + + QScreen *sc = QApplication::screens().at(0); + QList<QScreen *> lst = sc->virtualSiblings(); + + + for(int i=0; i<lst.size(); i++){ + std::string name = lst[i]->name().toStdString(); + if(name == outputName.toStdString()){ + sc = lst.at(i); + break; + } + } + + return sc; +} + void MonitorGui::on_cbxOutputs_currentIndexChanged(int index) { QList<QScreen*> screens = QApplication::screens(); diff --git a/app/SandboxSetup/monitorgui.h b/app/SandboxSetup/monitorgui.h index 10d39f2a1fddd3d196b72e85133e4a073a19877f..6b1b40763995f7b939a5e094ba1c80e985d97b87 100644 --- a/app/SandboxSetup/monitorgui.h +++ b/app/SandboxSetup/monitorgui.h @@ -9,6 +9,7 @@ #include <fstream> #include <map> #include <iostream> +#include <QScreen> namespace Ui { class MonitorGui; @@ -25,6 +26,8 @@ public: int getHeight(){ return height; }; int getWidth(){ return width; }; std::string getOutput(){ return outputName.toStdString(); }; + QScreen* getScreen(); + bool isOk(){ return valideState; }; private slots: @@ -33,11 +36,14 @@ private slots: private: Ui::MonitorGui *ui; + bool valideState = false; + std::map<std::string, std::vector<std::string>> monitors; + int height = 0; int width = 0; QString outputName = ""; - bool valideState = false; - std::map<std::string, std::vector<std::string>> monitors; + + void loadResolutionsOf(QScreen* screen); std::vector<std::string> splitResolution(std::string s); bool isResolution(std::string s); diff --git a/app/SandboxSetup/projectiongui.cpp b/app/SandboxSetup/projectiongui.cpp index 4a0a3538e2d796839afe52f5ec03d8873ccbe412..fab18ea5c67e0a8a8f7f06b79b72e893f3f35fee 100644 --- a/app/SandboxSetup/projectiongui.cpp +++ b/app/SandboxSetup/projectiongui.cpp @@ -5,7 +5,6 @@ ProjectionGui::ProjectionGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *par QDialog(parent), ui(new Ui::ProjectionGui) { - blueScreen = new QDialog; setup = _setup; mg = _mg; ui->setupUi(this); @@ -31,25 +30,15 @@ void ProjectionGui::on_btnSkip_clicked() // Note : Screens should be in extented mode, not mirror (to avoid loop noise from the capture of the screen) void ProjectionGui::on_btnStart_clicked() { - QScreen *sc = QApplication::screens().at(0); - QList<QScreen *> lst = sc->virtualSiblings(); - - for(int i=0; i<lst.size(); i++){ - std::string name = lst[i]->name().toStdString(); - if(name == mg->getOutput()){ - sc = lst[i]; - break; - } - } - + QScreen *sc = mg->getScreen(); // open blue screen on the selected output - blueScreen->setGeometry(sc->geometry()); - blueScreen->setStyleSheet("background-color:blue;"); - blueScreen->show(); + cv::Mat blue = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255)); + blueScreen = new QtFullScreen(sc); + blueScreen->imShow(blue); + cameraUsed = true; ui->fContainer->hide(); frameTimer->start(100); - cameraUsed = true; } void ProjectionGui::refreshFrame(){ diff --git a/app/SandboxSetup/projectiongui.h b/app/SandboxSetup/projectiongui.h index 4dcdeaa953228502812a4f440fe1264ddc48555c..de29078f3c8ea62e9dd7f19ee0952fdadb7060eb 100644 --- a/app/SandboxSetup/projectiongui.h +++ b/app/SandboxSetup/projectiongui.h @@ -4,6 +4,7 @@ #include <QDialog> #include <sandboxSetup.h> #include "monitorgui.h" +#include "qtfullscreen.h" namespace Ui { class ProjectionGui; @@ -27,7 +28,7 @@ private: SandboxSetup *setup; MonitorGui *mg; QTimer *frameTimer; - QDialog *blueScreen; + QtFullScreen *blueScreen; bool cameraUsed = false; void refreshFrame(); diff --git a/app/SandboxSetup/qtfullscreen.cpp b/app/SandboxSetup/qtfullscreen.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2fc2ee532844b12526662921eef8948abd86abb8 --- /dev/null +++ b/app/SandboxSetup/qtfullscreen.cpp @@ -0,0 +1,26 @@ +#include "qtfullscreen.h" + +QtFullScreen::QtFullScreen(QScreen *_sc, QWidget *parent) : QWidget(parent) +{ + win = new QDialog; + screen = _sc; + win->setGeometry(screen->geometry()); + image = new QLabel(win); + image->setGeometry(0, 0 , win->geometry().width(), win->geometry().height()); + image->setScaledContents(true); +} + +void QtFullScreen::imShow(cv::Mat frame){ + + QImage src = QImage((uchar *)frame.data, (int)frame.cols, (int)frame.rows, static_cast<int>(frame.step.buf[0]), QImage::Format_RGB888); + QPixmap px = QPixmap::fromImage(src); + image->setPixmap(px); + + if(!win->isVisible()) + win->show(); +} + +void QtFullScreen::close(){ + if(win->isVisible()) + win->close(); +} diff --git a/app/SandboxSetup/qtfullscreen.h b/app/SandboxSetup/qtfullscreen.h new file mode 100644 index 0000000000000000000000000000000000000000..a0e15a5e3beaeedad360667c76eec19ea38b9df9 --- /dev/null +++ b/app/SandboxSetup/qtfullscreen.h @@ -0,0 +1,28 @@ +#ifndef QTFULLSCREEN_H +#define QTFULLSCREEN_H + +#include <opencv2/opencv.hpp> +#include <QWidget> +#include <QLabel> +#include <QScreen> +#include <QDialog> + +class QtFullScreen : public QWidget +{ + Q_OBJECT +public: + explicit QtFullScreen(QScreen *sc, QWidget *parent = nullptr); + void imShow(cv::Mat frame); + void close(); + +signals: + +public slots: + +private: + QDialog *win; + QLabel *image; + QScreen *screen; +}; + +#endif // QTFULLSCREEN_H diff --git a/src/lib/sandboxSetup.cpp b/src/lib/sandboxSetup.cpp index a43f50389bf583d08a7fc54bbfb8414b9422ecdf..ed72f4cb94432887ccab6fc3973e43621abc6e75 100644 --- a/src/lib/sandboxSetup.cpp +++ b/src/lib/sandboxSetup.cpp @@ -102,7 +102,7 @@ int SandboxSetup::setupProjection(){ void SandboxSetup::captureBlueScreen(int delay){ // Blue screen - char windowName[] = "border"; + char windowName[] = "BlueScreen"; initWindowsFullScreen(windowName); cv::Mat frameBeamer(cv::Size(beamer.getWidth(), beamer.getHeight()), CV_8UC3, cv::Scalar(255, 0, 0)); cv::imshow(windowName, frameBeamer);