Skip to content
Snippets Groups Projects
Commit f5852d1a authored by simon.fanetti's avatar simon.fanetti
Browse files

add step to setup beamer and camera physically + setable output function in findBeamer routine

parent 06f1e4d7
No related branches found
No related tags found
No related merge requests found
......@@ -29,19 +29,22 @@ SOURCES += \
monitorgui.cpp \
camerafocus.cpp \
croppingmask.cpp \
maskedit.cpp
maskedit.cpp \
projectiongui.cpp
HEADERS += \
monitorgui.h \
camerafocus.h \
croppingmask.h \
maskedit.h
maskedit.h \
projectiongui.h
FORMS += \
monitorgui.ui \
camerafocus.ui \
croppingmask.ui \
maskedit.ui
maskedit.ui \
projectiongui.ui
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Focus</string>
</property>
<widget class="QDialogButtonBox" name="btnbxValidate">
<property name="geometry">
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Crop</string>
</property>
<widget class="QDialogButtonBox" name="btnbxEnd">
<property name="enabled">
......@@ -76,9 +76,26 @@
</layout>
</widget>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>350</y>
<width>441</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Note : Set your screens in mirror mode</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<zorder>frame</zorder>
<zorder>btnbxEnd</zorder>
<zorder>btnTakePicture</zorder>
<zorder>label</zorder>
</widget>
<resources/>
<connections>
......
#include <QApplication>
#include "monitorgui.h"
#include "camerafocus.h"
#include "croppingmask.h"
#include <QApplication>
#include "projectiongui.h"
#include <sandboxSetup.h>
char wname[] = "FindBeamer";
void showImage(cv::Mat frame){
cv::imshow(wname, frame);
}
int main(int argc, char *argv[])
{
......@@ -23,6 +31,12 @@ int main(int argc, char *argv[])
setup.setBeamerResolution(cv::Size(mg.getWidth(), mg.getHeight()));
// Setup camera and beamer physically
ProjectionGui pg(&setup, &mg);
pg.show();
app.exec();
// Edit frame process profil for the setupBeamerLocation routine
CameraFocus cf(&setup);
cf.show();
......@@ -51,10 +65,14 @@ int main(int argc, char *argv[])
// Setup the beamer location
if(setup.setupBeamerLocation()){
cv::namedWindow(wname, CV_WINDOW_NORMAL);
cv::setWindowProperty(wname, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
if(setup.setupBeamerLocation(showImage)){
std::cout << "Cancel beamer position" << std::endl;
return 1;
}
cv::destroyAllWindows();
// Save config in file
......
......@@ -37,6 +37,7 @@ void MonitorGui::on_btnbxMonitors_accepted()
{
valideState = true;
QString selectedRes = ui->cbxResolutions->currentText();
outputName = ui->cbxOutputs->currentText();
std::vector<std::string> res = splitResolution(selectedRes.toStdString());
width = std::stoi(res[0]);
height = std::stoi(res[1]);
......
......@@ -24,6 +24,7 @@ public:
int getHeight(){ return height; };
int getWidth(){ return width; };
std::string getOutput(){ return outputName.toStdString(); };
bool isOk(){ return valideState; };
private slots:
......@@ -34,6 +35,7 @@ private:
Ui::MonitorGui *ui;
int height = 0;
int width = 0;
QString outputName = "";
bool valideState = false;
std::map<std::string, std::vector<std::string>> monitors;
void loadResolutionsOf(QScreen* screen);
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Screen</string>
</property>
<widget class="QDialogButtonBox" name="btnbxMonitors">
<property name="geometry">
......
#include "projectiongui.h"
#include "ui_projectiongui.h"
ProjectionGui::ProjectionGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *parent) :
QDialog(parent),
ui(new Ui::ProjectionGui)
{
blueScreen = new QDialog;
setup = _setup;
mg = _mg;
ui->setupUi(this);
frameTimer = new QTimer(this);
connect(frameTimer, &QTimer::timeout, this, &ProjectionGui::refreshFrame);
}
ProjectionGui::~ProjectionGui()
{
delete ui;
}
void ProjectionGui::on_btnSkip_clicked()
{
if(cameraUsed){
frameTimer->stop();
setup->camera.stop();
blueScreen->close();
}
close();
}
// 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;
}
}
// open blue screen on the selected output
blueScreen->setGeometry(sc->geometry());
blueScreen->setStyleSheet("background-color:blue;");
blueScreen->show();
setup->camera.start();
ui->fContainer->hide();
frameTimer->start(100);
cameraUsed = true;
}
void ProjectionGui::refreshFrame(){
setup->camera.captureFrame();
cv::Mat rgb = setup->camera.getRGBFrame();
QImage img = QImage((uchar *)rgb.data, (int)rgb.cols, (int)rgb.rows, static_cast<int>(rgb.step.buf[0]), QImage::Format_RGB888);
QPixmap image = QPixmap::fromImage(img);
ui->lblFrame->setPixmap(image);
}
#ifndef PROJECTIONGUI_H
#define PROJECTIONGUI_H
#include <QDialog>
#include <sandboxSetup.h>
#include "monitorgui.h"
namespace Ui {
class ProjectionGui;
}
class ProjectionGui : public QDialog
{
Q_OBJECT
public:
explicit ProjectionGui(SandboxSetup *setup, MonitorGui *mg, QWidget *parent = 0);
~ProjectionGui();
private slots:
void on_btnSkip_clicked();
void on_btnStart_clicked();
private:
Ui::ProjectionGui *ui;
SandboxSetup *setup;
MonitorGui *mg;
QTimer *frameTimer;
QDialog *blueScreen;
bool cameraUsed = false;
void refreshFrame();
};
#endif // PROJECTIONGUI_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectionGui</class>
<widget class="QDialog" name="ProjectionGui">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>524</width>
<height>406</height>
</rect>
</property>
<property name="windowTitle">
<string>Setup</string>
</property>
<widget class="QFrame" name="fContainer">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>441</width>
<height>281</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QPushButton" name="btnStart">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>180</x>
<y>160</y>
<width>89</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>70</y>
<width>361</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string>Project a blue screen on the previously selected output to setup your beamer</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QPushButton" name="btnSkip">
<property name="geometry">
<rect>
<x>390</x>
<y>350</y>
<width>89</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Next</string>
</property>
</widget>
<widget class="QLabel" name="lblFrame">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>441</width>
<height>281</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>340</y>
<width>331</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Note : Setup your screens in extended mode</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<zorder>lblFrame</zorder>
<zorder>fContainer</zorder>
<zorder>btnSkip</zorder>
<zorder>label_2</zorder>
</widget>
<resources/>
<connections/>
</ui>
......@@ -59,7 +59,7 @@ class Beamer{
FrameProcessProfil* getProfil(){ return &profil; };
void setProfil(FrameProcessProfil p){ profil = p; };
int findBeamerFrom(Camera camera);
int findBeamerFrom(Camera camera, void (*showImage)(cv::Mat));
cv::Mat editContrast(cv::Mat image, double contrast, int brightness);
std::vector<int> findCercleZ(cv::Mat &rgb, double contrast, int brightness, int ratioRadius, int upperMinThreshold, int lowerMinThreshold);
void printPosition();
......
......@@ -33,7 +33,7 @@ class SandboxSetup{
void setupCroppingMask(std::vector<cv::Point> rectPoints);
int setupProjection();
int setupBeamerResolution();
int setupBeamerLocation();
int setupBeamerLocation(void (*showImage)(cv::Mat));
int loadFrameProcessProfil();
void setBeamerResolution(cv::Size resolution);
......
......@@ -13,11 +13,8 @@ Beamer::Beamer(){
*/
int Beamer::findBeamerFrom(Camera camera)
int Beamer::findBeamerFrom(Camera camera, void (*showImage)(cv::Mat))
{
char wname[] = "FindBeamer";
cv::namedWindow(wname, CV_WINDOW_NORMAL);
cv::setWindowProperty(wname, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
cv::Mat depth;
cv::Mat rgb;
cv::Mat frameImage(resolution, CV_8UC3, cv::Scalar(0, 0, 0));
......@@ -61,7 +58,7 @@ int Beamer::findBeamerFrom(Camera camera)
cv::FONT_HERSHEY_SIMPLEX,
1,
cv::Scalar(255, 255, 255));
cv::imshow(wname, frameImage);
showImage(frameImage);
// Wait for interaction
char keyCode = cv::waitKey(500);
......@@ -87,8 +84,6 @@ int Beamer::findBeamerFrom(Camera camera)
}
camera.stop();
cv::destroyAllWindows();
cv::Point3d beamerPoint = approximatePosition(directions, bases);
......
......@@ -88,8 +88,9 @@ int SandboxSetup::setupBeamerResolution(){
// return 1 when user exits process
int SandboxSetup::setupBeamerLocation(){
return beamer.findBeamerFrom(camera);
int SandboxSetup::setupBeamerLocation(void (*showImage)(cv::Mat)){
return beamer.findBeamerFrom(camera, showImage);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment