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

adapt SandboxSetup to custom the output of the beamer location routine + update qt app

parent 15b15b80
No related branches found
No related tags found
No related merge requests found
Showing
with 534 additions and 183 deletions
......@@ -32,7 +32,8 @@ SOURCES += \
maskedit.cpp \
projectiongui.cpp \
qtfullscreen.cpp \
beamerlocationgui.cpp
beamerlocationgui.cpp \
mainwindow.cpp
HEADERS += \
monitorgui.h \
......@@ -41,7 +42,8 @@ HEADERS += \
maskedit.h \
projectiongui.h \
qtfullscreen.h \
beamerlocationgui.h
beamerlocationgui.h \
mainwindow.h
FORMS += \
monitorgui.ui \
......@@ -49,7 +51,8 @@ FORMS += \
croppingmask.ui \
maskedit.ui \
projectiongui.ui \
beamerlocationgui.ui
beamerlocationgui.ui \
mainwindow.ui
......
......@@ -6,10 +6,16 @@ BeamerLocationGui::BeamerLocationGui(SandboxSetup *_setup, MonitorGui *_mg, QWid
ui(new Ui::BeamerLocationGui)
{
setup = _setup;
beamer = setup->getBeamer();
camera = setup->getCamera();
crosses = beamer->getCrossList();
mg = _mg;
QScreen *sc = mg->getScreen();
winFullScreen = new QtFullScreen(sc, true);
winFullScreen = new QtFullScreen(mg->getResolution(), true, this);
ui->setupUi(this);
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &BeamerLocationGui::routineFrame);
}
BeamerLocationGui::~BeamerLocationGui()
......@@ -17,20 +23,98 @@ BeamerLocationGui::~BeamerLocationGui()
delete ui;
}
void BeamerLocationGui::imshow(cv::Mat frame){
winFullScreen->imShow(frame);
void BeamerLocationGui::closeEvent (QCloseEvent *e){
QWidget::closeEvent(e);
endRoutine();
}
void BeamerLocationGui::keyPressEvent(QKeyEvent *e)
{
std::cout << e->text().toStdString().at(0) << std::endl;
char keyCode = (char)(e->text().toStdString().at(0));
if (keyCode == 'b'){
userValidePoint();
}
}
void BeamerLocationGui::startRoutine(){
profil = beamer->getProfil();
stepCross = 0;
directions = std::vector<cv::Point3d>();
bases = std::vector<cv::Point3d>();
capturedPoints = std::vector<cv::Point3f>();
circle = std::vector<cv::Point3i>();
if(!timer->isActive())
timer->start(500);
}
void BeamerLocationGui::findBeamer(){
if(ptrShowImage == nullptr){
std::cout << "Null Pointer, showImage method must be specified with \"setPtrShowImage\" in BeamerLocationGui" << std::endl;
exit(1);
void BeamerLocationGui::routineFrame(){
if(capturedPoints.size() < beamer->MAX_LINEAR_LINE_POINTS && (uint)stepCross < crosses.size()){
cv::Point2i cross = crosses.at(stepCross);
// capture frame
camera->captureFrame();
depth = camera->getDepthFrame();
rgb = camera->getRGBFrame();
// Look for the circle target
circle = beamer->findCercleZ(rgb, profil->getContrast(), profil->getBrightness(), profil->getRadiusRatio(), profil->getUpperMinThreshold(), profil->getLowerMinThreshold());
// Show black screen with cross
cv::Mat frameImage = beamer->getCrossFrame(cross, capturedPoints.size()+1, beamer->MAX_LINEAR_LINE_POINTS, !circle.empty());
cv::cvtColor(frameImage, frameImage, CV_BGR2RGB);
winFullScreen->imShow(frameImage);
}
}
endSuccessfully = (setup->setupBeamerLocation(ptrShowImage)==0);
void BeamerLocationGui::userValidePoint(){
if(!circle.empty()){
capturedPoints.push_back( beamer->deprojectPixel(circle.at(0), &depth, camera) );
// enough points to perform linear regression and move into next step
if(capturedPoints.size() >= beamer->MAX_LINEAR_LINE_POINTS){
beamer->findLinearLineFrom(&capturedPoints, &bases, &directions);
capturedPoints = std::vector<cv::Point3f>();
circle = std::vector<cv::Point3i>();
stepCross++;
if((uint)stepCross >= crosses.size()){
endRoutine();
}
}
}
}
void BeamerLocationGui::endRoutine(){
if(timer->isActive())
timer->stop();
endSuccessfully = (bases.size() == beamer->MAX_LINEAR_LINE_POINTS && directions.size() == beamer->MAX_LINEAR_LINE_POINTS);
if(endSuccessfully)
beamer->setPosition( (cv::Point3f)beamer->approximatePosition(&bases, &directions) );
winFullScreen->close();
}
void BeamerLocationGui::showEvent(QShowEvent *e){
QDialog::showEvent(e);
findBeamer();
void BeamerLocationGui::on_btnStart_clicked()
{
if(!isFullScreenInit){
winFullScreen->setGeometry(mg->getResolution());
}
startRoutine();
}
......@@ -2,6 +2,7 @@
#define BEAMERLOCATIONGUI_H
#include <QDialog>
#include <QTimer>
#include <opencv2/opencv.hpp>
#include "qtfullscreen.h"
#include "monitorgui.h"
......@@ -18,22 +19,41 @@ class BeamerLocationGui : public QDialog
public:
explicit BeamerLocationGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *parent = 0);
bool endedSuccessfully(){ return endSuccessfully; };
void setPtrShowImageFn(ShowImageFn ptr){ ptrShowImage = ptr; };
void imshow(cv::Mat);
~BeamerLocationGui();
protected:
void showEvent(QShowEvent *e);
void keyPressEvent(QKeyEvent *e);
void closeEvent (QCloseEvent *event);
private slots:
void on_btnStart_clicked();
private:
Ui::BeamerLocationGui *ui;
QtFullScreen *winFullScreen;
SandboxSetup *setup;
Beamer *beamer;
Camera *camera;
FrameProcessProfil *profil;
MonitorGui *mg;
bool endSuccessfully = false;
ShowImageFn ptrShowImage = nullptr;
void findBeamer();
int keypressed = -1;
bool isFullScreenInit = false;
bool isWaiting = true;
std::vector<cv::Point2i> crosses;
std::vector<cv::Point3d> directions;
std::vector<cv::Point3d> bases;
std::vector<cv::Point3f> capturedPoints;
cv::Mat depth;
cv::Mat rgb;
std::vector<cv::Point3i> circle;
int stepCross = 0;
QTimer *timer;
void startRoutine();
void routineFrame();
void userValidePoint();
void endRoutine();
};
#endif // BEAMERLOCATIONGUI_H
......@@ -13,17 +13,17 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QCheckBox" name="checkBox">
<widget class="QPushButton" name="btnStart">
<property name="geometry">
<rect>
<x>100</x>
<y>70</y>
<width>92</width>
<height>23</height>
<x>210</x>
<y>210</y>
<width>89</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>CheckBox</string>
<string>Start</string>
</property>
</widget>
</widget>
......
......@@ -41,7 +41,7 @@ void CameraFocus::refreshFrame(){
cv::Mat gray;
cv::Mat rgbFromGray;
cv::Mat rgb = setup->getCamera()->getRGBFrame();
std::vector<int> crc;
std::vector<cv::Point3i> crc;
if(profil->getUpperMinThreshold() >= profil->getLowerMinThreshold()){
......@@ -64,7 +64,7 @@ void CameraFocus::refreshFrame(){
cv::cvtColor(gray, rgbFromGray, CV_GRAY2BGR);
if(!crc.empty()){
cv::circle(rgbFromGray, cv::Point(crc[0], crc[1]), crc[2], cv::Scalar(0,255,0), 2);
cv::circle(rgbFromGray, cv::Point(crc[0].x, crc[0].y), crc[0].z, cv::Scalar(0,255,0), 2);
}
QImage img = QImage((uchar *)rgbFromGray.data, (int)rgbFromGray.cols, (int)rgbFromGray.rows, static_cast<int>(rgbFromGray.step.buf[0]), QImage::Format_RGB888);
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>635</width>
<width>653</width>
<height>611</height>
</rect>
</property>
......
......@@ -12,8 +12,7 @@ CroppingMask::CroppingMask(SandboxSetup *sandbox, MonitorGui *_mg, QWidget *pare
maskEdit = new MaskEdit(ui->frame->geometry());
ui->vLayout->addWidget(maskEdit, 1);
QScreen *sc = mg->getScreen();
projBlueScreen = new QtFullScreen(sc, true);
projBlueScreen = new QtFullScreen(mg->getResolution(), true, this);
// TODO : try to load cropping mask from file
......@@ -27,10 +26,14 @@ CroppingMask::~CroppingMask()
void CroppingMask::on_btnTakePicture_clicked()
{
// take picture of blue screen
initFullScreen();
if(!blueScreenInitilized){
blueScreenInitilized = true;
projBlueScreen->setGeometry(mg->getResolution());
}
cv::Mat blueMat = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255));
projBlueScreen->imShow(blueMat);
QTimer::singleShot(1000, this, &CroppingMask::takePicture);
maskUpdated = true;
}
void CroppingMask::takePicture(){
......@@ -50,16 +53,6 @@ void CroppingMask::takePicture(){
maskEdit->updateFrame(&cameraRGBFrame, &rectPoints);
}
void CroppingMask::initFullScreen(){
if(!blueScreenInitilized){
blueScreenInitilized = true;
QScreen *sc = mg->getScreen();
QRect res = sc->geometry();
projBlueScreen->setGeometry(res.x(), res.y(), res.width(), res.height());
}
}
bool CroppingMask::maskValideInFrame(cv::Mat *rgb){
if(rectPoints.empty())
......
......@@ -21,6 +21,7 @@ public:
explicit CroppingMask(SandboxSetup *sandbox, MonitorGui *_mg, QWidget *parent = 0);
~CroppingMask();
std::vector<cv::Point> getRectPoints(){ return rectPoints; };
bool updated(){ return maskUpdated; };
bool isOk(){ return state; };
private slots:
......@@ -37,9 +38,8 @@ private:
MonitorGui *mg;
QtFullScreen *projBlueScreen;
bool blueScreenInitilized = false;
bool maskUpdated = false;
void initFullScreen();
bool maskValideInFrame(cv::Mat *rgb);
void takePicture();
};
......
/*
#include <QApplication>
#include "mainwindow.h"
#include <sandboxSetup.h>
#include "monitorgui.h"
#include "camerafocus.h"
#include "croppingmask.h"
#include "projectiongui.h"
#include "beamerlocationgui.h"
int argc = 0;
char *argv[] = {""};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
SandboxSetup setup;
MonitorGui mg;
ProjectionGui pg(&setup, &mg);
CameraFocus cf(&setup);
CroppingMask cm(&setup, &mg);
BeamerLocationGui bl(&setup, &mg);
void beamerLocationShowImage(cv::Mat frame){
bl.imshow(frame);
}
void exit_msg(SandboxSetup *setup, std::string msg){
setup->getCamera()->stop();
std::cout << msg << std::endl;
exit(1);
}
int main(){
// Init
setup.getCamera()->start();
// Select output screen and projection's resolutions
mg.show();
app.exec();
if(!mg.isOk()){
exit_msg(&setup, "Cancel resolution");
}
setup.getBeamer()->setResolution(cv::Size(mg.getWidth(), mg.getHeight()));
// Setup camera and beamer physically
pg.show();
app.exec();
// Edit frame process profil for the setupBeamerLocation routine
cf.show();
app.exec();
if(!cf.isOk()){
exit_msg(&setup, "Cancel camera parameters");
}
// Setup the adjust matrix and cropping mask
cm.show();
app.exec();
if(!cm.isOk()){
exit_msg(&setup, "Cancel drop");
}
cv::Size s = setup.getCamera()->getDepthFrame().size();
cv::Point center(s.width / 2, s.height / 2);
std::vector<cv::Point> rectPoints = cm.getRectPoints();
setup.setupAdjustMatrix(rectPoints, center);
setup.setupCroppingMask(rectPoints);
// Setup the beamer location
bl.setPtrShowImageFn(beamerLocationShowImage);
bl.show();
app.exec();
if(!bl.endedSuccessfully()){
exit_msg(&setup, "Cancel beamer position");
}
// Save config in file
if(setup.saveConfig()){
exit_msg(&setup, "Failed to save configuration");
}
setup.getCamera()->stop();
return 0;
MainWindow main;
main.show();
return app.exec();
}
*/
#include <QApplication>
#include "monitorgui.h"
#include "camerafocus.h"
#include "croppingmask.h"
#include "projectiongui.h"
#include "qtfullscreen.h"
#include "beamerlocationgui.h"
#include <sandboxSetup.h>
//QScreen *sc = nullptr;
char wname[] = "Image";
void showImage(cv::Mat frame){
//QtFullScreen *winFullScreen = new QtFullScreen(sc, true);
//winFullScreen->imShow(frame);
cv::imshow(wname, frame);
}
void exit_msg(SandboxSetup *setup, std::string msg){
setup->getCamera()->stop();
std::cout << msg << std::endl;
......@@ -119,13 +30,14 @@ void exit_msg(SandboxSetup *setup, std::string msg){
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
SandboxSetup setup;
MonitorGui mg;
ProjectionGui pg(&setup, &mg);
CameraFocus cf(&setup);
CroppingMask cm(&setup, &mg);
BeamerLocationGui bl(&setup, &mg);
setup.getCamera()->start();
......@@ -137,7 +49,7 @@ int main(int argc, char *argv[])
exit_msg(&setup, "Cancel resolution");
}
setup.getBeamer()->setResolution(cv::Size(mg.getWidth(), mg.getHeight()));
//sc = mg.getScreen();
// Setup camera and beamer physically
pg.show();
......@@ -158,24 +70,21 @@ int main(int argc, char *argv[])
if(!cm.isOk()){
exit_msg(&setup, "Cancel drop");
}
if(cm.updated()){
cv::Size s = setup.getCamera()->getDepthFrame().size();
cv::Point center(s.width / 2, s.height / 2);
std::vector<cv::Point> rectPoints = cm.getRectPoints();
setup.setupAdjustMatrix(rectPoints, center);
setup.setupCroppingMask(rectPoints);
}
// Setup the beamer location
cv::namedWindow(wname, CV_WINDOW_NORMAL);
cv::setWindowProperty(wname, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
if(setup.setupBeamerLocation(showImage)){
bl.show();
app.exec();
if(!bl.endedSuccessfully()){
exit_msg(&setup, "Cancel beamer position");
}
cv::destroyAllWindows();
// Save config in file
if(setup.saveConfig()){
......@@ -184,5 +93,6 @@ int main(int argc, char *argv[])
setup.getCamera()->stop();
return 0;
}
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->apps->setGeometry(QRect(0, 0, 670, 630));
ui->btnPrev->setVisible(false);
ui->btnNext->setEnabled(false);
setup = new SandboxSetup;
mg = new MonitorGui(this);
pg = new ProjectionGui(setup, mg, this);
cf = new CameraFocus(setup, this);
cm = new CroppingMask(setup, mg, this);
bl = new BeamerLocationGui(setup, mg, this);
applist.push_back(mg);
applist.push_back(pg);
applist.push_back(cf);
applist.push_back(cm);
applist.push_back(bl);
/*
checkapplist.push_back(checkResolution);
checkapplist.push_back(checkProj);
checkapplist.push_back(checkProcessProfil);
checkapplist.push_back(checkCroppingMask);
checkapplist.push_back(checkBeamerLocation);
*/
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::showEvent(QShowEvent *event){
QWidget::showEvent(event);
QTimer::singleShot(0, this, &MainWindow::initCamera);
}
void MainWindow::exit_msg(std::string msg){
setup->getCamera()->stop();
std::cout << msg << std::endl;
exit(1);
}
//
// STEPS
//
void MainWindow::closeApp(){
applist.at(step)->close();
if(ui->apps->count() > 0){
ui->apps->removeWidget(applist.at(step));
}
}
void MainWindow::loadApp(){
ui->apps->addWidget(applist.at(step));
applist.at(step)->show();
}
bool MainWindow::verifyApp(){
return true;//checkapplist.at(step)();
}
void MainWindow::nextApp(){
if(verifyApp()){
closeApp();
step++;
loadApp();
}else{
exit_msg("Failed setup at step : " + step);
}
}
void MainWindow::prevApp(){
if(step > 0){
closeApp();
step--;
loadApp();
}
}
void MainWindow::initCamera(){
std::cout << "init camera" << std::endl;
setup->getCamera()->start();
std::cout << "camera ready" << std::endl;
ui->btnNext->setEnabled(true);
loadApp();
}
void MainWindow::finishConfig(){
// Save config in file
if(setup->saveConfig()){
exit_msg("Failed to save configuration");
}
setup->getCamera()->stop();
}
bool MainWindow::checkResolution(){
if(!mg->isOk()){
//exit_msg("Cancel resolution");
return false;
}
setup->getBeamer()->setResolution(cv::Size(mg->getWidth(), mg->getHeight()));
return true;
}
bool MainWindow::checkProj(){ return true; }
bool MainWindow::checkProcessProfil(){
if(!cf->isOk()){
//exit_msg("Cancel camera parameters");
return false;
}
return true;
}
bool MainWindow::checkCroppingMask(){
if(!cm->isOk()){
//exit_msg("Cancel drop");
return false;
}
if(cm->updated()){
cv::Size s = setup->getCamera()->getDepthFrame().size();
cv::Point center(s.width / 2, s.height / 2);
std::vector<cv::Point> rectPoints = cm->getRectPoints();
setup->setupAdjustMatrix(rectPoints, center);
setup->setupCroppingMask(rectPoints);
}
return true;
}
bool MainWindow::checkBeamerLocation(){
if(!bl->endedSuccessfully()){
//exit_msg("Cancel beamer position");
return false;
}
return true;
}
void MainWindow::on_btnNext_clicked()
{
if(step == 0)
ui->btnPrev->setVisible(true);
nextApp();
}
void MainWindow::on_btnPrev_clicked()
{
if(step == 0)
ui->btnPrev->setVisible(false);
prevApp();
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "monitorgui.h"
#include "camerafocus.h"
#include "croppingmask.h"
#include "projectiongui.h"
#include "qtfullscreen.h"
#include "beamerlocationgui.h"
#include <sandboxSetup.h>
#include <QTimer>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_btnNext_clicked();
void on_btnPrev_clicked();
protected:
void showEvent(QShowEvent *event);
private:
Ui::MainWindow *ui;
SandboxSetup *setup;
MonitorGui *mg;
ProjectionGui *pg;
CameraFocus *cf;
CroppingMask *cm;
BeamerLocationGui *bl;
int step = 0;
std::vector<QWidget*> applist;
std::vector<bool(MainWindow::*)()> checkapplist;
void loadApp();
void closeApp();
bool verifyApp();
void nextApp();
void prevApp();
void initCamera();
void finishConfig();
bool checkResolution();
bool checkProj();
bool checkProcessProfil();
bool checkCroppingMask();
bool checkBeamerLocation();
void exit_msg(std::string msg);
};
#endif // MAINWINDOW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>Sandbox setup</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>160</width>
<height>80</height>
</rect>
</property>
<layout class="QVBoxLayout" name="apps"/>
</widget>
<widget class="QPushButton" name="btnNext">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>650</x>
<y>530</y>
<width>89</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Next</string>
</property>
</widget>
<widget class="QPushButton" name="btnPrev">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>530</x>
<y>530</y>
<width>89</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Previous</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
......@@ -6,6 +6,7 @@ MonitorGui::MonitorGui(QWidget *parent) :
ui(new Ui::MonitorGui)
{
ui->setupUi(this);
resolution = new QRect;
std::string path = ".monitors.tmp";
monitors = std::map<std::string, std::vector<std::string>>();
......@@ -27,7 +28,7 @@ MonitorGui::~MonitorGui()
delete ui;
}
QScreen* MonitorGui::getScreen(){
QScreen* MonitorGui::getMonitor(){
QScreen *sc = QApplication::screens().at(0);
QList<QScreen *> lst = sc->virtualSiblings();
......@@ -58,6 +59,12 @@ void MonitorGui::on_btnbxMonitors_accepted()
std::vector<std::string> res = splitResolution(selectedRes.toStdString());
width = std::stoi(res[0]);
height = std::stoi(res[1]);
QScreen *sc = getMonitor();
resolution->setX(sc->geometry().x());
resolution->setY(sc->geometry().y());
resolution->setWidth(width);
resolution->setHeight(height);
}
......
......@@ -26,7 +26,7 @@ public:
int getHeight(){ return height; };
int getWidth(){ return width; };
std::string getOutput(){ return outputName.toStdString(); };
QScreen* getScreen();
QRect getResolution(){ return *resolution; }
bool isOk(){ return valideState; };
......@@ -42,8 +42,9 @@ private:
int height = 0;
int width = 0;
QString outputName = "";
QRect *resolution;
QScreen* getMonitor();
void loadResolutionsOf(QScreen* screen);
std::vector<std::string> splitResolution(std::string s);
bool isResolution(std::string s);
......
......@@ -30,10 +30,10 @@ 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 = mg->getScreen();
QRect reso = mg->getResolution();
// open blue screen on the selected output
cv::Mat blue = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255));
blueScreen = new QtFullScreen(sc, true);
blueScreen = new QtFullScreen(reso, true);
blueScreen->imShow(blue);
cameraUsed = true;
......
#include "qtfullscreen.h"
QtFullScreen::QtFullScreen(QScreen *_sc, bool isBorderless, QWidget *parent) : QWidget(parent)
QtFullScreen::QtFullScreen(QRect _resolution, bool _isBorderless, QWidget *parent) : QWidget(parent)
{
p = parent;
win = new QDialog;
screen = _sc;
win->setGeometry(screen->geometry());
if(isBorderless)
win->setWindowState(Qt::WindowFullScreen);
resolution = &_resolution;
isBorderless = _isBorderless;
win->setGeometry(*resolution);
image = new QLabel(win);
image->setGeometry(0, 0 , win->geometry().width(), win->geometry().height());
image->setScaledContents(true);
}
void QtFullScreen::showEvent(QShowEvent* event){
QWidget::showEvent( event );
if(p != nullptr)
p->setFocus();
}
void QtFullScreen::setGeometry(QRect reso){
setGeometry(reso.x(), reso.y(), reso.width(), reso.height());
}
void QtFullScreen::setGeometry(int x, int y, int w, int h){
win->setGeometry(x, y, w, h);
image->setGeometry(0 , 0, w, h);
......@@ -24,6 +36,9 @@ void QtFullScreen::imShow(cv::Mat frame){
QPixmap px = QPixmap::fromImage(src);
image->setPixmap(px);
if(isBorderless && !win->windowState().testFlag(Qt::WindowFullScreen))
win->setWindowState(Qt::WindowFullScreen);
if(!win->isVisible())
win->show();
}
......
......@@ -11,19 +11,26 @@ class QtFullScreen : public QWidget
{
Q_OBJECT
public:
explicit QtFullScreen(QScreen *sc, bool isBorderless=false, QWidget *parent = nullptr);
explicit QtFullScreen(QRect resolution, bool isBorderless=false, QWidget *parent = nullptr);
void imShow(cv::Mat frame);
void close();
void setGeometry(QRect resolution);
void setGeometry(int x, int y, int w, int h);
signals:
public slots:
protected:
void showEvent(QShowEvent* event);
private:
QDialog *win;
QLabel *image;
QScreen *screen;
QRect *resolution;
QWidget *p;
bool isBorderless = false;
};
#endif // QTFULLSCREEN_H
......@@ -3,9 +3,6 @@
#include <opencv2/opencv.hpp>
#include "camera.h"
#define ESCAPE_CHAR 27
typedef void (*ShowImageFn)(cv::Mat);
class FrameProcessProfil{
private:
......@@ -46,11 +43,14 @@ class Beamer{
FrameProcessProfil profil = FrameProcessProfil();
cv::Point3f intersection(cv::Vec3f v1, cv::Point3f p1, cv::Vec3f v2, cv::Point3f p2, cv::Vec3f v3, cv::Point3f p3, bool &isFound);
cv::Point3d approximatePosition(std::vector<cv::Point3d> points1, std::vector<cv::Point3d> points2);
public:
Beamer();
const char ESCAPE_CHAR = 27;
const unsigned int MAX_LINEAR_LINE_POINTS = 3; //number of point to calculate 1 vector
const double LINEAR_REGRESSION_FACT = -20.0; // used for linear regression
cv::Point3f getPosition(){ return beamerPosition; };
void setPosition(cv::Point3f pos){ beamerPosition = pos; };
......@@ -66,9 +66,14 @@ class Beamer{
FrameProcessProfil* getProfil(){ return &profil; };
void setProfil(FrameProcessProfil p){ profil = p; };
int findBeamerFrom(Camera camera, void (*showImage)(cv::Mat));
int findBeamerFrom(Camera *camera);
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);
cv::Point3f deprojectPixel(cv::Point3i circle, cv::Mat *depth, Camera *camera);
std::vector<cv::Point2i> getCrossList();
cv::Mat getCrossFrame(cv::Point2i projectedCross, int step, int max, bool circlesFound);
cv::Point3d approximatePosition(std::vector<cv::Point3d> *bases, std::vector<cv::Point3d> *directions);
void findLinearLineFrom(std::vector<cv::Point3f> *capturedPoints, std::vector<cv::Point3d> *bases, std::vector<cv::Point3d> *directions);
std::vector<cv::Point3i> findCercleZ(cv::Mat &rgb, double contrast, int brightness, int ratioRadius, int upperMinThreshold, int lowerMinThreshold);
void printPosition();
};
......
......@@ -3,8 +3,6 @@
#include <opencv2/opencv.hpp>
#define ESCAPE_CHAR 27
class BorderEdit{
private:
static const int margeClick = 10;
......@@ -15,6 +13,7 @@ class BorderEdit{
static void drawSquare(cv::Point *p, int n);
static int findPoints(int x, int y, std::vector<cv::Point> &posSandbox);
static void mouseHandler(int event, int x, int y, int, void *param);
static const char ESCAPE_CHAR = 27;
public:
static int edit(cv::Mat frame, std::vector<cv::Point> *posSandbox);
......
......@@ -33,12 +33,13 @@ class SandboxSetup{
int loadFrameProcessProfil();
// edit variables of config => not persistant
void captureBlueScreen(int delay);
void setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Point center);
void setupCroppingMask(std::vector<cv::Point> rectPoints);
int setupProjection();
int setupBeamerResolution();
int setupBeamerLocation(void (*showImage)(cv::Mat));
void defaultCaptureBlueScreen(int delay);
int defaultSetupProjection();
int defaultSetupBeamerResolution();
int defaultSetupBeamerLocation();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment