diff --git a/TrackerPlugin_PupilDiam.cpp b/TrackerPlugin_EyeTracker.cpp similarity index 85% rename from TrackerPlugin_PupilDiam.cpp rename to TrackerPlugin_EyeTracker.cpp index 74f7914..d3f0681 100644 --- a/TrackerPlugin_PupilDiam.cpp +++ b/TrackerPlugin_EyeTracker.cpp @@ -1,6 +1,6 @@ -#include "TrackerPlugin_PupilDiam.h" +#include "TrackerPlugin_EyeTracker.h" -TrackerPlugin_PupilDiam::TrackerPlugin_PupilDiam(QObject *parent) +TrackerPlugin_EyeTracker::TrackerPlugin_EyeTracker(QObject *parent) { ui = new Ui::TrackerPlugin_PupilDiam; trackerWorker = new TrackerWorker(); @@ -38,7 +38,6 @@ TrackerPlugin_PupilDiam::TrackerPlugin_PupilDiam(QObject *parent) uiSliders_Size.push_back(ui->Slider_Size_1); uiSliders_Size.push_back(ui->Slider_Size_2); - uiLineEdits.push_back(ui->lineEdit_PupilMinArea); uiLineEdits.push_back(ui->lineEdit_PupilMaxArea); uiLineEdits.push_back(ui->lineEdit_CorneaMinArea); @@ -49,10 +48,19 @@ TrackerPlugin_PupilDiam::TrackerPlugin_PupilDiam(QObject *parent) uiPlots.at(0)->setAxisTitle(0, "Pupil x [px]"); uiPlots.at(1)->setAxisTitle(0, "Pupil y [px]"); - uiPlots.at(2)->setAxisTitle(0, "Cornea x [px]"); - uiPlots.at(3)->setAxisTitle(0, "Cornea y [px]"); - uiPlots.at(4)->setAxisTitle(0, "Pupil diam [px]"); + uiPlots.at(2)->setAxisTitle(0, "CR x [px]"); + uiPlots.at(3)->setAxisTitle(0, "CR y [px]"); + uiPlots.at(4)->setAxisTitle(0, "Pupil Ø [px]"); + +// pLineH.setLine(0,0,100,100); +// pLineV.setLine(0,0,0,0); +// cLineH.setLine(0,0,0,0); +// cLineV.setLine(0,0,0,0); +// cameraScene->addLine(pLineH); +// cameraScene->addLine(pLineV); +// cameraScene->addLine(cLineH); +// cameraScene->addLine(cLineV); /*Prepare rects*/ for(int i=0;i<2;i++){ @@ -67,7 +75,6 @@ TrackerPlugin_PupilDiam::TrackerPlugin_PupilDiam(QObject *parent) } connect(signalMapperPosition, SIGNAL(mapped(int)), this, SLOT(onItemPositionChanged(int))); - /*Prepare curves*/ for(int i=0;i<plotPens.size();i++){ curves.push_back(new QwtPlotCurve("Curve")); @@ -127,7 +134,6 @@ TrackerPlugin_PupilDiam::TrackerPlugin_PupilDiam(QObject *parent) QIntValidator *intValidator = new QIntValidator(0, 2147483647 ,this); ui->lineEdit->setValidator(intValidator); - /*Connection TrackingGui - TrackingWorker*/ connect(this, SIGNAL(thresholdChanged(int, int)), trackerWorker, SLOT(onThresholdChanged(int, int))); // //connect(ui->widget_trackingGui, SIGNAL(roiChanged(int, QRectF)), trackingWorker, SLOT(onRoisChanged(int, QRectF))); @@ -135,16 +141,16 @@ TrackerPlugin_PupilDiam::TrackerPlugin_PupilDiam(QObject *parent) connect(this, SIGNAL(sizeChanged(int, QSize)), trackerWorker, SLOT(onSizeChanged(int, QSize))); connect(this, SIGNAL(areaContraintsChanged(int,int)), trackerWorker, SLOT(onAreaConstraintsChanged(int,int))); connect(ui->checkBox_showBinary, SIGNAL(clicked(bool)), trackerWorker, SLOT(onShowBinary(bool))); -// connect(trackerWorker, SIGNAL(trackingResult(QVector<float>)), this, SLOT(onTrackingResult(QVector<float>))); - connect(trackerWorker, SIGNAL(trackingResult(TrackingResults)), this, SLOT(onTrackingResult(TrackingResults))); + connect(trackerWorker, SIGNAL(trackingResult(std::vector<double>)), this, SLOT(onTrackingResult(std::vector<double>))); +// connect(trackerWorker, SIGNAL(trackingResult(TrackingResults)), this, SLOT(onTrackingResult(TrackingResults))); } -QObject *TrackerPlugin_PupilDiam::worker() +QObject *TrackerPlugin_EyeTracker::worker() { return trackerWorker; } -void TrackerPlugin_PupilDiam::initializeUI(QLayout *layout, QGraphicsScene *cameraScene, QSize cameraResolution) +void TrackerPlugin_EyeTracker::initializeUI(QLayout *layout, QGraphicsScene *cameraScene, QSize cameraResolution) { this->cameraResolution = cameraResolution; layout->addWidget(this); @@ -169,45 +175,28 @@ void TrackerPlugin_PupilDiam::initializeUI(QLayout *layout, QGraphicsScene *came } } - - -void TrackerPlugin_PupilDiam::onTrackingResult(TrackingResults result) +void TrackerPlugin_EyeTracker::onTrackingResult(std::vector<double> result) { - int nPlots = 5; - - /*window is full - stop */ - if(frameCount>wndLength){ - for(int i=0;i<nPlots;i++){ - rectSamples.at(i)->pop_front(); - } - } - - rectSamples.at(0)->push_back(QPointF(t, result.cPupil.x)); - rectSamples.at(1)->push_back(QPointF(t, result.cPupil.y)); - rectSamples.at(2)->push_back(QPointF(t, result.cCornea.x)); - rectSamples.at(3)->push_back(QPointF(t, result.cCornea.y)); - rectSamples.at(4)->push_back(QPointF(t, result.pDiam)); - - - for(int i = 0; i< nPlots; i++){ + for(int i = 0; i< rectSamples.size(); i++){ + if(frameCount>wndLength)/*window is full - stop */ + rectSamples.at(i)->pop_front(); + rectSamples.at(i)->push_back(QPointF(t, result.at(i))); rectData.at(i)->setSamples(*rectSamples.at(i)); curves.at(i)->setData(rectData.at(i)); } - ui->qwtPlot_1->replot(); ui->qwtPlot_2->replot(); ui->qwtPlot_3->replot(); ui->qwtPlot_4->replot(); ui->qwtPlot_5->replot(); + t++; frameCount++; - } -void TrackerPlugin_PupilDiam::onCheckBoxClicked(int index) +void TrackerPlugin_EyeTracker::onCheckBoxClicked(int index) { - bool isVisible = !uiPlots.at(index)->isVisible(); switch ( index ){ @@ -225,18 +214,15 @@ void TrackerPlugin_PupilDiam::onCheckBoxClicked(int index) uiPlots.at(index)->setVisible(isVisible); - - - } -void TrackerPlugin_PupilDiam::onThreshSliderMoved(int index) +void TrackerPlugin_EyeTracker::onThreshSliderMoved(int index) { float value = uiSliders.at(index)->value(); emit(thresholdChanged(index, value)); } -void TrackerPlugin_PupilDiam::onSizeSliderMoved(int index) +void TrackerPlugin_EyeTracker::onSizeSliderMoved(int index) { float value = uiSliders_Size.at(index)->value(); if((rectItems.at(index)->pos().x() + maxRectWidth*value < cameraScene->width()) & @@ -247,7 +233,7 @@ void TrackerPlugin_PupilDiam::onSizeSliderMoved(int index) } } -void TrackerPlugin_PupilDiam::on_lineEdit_editingFinished() +void TrackerPlugin_EyeTracker::on_lineEdit_editingFinished() { wndLength = ui->lineEdit->text().toDouble(); for(int i=0;i<rectSamples.size();i++){ @@ -256,12 +242,12 @@ void TrackerPlugin_PupilDiam::on_lineEdit_editingFinished() } } -void TrackerPlugin_PupilDiam::onAreaConstraintsEditingFinished(int index) +void TrackerPlugin_EyeTracker::onAreaConstraintsEditingFinished(int index) { emit(areaContraintsChanged(index, uiLineEdits.at(index)->text().toInt())); } -void TrackerPlugin_PupilDiam::onItemPositionChanged(int index) +void TrackerPlugin_EyeTracker::onItemPositionChanged(int index) { if(rectItems.at(index)->pos().x() < 0){ rectItems.at(index)->setX(0); diff --git a/TrackerPlugin_PupilDiam.h b/TrackerPlugin_EyeTracker.h similarity index 88% rename from TrackerPlugin_PupilDiam.h rename to TrackerPlugin_EyeTracker.h index e60a097..44b7e3e 100644 --- a/TrackerPlugin_PupilDiam.h +++ b/TrackerPlugin_EyeTracker.h @@ -3,7 +3,7 @@ #include "TrackerInterface.h" #include "TrackerWorker.h" -#include "ui_TrackerPlugin_PupilDiam.h" +#include "ui_TrackerPlugin_EyeTracker.h" #include <qwt_plot.h> #include <qwt_plot_curve.h> #include <qwt_series_data.h> @@ -27,22 +27,19 @@ namespace Ui { class TrackerPlugin_PupilDiam; } -class TrackerPlugin_PupilDiam : public QWidget, public TrackerInterface +class TrackerPlugin_EyeTracker : public QWidget, public TrackerInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.PylonRecorder.TrackerInterface") Q_INTERFACES(TrackerInterface) public: - explicit TrackerPlugin_PupilDiam(QObject *parent = 0); + explicit TrackerPlugin_EyeTracker(QObject *parent = 0); QObject *worker(); void initializeUI(QLayout* guiTargetLayout, QGraphicsScene* cameraScene, QSize cameraResolution); TrackerWorker* trackerWorker; QSize cameraResolution; -public slots: - void onFrameGrabbed(cv::Mat); - private: Ui::TrackerPlugin_PupilDiam *ui; QGraphicsScene* cameraScene; @@ -51,6 +48,11 @@ public slots: QVector<QPen*> plotPens; QVector<QPen*> rectPens; + QLine pLineV; + QLine pLineH; + QLine cLineH; + QLine cLineV; + QVector<QVector<QPointF>*> rectSamples; QVector<QwtPointSeriesData*> rectData; QVector<QwtPlotCurve*> curves; @@ -76,7 +78,7 @@ public slots: QSignalMapper* signalMapperLineEdit; private slots: - void onTrackingResult(TrackingResults result); + void onTrackingResult(std::vector<double>); void onCheckBoxClicked(int); void onThreshSliderMoved(int); void onSizeSliderMoved(int); diff --git a/TrackerPlugin_EyeTracker.pro b/TrackerPlugin_EyeTracker.pro new file mode 100644 index 0000000..99bf745 --- /dev/null +++ b/TrackerPlugin_EyeTracker.pro @@ -0,0 +1,62 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-10-24T11:57:07 +# +#------------------------------------------------- + +TEMPLATE = lib +CONFIG += plugin +QT += widgets +TARGET = $$qtLibraryTarget(TrackerPlugin_EyeTracker) +DESTDIR = ../../../../src/build/plugins +CONFIG += c++11 + + +SOURCES += \ + TrackerWorker.cpp \ + TrackerPlugin_EyeTracker.cpp + +HEADERS += \ + TrackerWorker.h \ + NotifyingQGraphicsRectItem.h \ + TrackerPlugin_EyeTracker.h + +INCLUDEPATH += ../../../src/ + +win32 { + INCLUDEPATH += "D:\\opencv\\build_vc12\\install\\include" + + CONFIG(debug,debug|release) { + LIBS += -L"D:\\opencv\\build_vc12\\install\\x64\\vc12\\lib" \ + -lopencv_core310 \ + -lopencv_highgui310 \ + -lopencv_imgproc310 \ + -lopencv_features2d310 \ + -lopencv_videoio310 \ + -lopencv_video310 \ + -lopencv_videostab310 \ + } + + CONFIG(release,debug|release) { + DEFINES += QT_NO_WARNING_OUTPUT QT_NO_DEBUG_OUTPUT + LIBS += -L"D:\\opencv\\build_vc12\\install\\x64\\vc12\\lib" \ + -lopencv_core310 \ + -lopencv_highgui310 \ + -lopencv_imgproc310 \ + -lopencv_features2d310 \ + -lopencv_videoio310 \ + -lopencv_video310 \ + -lopencv_videostab310 \ + } + + INCLUDEPATH += "C:/Qwt-6.1.3/include" + LIBS += -L"C:/Qwt-6.1.3/lib" \ + -lqwt +} + +unix{ + CONFIG += qwt +} + +FORMS += \ + TrackerPlugin_EyeTracker.ui diff --git a/TrackerPlugin_EyeTracker.ui b/TrackerPlugin_EyeTracker.ui new file mode 100644 index 0000000..aff21a1 --- /dev/null +++ b/TrackerPlugin_EyeTracker.ui @@ -0,0 +1,366 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TrackerPlugin_PupilDiam</class> + <widget class="QWidget" name="TrackerPlugin_PupilDiam"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>610</width> + <height>909</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="topMargin"> + <number>0</number> + </property> + <item row="8" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_5"> + <property name="text"> + <string>Pupil Diameter</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QwtPlot" name="qwtPlot_5"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>100</height> + </size> + </property> + <zorder>horizontalLayoutWidget</zorder> + </widget> + </item> + </layout> + </item> + <item row="3" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_2"> + <property name="text"> + <string>Pupil Y</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QwtPlot" name="qwtPlot_2"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>100</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_11"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_1"> + <property name="text"> + <string>Pupil X</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QwtPlot" name="qwtPlot_1"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>100</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item row="7" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_4"> + <property name="text"> + <string>Cornea Y</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QwtPlot" name="qwtPlot_4"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>100</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item row="5" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_9"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_3"> + <property name="text"> + <string>Cornea X</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QwtPlot" name="qwtPlot_3"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>100</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout"> + <property name="topMargin"> + <number>0</number> + </property> + <item row="4" column="2"> + <widget class="QwtSlider" name="Slider_Size_1"> + <property name="lowerBound"> + <double>0.010000000000000</double> + </property> + <property name="upperBound"> + <double>1.000000000000000</double> + </property> + <property name="scaleMaxMajor"> + <number>2</number> + </property> + <property name="scaleMaxMinor"> + <number>0</number> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QwtSlider" name="Slider_1"> + <property name="upperBound"> + <double>255.000000000000000</double> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="lineEdit_PupilMaxArea"> + <property name="text"> + <string>50000</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Pupil min Area</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Pupil max Area</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="lineEdit_PupilMinArea"> + <property name="text"> + <string>0</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_3"> + <property name="topMargin"> + <number>0</number> + </property> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Cornea max Area</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QwtSlider" name="Slider_Size_2"> + <property name="lowerBound"> + <double>0.010000000000000</double> + </property> + <property name="upperBound"> + <double>1.000000000000000</double> + </property> + <property name="scaleMaxMajor"> + <number>2</number> + </property> + <property name="scaleMaxMinor"> + <number>0</number> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="lineEdit_CorneaMaxArea"> + <property name="text"> + <string>50000</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Cornea min Area</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QwtSlider" name="Slider_2"> + <property name="upperBound"> + <double>255.000000000000000</double> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="lineEdit_CorneaMinArea"> + <property name="text"> + <string>0</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Window width [fms]:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"> + <property name="text"> + <string>200</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_showBinary"> + <property name="text"> + <string>Binary</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>QwtPlot</class> + <extends>QFrame</extends> + <header>qwt_plot.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>QwtSlider</class> + <extends>QWidget</extends> + <header>qwt_slider.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/TrackerPlugin_PupilDiam.pro b/TrackerPlugin_PupilDiam.pro deleted file mode 100644 index 9f870e7..0000000 --- a/TrackerPlugin_PupilDiam.pro +++ /dev/null @@ -1,38 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2016-10-24T11:57:07 -# -#------------------------------------------------- - -TEMPLATE = lib -CONFIG += plugin -QT += widgets -TARGET = $$qtLibraryTarget(TrackerPlugin_pupilDiam) -DESTDIR = ../../../../src/build/plugins -CONFIG += c++11 - - -SOURCES += \ - TrackerPlugin_PupilDiam.cpp \ - TrackerWorker.cpp - -HEADERS += \ - TrackerPlugin_PupilDiam.h \ - TrackerWorker.h \ - NotifyingQGraphicsRectItem.h \ - TrackingResults.h - -INCLUDEPATH += ../../../../src/ - -win32 { - INCLUDEPATH += "C:/Qwt-6.1.3/include" - LIBS += -L"C:/Qwt-6.1.3/lib" \ - -lqwt -} - -unix{ - CONFIG += qwt -} - -FORMS += \ - TrackerPlugin_PupilDiam.ui diff --git a/TrackerPlugin_PupilDiam.ui b/TrackerPlugin_PupilDiam.ui deleted file mode 100644 index ae46d20..0000000 --- a/TrackerPlugin_PupilDiam.ui +++ /dev/null @@ -1,416 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>TrackerPlugin_PupilDiam</class> - <widget class="QWidget" name="TrackerPlugin_PupilDiam"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>610</width> - <height>909</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout_2"> - <property name="topMargin"> - <number>0</number> - </property> - <item row="3" column="1"> - <widget class="QwtPlot" name="qwtPlot_4"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>150</height> - </size> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QwtPlot" name="qwtPlot_3"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>150</height> - </size> - </property> - </widget> - </item> - <item row="3" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QCheckBox" name="checkBox_4"> - <property name="text"> - <string>Cornea Y</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <item> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Min Area</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_CorneaMinArea"> - <property name="text"> - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Max Area</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_CorneaMaxArea"> - <property name="text"> - <string>50000</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer_4"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="0" column="1"> - <widget class="QwtPlot" name="qwtPlot_1"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </widget> - </item> - <item row="0" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QCheckBox" name="checkBox_1"> - <property name="text"> - <string>Pupil X</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QwtSlider" name="Slider_1"/> - </item> - <item> - <widget class="QwtSlider" name="Slider_Size_1"> - <property name="lowerBound"> - <double>0.010000000000000</double> - </property> - <property name="upperBound"> - <double>1.000000000000000</double> - </property> - <property name="scaleMaxMajor"> - <number>2</number> - </property> - <property name="scaleMaxMinor"> - <number>0</number> - </property> - <property name="value"> - <double>1.000000000000000</double> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="1" column="1"> - <widget class="QwtPlot" name="qwtPlot_2"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>150</height> - </size> - </property> - </widget> - </item> - <item row="1" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QCheckBox" name="checkBox_2"> - <property name="text"> - <string>Pupil Y</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Min Area</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_PupilMinArea"> - <property name="text"> - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Max Area</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_PupilMaxArea"> - <property name="text"> - <string>50000</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QCheckBox" name="checkBox_3"> - <property name="text"> - <string>Cornea X</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QwtSlider" name="Slider_2"/> - </item> - <item> - <widget class="QwtSlider" name="Slider_Size_2"> - <property name="lowerBound"> - <double>0.010000000000000</double> - </property> - <property name="upperBound"> - <double>1.000000000000000</double> - </property> - <property name="scaleMaxMajor"> - <number>2</number> - </property> - <property name="scaleMaxMinor"> - <number>0</number> - </property> - <property name="value"> - <double>1.000000000000000</double> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="4" column="1"> - <widget class="QwtPlot" name="qwtPlot_5"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>150</height> - </size> - </property> - </widget> - </item> - <item row="4" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QCheckBox" name="checkBox_5"> - <property name="text"> - <string>Pupil Diameter</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_5"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QCheckBox" name="checkBox_showBinary"> - <property name="text"> - <string>Binary</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Window width [fms]:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"> - <property name="text"> - <string>200</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>QwtPlot</class> - <extends>QFrame</extends> - <header>qwt_plot.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>QwtSlider</class> - <extends>QWidget</extends> - <header>qwt_slider.h</header> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/TrackerWorker.cpp b/TrackerWorker.cpp index 6e51efd..ece6758 100644 --- a/TrackerWorker.cpp +++ b/TrackerWorker.cpp @@ -7,8 +7,6 @@ TrackerWorker::TrackerWorker(QObject* parent) { qRegisterMetaType < QVector<float> >("QVectorFloat"); - qRegisterMetaType<TrackingResults>("TrackingResults"); - rois.push_back(QRect(0,0,100,100)); rois.push_back(QRect(0,0,100,100)); @@ -28,10 +26,9 @@ void TrackerWorker::onFrameGrabbed(Mat src) int cMinArea = areaConstraints.at(2); int cMaxArea = areaConstraints.at(3); - TrackingResults eyeTrackingResult; - eyeTrackingResult.cCornea = Point(0,0); - eyeTrackingResult.cPupil = Point(0,0); - eyeTrackingResult.pDiam = 0; + Point cCornea(0,0); + Point cPupil(0,0); + double pDiam = 0; std::vector<Mat> rgb; split(src, rgb); @@ -59,8 +56,8 @@ void TrackerWorker::onFrameGrabbed(Mat src) if(pContour.size()>4){ /*Determine centroid by fitting an ellipse*/ pRect = fitEllipse(pContour); - eyeTrackingResult.cPupil = pRect.center; - eyeTrackingResult.pDiam = (pRect.boundingRect().height + pRect.boundingRect().width) / 2; + cPupil = pRect.center; + pDiam = (pRect.boundingRect().height + pRect.boundingRect().width) / 2; } @@ -88,12 +85,10 @@ void TrackerWorker::onFrameGrabbed(Mat src) if(cContour.size()>4){ /*Determine centroid with boundingRect*/ Rect cRect = boundingRect(cContour); - eyeTrackingResult.cCornea.x = cRect.x + (cRect.width / 2); - eyeTrackingResult.cCornea.y = cRect.y + (cRect.height / 2); + cCornea.x = cRect.x + (cRect.width / 2); + cCornea.y = cRect.y + (cRect.height / 2); } - emit(trackingResult(eyeTrackingResult)); - /*Generate preview image*/ Mat previewIm(src.size(), CV_8U, double(0)); previewIm(Rect(rois.at(0).x(),rois.at(0).y(), rois.at(0).width(), rois.at(0).height())) = pMask*255; @@ -108,8 +103,8 @@ void TrackerWorker::onFrameGrabbed(Mat src) outputIm = src; } - circle(outputIm, eyeTrackingResult.cPupil, 10, Scalar(0,255,0), -1, 8, 0); - circle(outputIm, eyeTrackingResult.cCornea, 10, Scalar(255,0,255), -1, 8, 0); + circle(outputIm, cPupil, 10, Scalar(0,255,0), -1, 8, 0); + circle(outputIm, cCornea, 10, Scalar(255,0,255), -1, 8, 0); //std::vector<std::vector<Point> > pContourV = std::vector<std::vector<Point> >(1, pContour); //drawContours(outputIm, pContourV, -1, Scalar(0,255,0), 2, 8); @@ -119,8 +114,14 @@ void TrackerWorker::onFrameGrabbed(Mat src) ellipse(outputIm, pRect, Scalar(0,255,0), 10, 8); + std::vector<double> result; + result.push_back(cPupil.x); + result.push_back(cPupil.y); + result.push_back(cCornea.x); + result.push_back(cCornea.y); + result.push_back(pDiam); + emit(trackingResult(result)); emit(trackingPreview(outputIm)); - emit(trackingResult(eyeTrackingResult)); } void TrackerWorker::onThresholdChanged(int index, int value) diff --git a/TrackerWorker.h b/TrackerWorker.h index 8a0c36f..7cd4bc7 100644 --- a/TrackerWorker.h +++ b/TrackerWorker.h @@ -1,7 +1,5 @@ #ifndef TRACKERWORKER_H #define TRACKERWORKER_H -#include "TrackerWorkerInterface.h" - #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> @@ -10,8 +8,7 @@ #include <QtGlobal> #include <QVector> #include <QRect> - -#include "TrackingResults.h" +#include "TrackerWorkerInterface.h" using namespace cv; @@ -38,10 +35,9 @@ public slots: signals: - //void trackingResult(QVector<float>); - void trackingResult(TrackingResults eyeTrackingResults); void trackingPreview(Mat); void trackingRois(QVector<Mat>); + void trackingResult(std::vector<double> data); }; diff --git a/TrackingResults.h b/TrackingResults.h deleted file mode 100644 index 621ddff..0000000 --- a/TrackingResults.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TRACKINGRESULTS_H -#define TRACKINGRESULTS_H -#include <opencv2/core/core.hpp> - - -struct TrackingResults{ - cv::Point cPupil; - cv::Point cCornea; - double pDiam; -}; - - - -#endif // TRACKINGRESULTS_H