Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Renamed project to EyeTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-kretschmerf committed Nov 25, 2016
1 parent abde56f commit 219edd9
Show file tree
Hide file tree
Showing 9 changed files with 485 additions and 540 deletions.
74 changes: 30 additions & 44 deletions TrackerPlugin_PupilDiam.cpp → TrackerPlugin_EyeTracker.cpp
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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++){
Expand All @@ -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"));
Expand Down Expand Up @@ -127,24 +134,23 @@ 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)));
connect(this, SIGNAL(posChanged(int, QPoint)), trackerWorker, SLOT(onPosChanged(int, QPoint)));
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);
Expand All @@ -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 ){
Expand All @@ -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()) &
Expand All @@ -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++){
Expand All @@ -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);
Expand Down
16 changes: 9 additions & 7 deletions TrackerPlugin_PupilDiam.h → TrackerPlugin_EyeTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
62 changes: 62 additions & 0 deletions TrackerPlugin_EyeTracker.pro
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 219edd9

Please sign in to comment.