diff --git a/Calibration/Calibration.pro b/Calibration/Calibration.pro index 7119b9d68c1bb5e470f291b8de40d6282b5179b9..4e8414dbd50743acc46589dc3ddfe60ea8d6e92c 100644 --- a/Calibration/Calibration.pro +++ b/Calibration/Calibration.pro @@ -17,11 +17,13 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + reactivelabel.cpp HEADERS += \ ../sandbox/sandbox.h \ - mainwindow.h + mainwindow.h \ + reactivelabel.h FORMS += \ mainwindow.ui diff --git a/Calibration/mainwindow.cpp b/Calibration/mainwindow.cpp index d7f3792eb042bf316e514ce1961922df39fc4494..a2ba4dfd3568bb9dcfcf1a0a0ed16fa618348610 100644 --- a/Calibration/mainwindow.cpp +++ b/Calibration/mainwindow.cpp @@ -19,7 +19,10 @@ MainWindow::MainWindow(QWidget *parent) parent->connect(ui->btnReload, SIGNAL (released()),this, SLOT(reloadListRealSenseDevices())); parent->connect(ui->btnSave, SIGNAL (released()),this, SLOT(saveConfiguration())); 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 (mouseLeft()),this, SLOT(deselectEdgeBorder())); + //parent->connect(ui->MainWindow, SIGNAL (mousePressEvent(QMouseEvent*)),this, SLOT(test(QMouseEvent*))); // init cursor for console pteConsole_cursor = QTextCursor(ui->pteConsole->document()); pteConsole_cursor.movePosition(QTextCursor::End); @@ -115,5 +118,40 @@ void MainWindow::saveConfiguration() { * Launch the process to configure the matrix */ void MainWindow::configure() { - sandbox.configure(ui->lblImage); + 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"); + borderEdition = true; +} + +void MainWindow::selectEdgeBorder() +{ + if (borderEdition) { + selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y); + } +} + +void MainWindow::moveEdgeBorder() { + pteConsole_cursor.insertText(QString::number(ui->lblImage->x)); + pteConsole_cursor.insertText(" "); + pteConsole_cursor.insertText(QString::number(ui->lblImage->y)); + pteConsole_cursor.insertText("\n"); + if (borderEdition) { + if (selectedPoint == -1) { + selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y); + //pteConsole_cursor.insertText(QString::number(selectedPoint)); + //pteConsole_cursor.insertText("\n"); + } else { + pteConsole_cursor.insertText(QString::number(selectedPoint)); + pteConsole_cursor.insertText("\n"); + 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))); + } + } +} + +void MainWindow::deselectEdgeBorder() { + if (borderEdition) { + selectedPoint = -1; + } } diff --git a/Calibration/mainwindow.h b/Calibration/mainwindow.h index 7b07b62846cfc00a4920f1d63d809c405694bdf4..8b4c2e6e0ea253be50a78b56a14f60713eb1eeb9 100644 --- a/Calibration/mainwindow.h +++ b/Calibration/mainwindow.h @@ -10,6 +10,7 @@ #include "sandbox.h" #include <string> #include <iostream> +#include "reactivelabel.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -33,6 +34,8 @@ private: context ctx; device_list listRealSenseDevices; Sandbox sandbox; + int selectedPoint = -1; + bool borderEdition = false; // Methods void showListRealSenseDevices(); @@ -44,5 +47,8 @@ private slots: void reloadListRealSenseDevices(); void saveConfiguration(); void configure(); + void selectEdgeBorder(); + void moveEdgeBorder(); + void deselectEdgeBorder(); }; #endif // MAINWINDOW_H diff --git a/Calibration/mainwindow.ui b/Calibration/mainwindow.ui index f006226544dfebf32e3061f123216240790c8939..fd1257837cf5afa779cb060a5d0298db1acc2582 100644 --- a/Calibration/mainwindow.ui +++ b/Calibration/mainwindow.ui @@ -103,13 +103,7 @@ </spacer> </item> <item> - <widget class="QLabel" name="lblImage"> - <property name="minimumSize"> - <size> - <width>1400</width> - <height>1050</height> - </size> - </property> + <widget class="ReactiveLabel" name="lblImage"> <property name="styleSheet"> <string notr="true">border-color: rgb(46, 52, 54); border-width: 1px; @@ -137,19 +131,19 @@ border-style: solid;</string> </item> <item> <layout class="QVBoxLayout" name="layoutRight"> - <item> - <spacer name="topRightSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> + <item> + <spacer name="topRightSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> <item> <widget class="QLabel" name="lblConsole"> <property name="text"> diff --git a/Calibration/reactivelabel.cpp b/Calibration/reactivelabel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f38abca3d199a086b8c7f0ec89d7336a98f0ef0f --- /dev/null +++ b/Calibration/reactivelabel.cpp @@ -0,0 +1,21 @@ +#include "reactivelabel.h" + +ReactiveLabel::ReactiveLabel(QWidget *parent) : QLabel(parent) +{ + +} + +void ReactiveLabel::mouseMoveEvent(QMouseEvent *ev){ + this->x = ev->x(); + this->y = ev->y(); + + emit mousePos(); +} + +void ReactiveLabel::mousePressEvent(QMouseEvent *){ + emit mousePressed(); +} + +void ReactiveLabel::mouseReleaseEvent(QMouseEvent *){ + emit mouseLeft(); +} diff --git a/Calibration/reactivelabel.h b/Calibration/reactivelabel.h new file mode 100644 index 0000000000000000000000000000000000000000..68f64d09a4b6da2800bb7f1354cd13f526370af3 --- /dev/null +++ b/Calibration/reactivelabel.h @@ -0,0 +1,25 @@ +#ifndef REACTIVELABEL_H +#define REACTIVELABEL_H + +#include <QLabel> +#include <QMouseEvent> + +class ReactiveLabel : public QLabel +{ + Q_OBJECT +public: + explicit ReactiveLabel(QWidget *parent = 0); + + void mouseMoveEvent(QMouseEvent *ev); + void mousePressEvent(QMouseEvent *ev); + void mouseReleaseEvent(QMouseEvent *ev); + + int x, y = 0; + +signals: + void mousePressed(); + void mousePos(); + void mouseLeft(); +}; + +#endif // REACTIVELABEL_H diff --git a/build-Calibration-Desktop-Debug/2020-04-09-13_20_15.log b/build-Calibration-Desktop-Debug/2020-04-09-13_20_15.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-09-13_26_24.log b/build-Calibration-Desktop-Debug/2020-04-09-13_26_24.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-10-09_43_03.log b/build-Calibration-Desktop-Debug/2020-04-10-09_43_03.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-10-09_44_48.log b/build-Calibration-Desktop-Debug/2020-04-10-09_44_48.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-10-09_47_36.log b/build-Calibration-Desktop-Debug/2020-04-10-09_47_36.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-10-09_50_46.log b/build-Calibration-Desktop-Debug/2020-04-10-09_50_46.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-10-10_09_24.log b/build-Calibration-Desktop-Debug/2020-04-10-10_09_24.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-09_29_15.log b/build-Calibration-Desktop-Debug/2020-04-21-09_29_15.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-09_36_00.log b/build-Calibration-Desktop-Debug/2020-04-21-09_36_00.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-09_57_14.log b/build-Calibration-Desktop-Debug/2020-04-21-09_57_14.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_11_01.log b/build-Calibration-Desktop-Debug/2020-04-21-10_11_01.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_15_38.log b/build-Calibration-Desktop-Debug/2020-04-21-10_15_38.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_21_26.log b/build-Calibration-Desktop-Debug/2020-04-21-10_21_26.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_22_01.log b/build-Calibration-Desktop-Debug/2020-04-21-10_22_01.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_26_06.log b/build-Calibration-Desktop-Debug/2020-04-21-10_26_06.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_26_44.log b/build-Calibration-Desktop-Debug/2020-04-21-10_26_44.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_34_44.log b/build-Calibration-Desktop-Debug/2020-04-21-10_34_44.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_35_41.log b/build-Calibration-Desktop-Debug/2020-04-21-10_35_41.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_37_29.log b/build-Calibration-Desktop-Debug/2020-04-21-10_37_29.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_38_06.log b/build-Calibration-Desktop-Debug/2020-04-21-10_38_06.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_43_38.log b/build-Calibration-Desktop-Debug/2020-04-21-10_43_38.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_49_33.log b/build-Calibration-Desktop-Debug/2020-04-21-10_49_33.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_50_17.log b/build-Calibration-Desktop-Debug/2020-04-21-10_50_17.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-10_51_58.log b/build-Calibration-Desktop-Debug/2020-04-21-10_51_58.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-11_17_01.log b/build-Calibration-Desktop-Debug/2020-04-21-11_17_01.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-13_10_49.log b/build-Calibration-Desktop-Debug/2020-04-21-13_10_49.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-13_48_22.log b/build-Calibration-Desktop-Debug/2020-04-21-13_48_22.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-14_55_14.log b/build-Calibration-Desktop-Debug/2020-04-21-14_55_14.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_01_09.log b/build-Calibration-Desktop-Debug/2020-04-21-15_01_09.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_01_51.log b/build-Calibration-Desktop-Debug/2020-04-21-15_01_51.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_03_46.log b/build-Calibration-Desktop-Debug/2020-04-21-15_03_46.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_05_58.log b/build-Calibration-Desktop-Debug/2020-04-21-15_05_58.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_06_41.log b/build-Calibration-Desktop-Debug/2020-04-21-15_06_41.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_10_24.log b/build-Calibration-Desktop-Debug/2020-04-21-15_10_24.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_12_53.log b/build-Calibration-Desktop-Debug/2020-04-21-15_12_53.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-15_17_02.log b/build-Calibration-Desktop-Debug/2020-04-21-15_17_02.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_15_35.log b/build-Calibration-Desktop-Debug/2020-04-21-16_15_35.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_16_17.log b/build-Calibration-Desktop-Debug/2020-04-21-16_16_17.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_20_08.log b/build-Calibration-Desktop-Debug/2020-04-21-16_20_08.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_20_56.log b/build-Calibration-Desktop-Debug/2020-04-21-16_20_56.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_22_11.log b/build-Calibration-Desktop-Debug/2020-04-21-16_22_11.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_24_00.log b/build-Calibration-Desktop-Debug/2020-04-21-16_24_00.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_26_23.log b/build-Calibration-Desktop-Debug/2020-04-21-16_26_23.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_32_00.log b/build-Calibration-Desktop-Debug/2020-04-21-16_32_00.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_38_19.log b/build-Calibration-Desktop-Debug/2020-04-21-16_38_19.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_39_22.log b/build-Calibration-Desktop-Debug/2020-04-21-16_39_22.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_49_28.log b/build-Calibration-Desktop-Debug/2020-04-21-16_49_28.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_50_29.log b/build-Calibration-Desktop-Debug/2020-04-21-16_50_29.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_54_34.log b/build-Calibration-Desktop-Debug/2020-04-21-16_54_34.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_55_18.log b/build-Calibration-Desktop-Debug/2020-04-21-16_55_18.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_56_10.log b/build-Calibration-Desktop-Debug/2020-04-21-16_56_10.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_58_22.log b/build-Calibration-Desktop-Debug/2020-04-21-16_58_22.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-16_59_02.log b/build-Calibration-Desktop-Debug/2020-04-21-16_59_02.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-17_00_49.log b/build-Calibration-Desktop-Debug/2020-04-21-17_00_49.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-17_03_09.log b/build-Calibration-Desktop-Debug/2020-04-21-17_03_09.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-17_04_47.log b/build-Calibration-Desktop-Debug/2020-04-21-17_04_47.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-17_05_34.log b/build-Calibration-Desktop-Debug/2020-04-21-17_05_34.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-17_06_56.log b/build-Calibration-Desktop-Debug/2020-04-21-17_06_56.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/2020-04-21-17_09_27.log b/build-Calibration-Desktop-Debug/2020-04-21-17_09_27.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/build-Calibration-Desktop-Debug/Calibration b/build-Calibration-Desktop-Debug/Calibration index 4a4b8088d524853167bd6b6b278a998f2bd06d82..26220f47cb1e03889c4466243c332c6a51868bf2 100755 Binary files a/build-Calibration-Desktop-Debug/Calibration and b/build-Calibration-Desktop-Debug/Calibration differ diff --git a/build-Calibration-Desktop-Debug/Makefile b/build-Calibration-Desktop-Debug/Makefile index 8a24fc6b1fa62f0ff4725b68e4d114683bb64bb6..b44fc81ff20b817b2c91cfddd5dac3de97b0d01d 100644 --- a/build-Calibration-Desktop-Debug/Makefile +++ b/build-Calibration-Desktop-Debug/Makefile @@ -51,10 +51,14 @@ OBJECTS_DIR = ./ ####### Files SOURCES = ../Calibration/main.cpp \ - ../Calibration/mainwindow.cpp moc_mainwindow.cpp + ../Calibration/mainwindow.cpp \ + ../Calibration/reactivelabel.cpp moc_mainwindow.cpp \ + moc_reactivelabel.cpp OBJECTS = main.o \ mainwindow.o \ - moc_mainwindow.o + reactivelabel.o \ + moc_mainwindow.o \ + moc_reactivelabel.o DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf \ @@ -130,8 +134,10 @@ DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf \ ../Calibration/Calibration.pro ../sandbox/sandbox.h \ - ../Calibration/mainwindow.h ../Calibration/main.cpp \ - ../Calibration/mainwindow.cpp + ../Calibration/mainwindow.h \ + ../Calibration/reactivelabel.h ../Calibration/main.cpp \ + ../Calibration/mainwindow.cpp \ + ../Calibration/reactivelabel.cpp QMAKE_TARGET = Calibration DESTDIR = TARGET = Calibration @@ -315,8 +321,8 @@ distdir: FORCE @test -d $(DISTDIR) || mkdir -p $(DISTDIR) $(COPY_FILE) --parents $(DIST) $(DISTDIR)/ $(COPY_FILE) --parents /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp $(DISTDIR)/ - $(COPY_FILE) --parents ../sandbox/sandbox.h ../Calibration/mainwindow.h $(DISTDIR)/ - $(COPY_FILE) --parents ../Calibration/main.cpp ../Calibration/mainwindow.cpp $(DISTDIR)/ + $(COPY_FILE) --parents ../sandbox/sandbox.h ../Calibration/mainwindow.h ../Calibration/reactivelabel.h $(DISTDIR)/ + $(COPY_FILE) --parents ../Calibration/main.cpp ../Calibration/mainwindow.cpp ../Calibration/reactivelabel.cpp $(DISTDIR)/ $(COPY_FILE) --parents ../Calibration/mainwindow.ui $(DISTDIR)/ @@ -349,19 +355,27 @@ compiler_moc_predefs_clean: moc_predefs.h: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp g++ -pipe -g -std=gnu++11 -Wall -W -dM -E -o moc_predefs.h /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp -compiler_moc_header_make_all: moc_mainwindow.cpp +compiler_moc_header_make_all: moc_mainwindow.cpp moc_reactivelabel.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc_mainwindow.cpp + -$(DEL_FILE) moc_mainwindow.cpp moc_reactivelabel.cpp moc_mainwindow.cpp: ../sandbox/sandbox.h \ ../sandbox/serializable.h \ ../sandbox/camera.h \ ../sandbox/beamer.h \ ../sandbox/calibrate.h \ + ../sandbox/borderedit.h \ + ../sandbox/borderfinder.h \ + ../Calibration/reactivelabel.h \ ../Calibration/mainwindow.h \ moc_predefs.h \ /usr/lib/qt5/bin/moc /usr/lib/qt5/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -I/home/fabien/Desktop/pa/sandboxrefactorconfig/Calibration -I/home/fabien/Desktop/pa/sandboxrefactorconfig/sandbox -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../Calibration/mainwindow.h -o moc_mainwindow.cpp +moc_reactivelabel.cpp: ../Calibration/reactivelabel.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -I/home/fabien/Desktop/pa/sandboxrefactorconfig/Calibration -I/home/fabien/Desktop/pa/sandboxrefactorconfig/sandbox -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../Calibration/reactivelabel.h -o moc_reactivelabel.cpp + compiler_moc_source_make_all: compiler_moc_source_clean: compiler_uic_make_all: ui_mainwindow.h @@ -386,7 +400,10 @@ main.o: ../Calibration/main.cpp ../Calibration/mainwindow.h \ ../sandbox/serializable.h \ ../sandbox/camera.h \ ../sandbox/beamer.h \ - ../sandbox/calibrate.h + ../sandbox/calibrate.h \ + ../sandbox/borderedit.h \ + ../sandbox/borderfinder.h \ + ../Calibration/reactivelabel.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o ../Calibration/main.cpp mainwindow.o: ../Calibration/mainwindow.cpp ../Calibration/mainwindow.h \ @@ -395,12 +412,21 @@ mainwindow.o: ../Calibration/mainwindow.cpp ../Calibration/mainwindow.h \ ../sandbox/camera.h \ ../sandbox/beamer.h \ ../sandbox/calibrate.h \ + ../sandbox/borderedit.h \ + ../sandbox/borderfinder.h \ + ../Calibration/reactivelabel.h \ ui_mainwindow.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o ../Calibration/mainwindow.cpp +reactivelabel.o: ../Calibration/reactivelabel.cpp ../Calibration/reactivelabel.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o reactivelabel.o ../Calibration/reactivelabel.cpp + moc_mainwindow.o: moc_mainwindow.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp +moc_reactivelabel.o: moc_reactivelabel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_reactivelabel.o moc_reactivelabel.cpp + ####### Install install_target: first FORCE diff --git a/build-Calibration-Desktop-Debug/device b/build-Calibration-Desktop-Debug/device new file mode 100644 index 0000000000000000000000000000000000000000..b8120bf67851c45898ceaef49b0c91f4aa555395 --- /dev/null +++ b/build-Calibration-Desktop-Debug/device @@ -0,0 +1 @@ +840412061564 \ No newline at end of file diff --git a/build-Calibration-Desktop-Debug/main.o b/build-Calibration-Desktop-Debug/main.o index 63897af30701b9274a855a1b6be4a50908cdf14e..c9c9beb19b2d440be548242b03c27931e0444fa8 100644 Binary files a/build-Calibration-Desktop-Debug/main.o and b/build-Calibration-Desktop-Debug/main.o differ diff --git a/build-Calibration-Desktop-Debug/mainwindow.o b/build-Calibration-Desktop-Debug/mainwindow.o index 7a12afa38e10507e1a210a3f6ba648e8ed7a8887..fcfa0f0d630a550a80a818ea74c80982b22eb678 100644 Binary files a/build-Calibration-Desktop-Debug/mainwindow.o and b/build-Calibration-Desktop-Debug/mainwindow.o differ diff --git a/build-Calibration-Desktop-Debug/moc_mainwindow.cpp b/build-Calibration-Desktop-Debug/moc_mainwindow.cpp index 7673bbe9668ad515f9f4bf7ac9e73cc02016800f..5bc5ba9f7dcbfa66cbc289e23d8a78633e82a09f 100644 --- a/build-Calibration-Desktop-Debug/moc_mainwindow.cpp +++ b/build-Calibration-Desktop-Debug/moc_mainwindow.cpp @@ -21,8 +21,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { - QByteArrayData data[8]; - char stringdata0[122]; + QByteArrayData data[11]; + char stringdata0[173]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -38,13 +38,17 @@ QT_MOC_LITERAL(3, 28, 21), // "selectRealSenseDevice" QT_MOC_LITERAL(4, 50, 16), // "QListWidgetItem*" QT_MOC_LITERAL(5, 67, 26), // "reloadListRealSenseDevices" QT_MOC_LITERAL(6, 94, 17), // "saveConfiguration" -QT_MOC_LITERAL(7, 112, 9) // "configure" +QT_MOC_LITERAL(7, 112, 9), // "configure" +QT_MOC_LITERAL(8, 122, 16), // "selectEdgeBorder" +QT_MOC_LITERAL(9, 139, 14), // "moveEdgeBorder" +QT_MOC_LITERAL(10, 154, 18) // "deselectEdgeBorder" }, "MainWindow\0quitApplication\0\0" "selectRealSenseDevice\0QListWidgetItem*\0" "reloadListRealSenseDevices\0saveConfiguration\0" - "configure" + "configure\0selectEdgeBorder\0moveEdgeBorder\0" + "deselectEdgeBorder" }; #undef QT_MOC_LITERAL @@ -54,7 +58,7 @@ static const uint qt_meta_data_MainWindow[] = { 7, // revision 0, // classname 0, 0, // classinfo - 5, 14, // methods + 8, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -62,17 +66,23 @@ static const uint qt_meta_data_MainWindow[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags - 1, 0, 39, 2, 0x08 /* Private */, - 3, 1, 40, 2, 0x08 /* Private */, - 5, 0, 43, 2, 0x08 /* Private */, - 6, 0, 44, 2, 0x08 /* Private */, - 7, 0, 45, 2, 0x08 /* Private */, + 1, 0, 54, 2, 0x08 /* Private */, + 3, 1, 55, 2, 0x08 /* Private */, + 5, 0, 58, 2, 0x08 /* Private */, + 6, 0, 59, 2, 0x08 /* Private */, + 7, 0, 60, 2, 0x08 /* Private */, + 8, 0, 61, 2, 0x08 /* Private */, + 9, 0, 62, 2, 0x08 /* Private */, + 10, 0, 63, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, QMetaType::Void, 0x80000000 | 4, 2, QMetaType::Void, QMetaType::Void, + QMetaType::Void, + QMetaType::Void, + QMetaType::Void, QMetaType::Void, 0 // eod @@ -89,6 +99,9 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, case 2: _t->reloadListRealSenseDevices(); break; case 3: _t->saveConfiguration(); break; case 4: _t->configure(); break; + case 5: _t->selectEdgeBorder(); break; + case 6: _t->moveEdgeBorder(); break; + case 7: _t->deselectEdgeBorder(); break; default: ; } } @@ -119,13 +132,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 5) + if (_id < 8) qt_static_metacall(this, _c, _id, _a); - _id -= 5; + _id -= 8; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 5) + if (_id < 8) *reinterpret_cast<int*>(_a[0]) = -1; - _id -= 5; + _id -= 8; } return _id; } diff --git a/build-Calibration-Desktop-Debug/moc_mainwindow.o b/build-Calibration-Desktop-Debug/moc_mainwindow.o index 7140225c964566856e464c5eead0dfd6e7a7cac8..706b7a4ab0e921d8eb286569e5a2b13a3e3c45a0 100644 Binary files a/build-Calibration-Desktop-Debug/moc_mainwindow.o and b/build-Calibration-Desktop-Debug/moc_mainwindow.o differ diff --git a/build-Calibration-Desktop-Debug/moc_reactivelabel.cpp b/build-Calibration-Desktop-Debug/moc_reactivelabel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51d3bb24acc300bfda0db3d6926a00ea6421b878 --- /dev/null +++ b/build-Calibration-Desktop-Debug/moc_reactivelabel.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'reactivelabel.h' +** +** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.5) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../Calibration/reactivelabel.h" +#include <QtCore/qbytearray.h> +#include <QtCore/qmetatype.h> +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'reactivelabel.h' doesn't include <QObject>." +#elif Q_MOC_OUTPUT_REVISION != 67 +#error "This file was generated using the moc from 5.9.5. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +QT_BEGIN_MOC_NAMESPACE +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +struct qt_meta_stringdata_ReactiveLabel_t { + QByteArrayData data[5]; + char stringdata0[47]; +}; +#define QT_MOC_LITERAL(idx, ofs, len) \ + Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ + qptrdiff(offsetof(qt_meta_stringdata_ReactiveLabel_t, stringdata0) + ofs \ + - idx * sizeof(QByteArrayData)) \ + ) +static const qt_meta_stringdata_ReactiveLabel_t qt_meta_stringdata_ReactiveLabel = { + { +QT_MOC_LITERAL(0, 0, 13), // "ReactiveLabel" +QT_MOC_LITERAL(1, 14, 12), // "mousePressed" +QT_MOC_LITERAL(2, 27, 0), // "" +QT_MOC_LITERAL(3, 28, 8), // "mousePos" +QT_MOC_LITERAL(4, 37, 9) // "mouseLeft" + + }, + "ReactiveLabel\0mousePressed\0\0mousePos\0" + "mouseLeft" +}; +#undef QT_MOC_LITERAL + +static const uint qt_meta_data_ReactiveLabel[] = { + + // content: + 7, // revision + 0, // classname + 0, 0, // classinfo + 3, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 3, // signalCount + + // signals: name, argc, parameters, tag, flags + 1, 0, 29, 2, 0x06 /* Public */, + 3, 0, 30, 2, 0x06 /* Public */, + 4, 0, 31, 2, 0x06 /* Public */, + + // signals: parameters + QMetaType::Void, + QMetaType::Void, + QMetaType::Void, + + 0 // eod +}; + +void ReactiveLabel::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + if (_c == QMetaObject::InvokeMetaMethod) { + ReactiveLabel *_t = static_cast<ReactiveLabel *>(_o); + Q_UNUSED(_t) + switch (_id) { + case 0: _t->mousePressed(); break; + case 1: _t->mousePos(); break; + case 2: _t->mouseLeft(); break; + default: ; + } + } else if (_c == QMetaObject::IndexOfMethod) { + int *result = reinterpret_cast<int *>(_a[0]); + { + typedef void (ReactiveLabel::*_t)(); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ReactiveLabel::mousePressed)) { + *result = 0; + return; + } + } + { + typedef void (ReactiveLabel::*_t)(); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ReactiveLabel::mousePos)) { + *result = 1; + return; + } + } + { + typedef void (ReactiveLabel::*_t)(); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ReactiveLabel::mouseLeft)) { + *result = 2; + return; + } + } + } + Q_UNUSED(_a); +} + +const QMetaObject ReactiveLabel::staticMetaObject = { + { &QLabel::staticMetaObject, qt_meta_stringdata_ReactiveLabel.data, + qt_meta_data_ReactiveLabel, qt_static_metacall, nullptr, nullptr} +}; + + +const QMetaObject *ReactiveLabel::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; +} + +void *ReactiveLabel::qt_metacast(const char *_clname) +{ + if (!_clname) return nullptr; + if (!strcmp(_clname, qt_meta_stringdata_ReactiveLabel.stringdata0)) + return static_cast<void*>(this); + return QLabel::qt_metacast(_clname); +} + +int ReactiveLabel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QLabel::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 3) + qt_static_metacall(this, _c, _id, _a); + _id -= 3; + } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { + if (_id < 3) + *reinterpret_cast<int*>(_a[0]) = -1; + _id -= 3; + } + return _id; +} + +// SIGNAL 0 +void ReactiveLabel::mousePressed() +{ + QMetaObject::activate(this, &staticMetaObject, 0, nullptr); +} + +// SIGNAL 1 +void ReactiveLabel::mousePos() +{ + QMetaObject::activate(this, &staticMetaObject, 1, nullptr); +} + +// SIGNAL 2 +void ReactiveLabel::mouseLeft() +{ + QMetaObject::activate(this, &staticMetaObject, 2, nullptr); +} +QT_WARNING_POP +QT_END_MOC_NAMESPACE diff --git a/build-Calibration-Desktop-Debug/moc_reactivelabel.o b/build-Calibration-Desktop-Debug/moc_reactivelabel.o new file mode 100644 index 0000000000000000000000000000000000000000..fb53cdb745bf161a297f94116daa9b2c4bb08616 Binary files /dev/null and b/build-Calibration-Desktop-Debug/moc_reactivelabel.o differ diff --git a/build-Calibration-Desktop-Debug/reactivelabel.o b/build-Calibration-Desktop-Debug/reactivelabel.o new file mode 100644 index 0000000000000000000000000000000000000000..25e81d9ef7cacde34a3926e5d8844dea6365581f Binary files /dev/null and b/build-Calibration-Desktop-Debug/reactivelabel.o differ diff --git a/build-Calibration-Desktop-Debug/ui_mainwindow.h b/build-Calibration-Desktop-Debug/ui_mainwindow.h index 32bfb0df1f00c4dc331d19231a098ed551fdab9f..968784cc6975eb8f622c8735c0b53a0f8885b471 100644 --- a/build-Calibration-Desktop-Debug/ui_mainwindow.h +++ b/build-Calibration-Desktop-Debug/ui_mainwindow.h @@ -25,6 +25,7 @@ #include <QtWidgets/QStatusBar> #include <QtWidgets/QVBoxLayout> #include <QtWidgets/QWidget> +#include <reactivelabel.h> QT_BEGIN_NAMESPACE @@ -43,7 +44,7 @@ public: QSpacerItem *bottomLeftSpacer; QVBoxLayout *layoutCenter; QSpacerItem *topCenterSpacer; - QLabel *lblImage; + ReactiveLabel *lblImage; QSpacerItem *bottomCenterSpacer; QVBoxLayout *layoutRight; QSpacerItem *topRightSpacer; @@ -108,9 +109,8 @@ public: layoutCenter->addItem(topCenterSpacer); - lblImage = new QLabel(verticalLayoutWidget); + lblImage = new ReactiveLabel(verticalLayoutWidget); lblImage->setObjectName(QStringLiteral("lblImage")); - lblImage->setMinimumSize(QSize(1400, 1050)); lblImage->setStyleSheet(QLatin1String("border-color: rgb(46, 52, 54);\n" "border-width: 1px;\n" "border-style: solid;")); diff --git a/build-sandbox-Desktop-Debug/Makefile b/build-sandbox-Desktop-Debug/Makefile index e4944c3f94ccfce06bd1500cf6d0efbdce971ef9..ea286a10f0b09cdc19ed5b05d572339ce7c258be 100644 --- a/build-sandbox-Desktop-Debug/Makefile +++ b/build-sandbox-Desktop-Debug/Makefile @@ -50,11 +50,15 @@ OBJECTS_DIR = ./ SOURCES = ../sandbox/beamer.cpp \ ../sandbox/calibrate.cpp \ ../sandbox/camera.cpp \ - ../sandbox/sandbox.cpp + ../sandbox/sandbox.cpp \ + ../sandbox/borderedit.cpp \ + ../sandbox/borderfinder.cpp OBJECTS = beamer.o \ calibrate.o \ camera.o \ - sandbox.o + sandbox.o \ + borderedit.o \ + borderfinder.o DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf \ @@ -132,10 +136,14 @@ DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ ../sandbox/calibrate.h \ ../sandbox/camera.h \ ../sandbox/sandbox.h \ - ../sandbox/serializable.h ../sandbox/beamer.cpp \ + ../sandbox/serializable.h \ + ../sandbox/borderedit.h \ + ../sandbox/borderfinder.h ../sandbox/beamer.cpp \ ../sandbox/calibrate.cpp \ ../sandbox/camera.cpp \ - ../sandbox/sandbox.cpp + ../sandbox/sandbox.cpp \ + ../sandbox/borderedit.cpp \ + ../sandbox/borderfinder.cpp QMAKE_TARGET = sandbox DESTDIR = TARGET = libsandbox.a @@ -321,8 +329,8 @@ distdir: FORCE @test -d $(DISTDIR) || mkdir -p $(DISTDIR) $(COPY_FILE) --parents $(DIST) $(DISTDIR)/ $(COPY_FILE) --parents /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp $(DISTDIR)/ - $(COPY_FILE) --parents ../sandbox/beamer.h ../sandbox/calibrate.h ../sandbox/camera.h ../sandbox/sandbox.h ../sandbox/serializable.h $(DISTDIR)/ - $(COPY_FILE) --parents ../sandbox/beamer.cpp ../sandbox/calibrate.cpp ../sandbox/camera.cpp ../sandbox/sandbox.cpp $(DISTDIR)/ + $(COPY_FILE) --parents ../sandbox/beamer.h ../sandbox/calibrate.h ../sandbox/camera.h ../sandbox/sandbox.h ../sandbox/serializable.h ../sandbox/borderedit.h ../sandbox/borderfinder.h $(DISTDIR)/ + $(COPY_FILE) --parents ../sandbox/beamer.cpp ../sandbox/calibrate.cpp ../sandbox/camera.cpp ../sandbox/sandbox.cpp ../sandbox/borderedit.cpp ../sandbox/borderfinder.cpp $(DISTDIR)/ clean: compiler_clean @@ -386,9 +394,17 @@ sandbox.o: ../sandbox/sandbox.cpp ../sandbox/sandbox.h \ ../sandbox/serializable.h \ ../sandbox/camera.h \ ../sandbox/beamer.h \ - ../sandbox/calibrate.h + ../sandbox/calibrate.h \ + ../sandbox/borderedit.h \ + ../sandbox/borderfinder.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o sandbox.o ../sandbox/sandbox.cpp +borderedit.o: ../sandbox/borderedit.cpp ../sandbox/borderedit.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o borderedit.o ../sandbox/borderedit.cpp + +borderfinder.o: ../sandbox/borderfinder.cpp ../sandbox/borderfinder.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o borderfinder.o ../sandbox/borderfinder.cpp + ####### Install install_target: first FORCE diff --git a/build-sandbox-Desktop-Debug/borderedit.o b/build-sandbox-Desktop-Debug/borderedit.o new file mode 100644 index 0000000000000000000000000000000000000000..43c4ff8ad936fed272a813b3fcdf35aeb043d68a Binary files /dev/null and b/build-sandbox-Desktop-Debug/borderedit.o differ diff --git a/build-sandbox-Desktop-Debug/borderfinder.o b/build-sandbox-Desktop-Debug/borderfinder.o new file mode 100644 index 0000000000000000000000000000000000000000..60183584e89e3ab1631648a01b33c2d3212cc213 Binary files /dev/null and b/build-sandbox-Desktop-Debug/borderfinder.o differ diff --git a/build-sandbox-Desktop-Debug/libsandbox.a b/build-sandbox-Desktop-Debug/libsandbox.a index 72140bcda8896c8726ed055857e6f09f7c5ef9c4..531b3d3ef45842ae3d70ae21787d7e336557da67 100644 Binary files a/build-sandbox-Desktop-Debug/libsandbox.a and b/build-sandbox-Desktop-Debug/libsandbox.a differ diff --git a/build-sandbox-Desktop-Debug/sandbox.o b/build-sandbox-Desktop-Debug/sandbox.o index 28546963a82720f5d16b8d954e452ada7cbae553..d14490bb1d7c9cc12d38889297c665320af9e583 100644 Binary files a/build-sandbox-Desktop-Debug/sandbox.o and b/build-sandbox-Desktop-Debug/sandbox.o differ diff --git a/sandbox/borderedit.cpp b/sandbox/borderedit.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4f5363309a87387e16888a47000ea5b62c5abb6 --- /dev/null +++ b/sandbox/borderedit.cpp @@ -0,0 +1,37 @@ +#include <algorithm> +#include "borderedit.h" + +Mat BorderEdit::frameImage; + +Mat BorderEdit::drawSquare(Point *p, int n) +{ + Mat imageCopy = frameImage.clone(); + polylines(imageCopy, &p, &n, 1, true, Scalar(0, 255, 0), 1, LINE_AA); + //imshow(wndname, imageCopy); + + return imageCopy; +} + +int BorderEdit::findPoints(int x, int y, vector<Point> *posSandbox) +{ + for (int i = 0; i < (int)posSandbox->size(); i++) + { + //check if the point is clicked + if ((x >= (posSandbox->at(i).x - margeClick)) && (x <= (posSandbox->at(i).x + margeClick)) && (y >= (posSandbox->at(i).y - margeClick)) && (y <= (posSandbox->at(i).y + margeClick))) + return i; + } + return -1; //not found +} + +Mat BorderEdit::edit(int selectedPoint, int x, int y, vector<Point> *posSandbox) +{ + posSandbox->at(selectedPoint).x = x; + posSandbox->at(selectedPoint).y = y; + return BorderEdit::drawSquare(&posSandbox->at(0), (int)posSandbox->size()); +} + +Mat BorderEdit::initBorder(Mat frame, vector<Point> *posSandbox) +{ + frame.copyTo(frameImage); + return BorderEdit::drawSquare(&posSandbox->at(0), (int)posSandbox->size()); +} diff --git a/sandbox/borderedit.h b/sandbox/borderedit.h new file mode 100644 index 0000000000000000000000000000000000000000..a90a409790f8f0147a15dbd45434b1d83258f8d2 --- /dev/null +++ b/sandbox/borderedit.h @@ -0,0 +1,24 @@ +#ifndef BORDEREDIT_H +#define BORDEREDIT_H + +#include <opencv2/opencv.hpp> +#include <QLabel> + +using namespace cv; +using namespace std; + +class BorderEdit +{ +private: + static const int margeClick = 10; + static constexpr char *wndname = (char *)"Sandbox Border Finder"; + static Mat frameImage; + // OPENCV - MANUEL RECT CHANGE + static Mat drawSquare(cv::Point *p, int n); + +public: + static Mat initBorder(Mat frame, vector<Point> *posSandbox); + static Mat edit(int selectedPoint, int x, int y, vector<Point> *posSandbox); + static int findPoints(int x, int y, vector<Point> *posSandbox); +}; +#endif diff --git a/sandbox/borderfinder.cpp b/sandbox/borderfinder.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3584032815e13fc4a7daed448086d8bf4aca048d --- /dev/null +++ b/sandbox/borderfinder.cpp @@ -0,0 +1,92 @@ +#include <algorithm> +#include "borderfinder.h" + +double BorderFinder::angle(Point pt1, Point pt2, Point pt0) +{ + double dx1 = pt1.x - pt0.x; + double dy1 = pt1.y - pt0.y; + double dx2 = pt2.x - pt0.x; + double dy2 = pt2.y - pt0.y; + return (dx1 * dx2 + dy1 * dy2) / sqrt((dx1 * dx1 + dy1 * dy1) * (dx2 * dx2 + dy2 * dy2) + 1e-10); +} + +// returns sequence of squares detected on the image. +bool BorderFinder::find(Rect &rect) +{ + vector<vector<Point>> rectDetect; + + Mat pyr, timg, gray0(frameImage.size(), CV_8U); + + // down-scale and upscale the image to filter out the noise + pyrDown(frameImage, pyr, Size(frameImage.cols / 2, frameImage.rows / 2)); + pyrUp(pyr, timg, frameImage.size()); + vector<vector<Point>> contours; + int c = 1; + int ch[] = {c, 0}; + mixChannels(&timg, 1, &gray0, 1, ch, 1); + gray0 = gray0 > 10; + waitKey(0); + findContours(gray0, contours, RETR_LIST, CHAIN_APPROX_SIMPLE); + vector<Point> approx; + // test each contour + cout << "nb rect: " << contours.size() << endl; + for (size_t i = 0; i < contours.size(); i++) + { + // approximate contour with accuracy proportional + // to the contour perimeter + approxPolyDP(contours[i], approx, arcLength(contours[i], true) * 0.02, true); + if (approx.size() == 4 && + fabs(contourArea(approx)) > 1000 && + isContourConvex(approx)) + { + double maxCosine = 0; + + for (int j = 2; j < 5; j++) + { + // find the maximum cosine of the angle between joint edges + double cosine = fabs(angle(approx[j % 4], approx[j - 2], approx[j - 1])); + maxCosine = MAX(maxCosine, cosine); + } + + // if cosines of all angles are small + // (all angles are ~90 degree) then write quandrange + // vertices to resultant sequence + // if (maxCosine < 0.3) + // { + rect = rotateRect(boundingRect(approx), 90, 90); + const Point *p = &approx[0]; + int n = (int)approx.size(); + polylines(frameImage, &p, &n, 1, true, Scalar(0, 0, 255), 3, LINE_AA); + //return true; + //} + } + } + //imshow("ff", frameImage); + //waitKey(0); + return true; +} + +Rect BorderFinder::rotateRect(Rect rect, int heightPercentage, int widthPercetange) +{ + int rwidth = rect.width; + int rheight = rect.height; + + rect.width = round((rect.width * widthPercetange) / 100.0f); + rect.height = round((rect.height * heightPercentage) / 100.0f); + rect.x += (rwidth - rect.width) / 2; + rect.y += (rheight - rect.height) / 2; + + return rect; +} + +float BorderFinder::calculDistance(float point1[], float point2[]) +{ + return sqrt(pow(point1[0] - point2[0], 2) + + pow(point1[1] - point2[1], 2) + + pow(point1[2] - point2[2], 2)); +} + +BorderFinder::BorderFinder(Mat frame) +{ + frame.copyTo(frameImage); +} diff --git a/sandbox/borderfinder.h b/sandbox/borderfinder.h new file mode 100644 index 0000000000000000000000000000000000000000..e43b39ffee365065ac8c41a21dbb7f6dba9ac9ba --- /dev/null +++ b/sandbox/borderfinder.h @@ -0,0 +1,23 @@ +#ifndef BORDERFINDER_H +#define BORDERFINDER_H +#include <opencv2/opencv.hpp> + +using namespace cv; +using namespace std; + +class BorderFinder +{ +private: + // helper function: + // finds a cosine of angle between vectors + // from pt0->pt1 and from pt0->pt2 + double angle(Point pt1, Point pt2, Point pt0); + Mat frameImage; + Rect rotateRect(Rect rect, int heightPercentage, int widthPercetange); + +public: + float calculDistance(float point1[], float point2[]); + BorderFinder(Mat frame); + bool find(Rect &rect); +}; +#endif diff --git a/sandbox/sandbox.cpp b/sandbox/sandbox.cpp index f792e520c2e6801b08892e9c394df0e8e677340e..37f273701fcca7bd77c9afbc21252a9a548b2850 100644 --- a/sandbox/sandbox.cpp +++ b/sandbox/sandbox.cpp @@ -82,36 +82,56 @@ string Sandbox::deserialize(istream& stream) return "Problem to load"; } -/*! - * \brief Sandbox::configure - * \param lblImage - * Use a QLabel to configure the Matrices - * With the Intel RealSense camera and a beamer - */ -void Sandbox::configure(QLabel* lblImage) { - // Setup matrix for the label - Mat frameBeamer(Size(Beamer::width, Beamer::height), CV_8UC3, Scalar(255, 0, 0)); - lblImage->setPixmap(QPixmap::fromImage(QImage(frameBeamer.data, frameBeamer.cols, frameBeamer.rows, frameBeamer.step, QImage::Format_RGB888))); - +Mat Sandbox::generateBorder() { // Start the Intel RealSense Camera camera.startAlign(); // 1 seconde of warming up - //camera.captureFramesAlign(); + camera.captureFramesAlign(); - /*Mat frameData = camera.getDepthFrameAlign(); + Mat frameData = camera.getDepthFrameAlign(); Mat coloredFrame = camera.getRGBFrameAlign(); Size s = frameData.size(); - Point center(s.width / 2, s.height / 2); + center.x = s.width / 2; + center.y = s.height / 2; float distancePlan = static_cast<float>(mean(frameData(Rect(center, Size(10, 10))))[0]); // get sandbox distance from center of camera calibrate.setDistancePlan(distancePlan); //destroyAllWindows(); - vector<Point> rectPoints; + float y = coloredFrame.size().height; float x = coloredFrame.size().width; rectPoints.push_back(Point(1.0/4*x, 1.0/4*y)); rectPoints.push_back(Point(1.0/4*x, 3.0/4*y)); rectPoints.push_back(Point(3.0/4*x, 3.0/4*y)); - rectPoints.push_back(Point(3.0/4*x, 1.0/4*y));*/ + rectPoints.push_back(Point(3.0/4*x, 1.0/4*y)); + + coloredFrame = BorderEdit::initBorder(coloredFrame, &rectPoints); // edit projected frame + + return coloredFrame; +} + +void Sandbox::applyBorder() { + // adjust model matrixe to forme a rectangle in sandbox + int widthTop = rectPoints[3].x - rectPoints[0].x; + double angle1 = atan((double)(rectPoints[3].y - rectPoints[0].y) / widthTop); + Mat matRotation = getRotationMatrix2D(center, toDegrees(angle1), 1); + calibrate.setMatrixRotation(matRotation); + + Size rectSize = Size(widthTop, cvRound(widthTop / 1.33333) + 5); + Point p = calibrate.rotatePixel(rectPoints[0]); + rectSandbox = Rect(p, rectSize); +} + +double Sandbox::toDegrees(double radians) +{ + return radians * (180.0 / M_PI); +} + +int Sandbox::findEdgeBorder(int x, int y) { + return BorderEdit::findPoints(x, y, &rectPoints); +} + +Mat Sandbox::editEdgeBorder(int selectedPoint, int x, int y) { + return BorderEdit::edit(selectedPoint, x, y, &rectPoints); } diff --git a/sandbox/sandbox.h b/sandbox/sandbox.h index d750969c931cec846199992deb1db879ac71de25..901021bf4931b10085b8e8fd863f62a8936ca7d1 100644 --- a/sandbox/sandbox.h +++ b/sandbox/sandbox.h @@ -12,6 +12,8 @@ #include "camera.h" #include "beamer.h" #include "calibrate.h" +#include "borderedit.h" +#include "borderfinder.h" #include <QPixmap> #include <QLabel> #include <QImage> @@ -29,6 +31,9 @@ private: char* realSenseDeviceSerialNumber; Camera camera; Calibrate calibrate; + Rect rectSandbox; + vector<Point> rectPoints; + Point center; public: Sandbox(); @@ -39,7 +44,12 @@ public: void saveConfiguration(); void serialize(ostream& stream); string deserialize(istream& stream); - void configure(QLabel* lblImage); + Mat configure(); + double toDegrees(double radians); + void applyBorder(); + Mat generateBorder(); + int findEdgeBorder(int x, int y); + Mat editEdgeBorder(int selectedPoint, int x, int y); }; #endif // SANDBOX_H diff --git a/sandbox/sandbox.pro b/sandbox/sandbox.pro index f9a74013a1c82301d638131345f00477e36bfb2b..f6002099499060b0cc098a2f7c827108ba65fde8 100644 --- a/sandbox/sandbox.pro +++ b/sandbox/sandbox.pro @@ -20,14 +20,18 @@ SOURCES += \ beamer.cpp \ calibrate.cpp \ camera.cpp \ - sandbox.cpp + sandbox.cpp \ + borderedit.cpp \ + borderfinder.cpp HEADERS += \ beamer.h \ calibrate.h \ camera.h \ sandbox.h \ - serializable.h + serializable.h \ + borderedit.h \ + borderfinder.h # Default rules for deployment. unix {