Skip to content
Snippets Groups Projects
Commit 96249467 authored by Fabien Mottier's avatar Fabien Mottier
Browse files

set al all configuration, but problem to save configuration

parent a0b95b71
Branches
No related tags found
No related merge requests found
Showing
with 71 additions and 28 deletions
...@@ -19,10 +19,9 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -19,10 +19,9 @@ MainWindow::MainWindow(QWidget *parent)
parent->connect(ui->btnReload, SIGNAL (released()),this, SLOT(reloadListRealSenseDevices())); parent->connect(ui->btnReload, SIGNAL (released()),this, SLOT(reloadListRealSenseDevices()));
parent->connect(ui->btnSave, SIGNAL (released()),this, SLOT(saveConfiguration())); parent->connect(ui->btnSave, SIGNAL (released()),this, SLOT(saveConfiguration()));
parent->connect(ui->btnConfig, SIGNAL (released()),this, SLOT(configure())); parent->connect(ui->btnConfig, SIGNAL (released()),this, SLOT(configure()));
//parent->connect(ui->lblImage, SIGNAL (mousePressed()),this, SLOT(selectEdgeBorder()));
parent->connect(ui->lblImage, SIGNAL (mousePos()),this, SLOT(moveEdgeBorder())); parent->connect(ui->lblImage, SIGNAL (mousePos()),this, SLOT(moveEdgeBorder()));
parent->connect(ui->lblImage, SIGNAL (mouseLeft()),this, SLOT(deselectEdgeBorder())); parent->connect(ui->lblImage, SIGNAL (mouseLeft()),this, SLOT(deselectEdgeBorder()));
//parent->connect(ui->MainWindow, SIGNAL (mousePressEvent(QMouseEvent*)),this, SLOT(test(QMouseEvent*)));
// init cursor for console // init cursor for console
pteConsole_cursor = QTextCursor(ui->pteConsole->document()); pteConsole_cursor = QTextCursor(ui->pteConsole->document());
pteConsole_cursor.movePosition(QTextCursor::End); pteConsole_cursor.movePosition(QTextCursor::End);
...@@ -36,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -36,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent)
*/ */
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
sandbox.stopCamera();
delete ui; delete ui;
} }
...@@ -111,47 +111,82 @@ void MainWindow::saveConfiguration() { ...@@ -111,47 +111,82 @@ void MainWindow::saveConfiguration() {
sandbox.serialize(out); sandbox.serialize(out);
pteConsole_cursor.insertText("Serialized\n"); pteConsole_cursor.insertText("Serialized\n");
out.close(); out.close();
ifstream in("./device");
pteConsole_cursor.insertText("Deserialize\n");
sandbox.deserialize(in);
pteConsole_cursor.insertText("Deserialized\n");
out.close();
} }
/*! /*!
* \brief MainWindow::configure * \brief MainWindow::configure
* Launch the process to configure the matrix * Launch the process to configure the matrix
*/ */
void MainWindow::configure() { void MainWindow::configure() {
Mat coloredFrame = sandbox.generateBorder(); switch (stepConfiguration) {
ui->lblImage->setPixmap(QPixmap::fromImage(QImage(coloredFrame.data, coloredFrame.cols, coloredFrame.rows, coloredFrame.step, QImage::Format_RGB888))); case 0: // Edit the border
pteConsole_cursor.insertText("Ready to init\n"); {
borderEdition = true; Mat coloredFrame = sandbox.generateBorder();
} ui->lblImage->setPixmap(QPixmap::fromImage(QImage(coloredFrame.data, coloredFrame.cols, coloredFrame.rows, coloredFrame.step, QImage::Format_RGB888)));
pteConsole_cursor.insertText("Ready to init\n");
void MainWindow::selectEdgeBorder() ui->btnConfig->setText("Generate matrix");
{ stepConfiguration = 1;
if (borderEdition) { break;
selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y); }
case 1: // Valid the border for the matrix deformation and start beamer detection
{
sandbox.applyBorder();
ui->btnConfig->setText("Capture Point");
Mat frameDetection;
stepConfiguration = 2;
do {
tie(frameDetection, crcToDetectBeamer) = sandbox.detectPointToDetectBeamer(indexPointToDetectBeamer);
ui->lblImage->setPixmap(QPixmap::fromImage(QImage(frameDetection.data, frameDetection.cols, frameDetection.rows, frameDetection.step, QImage::Format_RGB888)));
waitKey(500);
} while(indexPointToDetectBeamer < 3);
ui->lblImage->setPixmap(QPixmap());
stepConfiguration = 3;
break;
}
case 2:
{
if (!crcToDetectBeamer.empty())
{
sandbox.capturePointToDetectBeamer(crcToDetectBeamer);
indexPointToDetectBeamer++;
pteConsole_cursor.insertText("add element\n");
}
}
default:
break;
} }
} }
/*!
* \brief MainWindow::moveEdgeBorder
* mouseMoveEvent when the mouse is pressed on the label
* selected the edge of border the nearest of the mouse
*/
void MainWindow::moveEdgeBorder() { void MainWindow::moveEdgeBorder() {
pteConsole_cursor.insertText(QString::number(ui->lblImage->x));
pteConsole_cursor.insertText(" "); if (stepConfiguration == 1) {
pteConsole_cursor.insertText(QString::number(ui->lblImage->y));
pteConsole_cursor.insertText("\n");
if (borderEdition) {
if (selectedPoint == -1) { if (selectedPoint == -1) {
selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y); selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y);
//pteConsole_cursor.insertText(QString::number(selectedPoint));
//pteConsole_cursor.insertText("\n");
} else { } else {
pteConsole_cursor.insertText(QString::number(selectedPoint));
pteConsole_cursor.insertText("\n");
Mat coloredFrame = sandbox.editEdgeBorder(selectedPoint,ui->lblImage->x, ui->lblImage->y); Mat coloredFrame = sandbox.editEdgeBorder(selectedPoint,ui->lblImage->x, ui->lblImage->y);
ui->lblImage->setPixmap(QPixmap::fromImage(QImage(coloredFrame.data, coloredFrame.cols, coloredFrame.rows, coloredFrame.step, QImage::Format_RGB888))); ui->lblImage->setPixmap(QPixmap::fromImage(QImage(coloredFrame.data, coloredFrame.cols, coloredFrame.rows, coloredFrame.step, QImage::Format_RGB888)));
} }
} }
} }
/*!
* \brief MainWindow::deselectEdgeBorder
* mouseReleaseEvent which deselect the edge of the border
*/
void MainWindow::deselectEdgeBorder() { void MainWindow::deselectEdgeBorder() {
if (borderEdition) { if (stepConfiguration == 1) {
selectedPoint = -1; selectedPoint = -1;
} }
} }
...@@ -35,7 +35,9 @@ private: ...@@ -35,7 +35,9 @@ private:
device_list listRealSenseDevices; device_list listRealSenseDevices;
Sandbox sandbox; Sandbox sandbox;
int selectedPoint = -1; int selectedPoint = -1;
bool borderEdition = false; int stepConfiguration = 0;
vector<int> crcToDetectBeamer;
int indexPointToDetectBeamer = 0;
// Methods // Methods
void showListRealSenseDevices(); void showListRealSenseDevices();
...@@ -47,7 +49,6 @@ private slots: ...@@ -47,7 +49,6 @@ private slots:
void reloadListRealSenseDevices(); void reloadListRealSenseDevices();
void saveConfiguration(); void saveConfiguration();
void configure(); void configure();
void selectEdgeBorder();
void moveEdgeBorder(); void moveEdgeBorder();
void deselectEdgeBorder(); void deselectEdgeBorder();
}; };
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1920</width> <width>1920</width>
<height>445</height> <height>800</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -103,13 +103,13 @@ ...@@ -103,13 +103,13 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="ReactiveLabel" name="lblImage"> <widget class="ReactiveLabel" name="lblImage" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">border-color: rgb(46, 52, 54); <string notr="true">border-color: rgb(46, 52, 54);
border-width: 1px; border-width: 1px;
border-style: solid;</string> border-style: solid;</string>
</property> </property>
<property name="text"> <property name="text" stdset="0">
<string/> <string/>
</property> </property>
</widget> </widget>
...@@ -209,6 +209,13 @@ border-style: solid;</string> ...@@ -209,6 +209,13 @@ border-style: solid;</string>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<customwidgets>
<customwidget>
<class>ReactiveLabel</class>
<extends>QWidget</extends>
<header>reactivelabel.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment